robotology / idyntree

Multibody Dynamics Library designed for Free Floating Robots
BSD 3-Clause "New" or "Revised" License
155 stars 65 forks source link

Add method to help calibrating multiple FT sensors attached to the same submodel #1091

Closed traversaro closed 10 months ago

traversaro commented 10 months ago

This PR adds the ExtWrenchesAndJointTorquesEstimator::computeSubModelMatrixRelatingFTSensorsMeasuresAndKinematics method, that can be used to compute for each submodel without any external wrench, the equation that relates the FT sensor measures with the kinematics-related known terms. This function can be useful to perform calibration of multiple FT connected to the same submodel without any external force, even if multiple links (that belong to different submodels) have external forces on it.

For more theorical details, check the ExtWrenchesAndJointTorquesEstimator::computeSubModelMatrixRelatingFTSensorsMeasuresAndKinematics documentation, and for details on how to use the class check the added tests.

traversaro commented 10 months ago
  • Since the matrix A and the vector b are computed to obtain the expected FT wrenches, why provide A and b instead of computing wsm by the pseudo-inverse? In this way, the function will be compatible with the method computeExpectedFTSensorsMeasurements(), especially since you checked in the unit test that the expected computed with the latter provides a correct solution for the A and b pair computed by the new method.

The main reason is that in this way we can plug this information in any learning/identification/calibration algorithm. Let's say that you are in the case in which you have a model in which they are two FT sensors, connected in a chain:

ExampleFTs drawio

(code: ExampleFTs.zip )

For this model, let's say that you have a dataset composed by $i = 1 ... N$ data points, and:

And you want to learn the parameters for the following generic non-linear calibration models for the FT sensors (this models could be linear models, polynomial models, feedforward Neural networks):

$$ \mathrm{f}^i_1 = \mathrm{f}_1 (r_1^i, \theta_1) $$

$$ \mathrm{f}^i_2 = \mathrm{f}_2 (r_1^i, \theta_2) $$

Using the method introduced in this PR, you can write the following cost function to minimize:

$$ C(\theta_1, \theta2) = \sum{i=1}^{N} \sum{sm=1}^3 \left[ {SM}_{sm} \cap c^i{sm} = \emptyset \right] \left| A^i_j \begin{bmatrix} \mathrm{f}_1 (r_1^i, \theta_1) \\ \mathrm{f}_2 (r_1^i, \theta_2) \end{bmatrix} - b^i_j \right|^2 $$

Where:

The identification problem could then be solved by:

$$ (\theta_1^*, \theta_2^*) = argmin_{(\theta_1, \theta_2} C(\theta_1, \theta_2) $$

If the method gave in input directly the $\mathrm{f}^i_1$ and $\mathrm{f}^i_2$ computed by solving the pseudoinverse, you could not write (unless I am missing something, that is possible) the cost function that $C(\theta_1, \theta_2)$.

Note that in specific cases (for example if both $L_1$ and $L_4$ are in in contact, i.e. $c^i = \lbrace L_1, L_4 \rbrace$) the size of $A$ is $6 \times 12$, and so for sure there are infinite solution that minimize the least square residual.

traversaro commented 10 months ago

I am not excited about the naming, but let's merge this, we can always change names later.

HosameldinMohamed commented 10 months ago

Can we generate MATLAB bindings for this method?

Maybe you could give me pointers on how to do it?

traversaro commented 10 months ago

Good idea, so we see if they work! MATLAB bindings generation is done by an action, let me trigger it.

HosameldinMohamed commented 10 months ago

Good idea, so we see if they work! MATLAB bindings generation is done by an action, let me trigger it.

Greate! Thanks a lot!