Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add optional format alternative to motor reflected inertia #44

Conversation

nunoguedelha
Copy link
Collaborator

@nunoguedelha nunoguedelha commented May 7, 2021

Motivation and main changes

The integration of the matlab-whole-body-simulator with the YOGA controller from whole-body-controllers repository (robotology/whole-body-controllers#122) required a change in the format of the reflected motor inertia parameters. These used to be defined as a column vector composed of the diagonal terms of $\Gamma^{-\top} G^{-1} I _m G^{-1} \Gamma^{-1}$, since this expression resulted in a diagonal matrix in the case of a robot without coupled joints. In the case of iCub, the shoulder joints are coupled, as well as the torso joints. The matrix $\Gamma^{-\top} G^{-1} I _m G^{-1} \Gamma^{-1}$ is not diagonal anymore (robotology/whole-body-controllers#121 (comment)), and so the coupling terms need to be accounted for. For this reason we pass the full matrix mentioned above to the simulation block RobotDynWithContacts.

There are two impacts on the block RobotDynWithContacts:

  1. library block interface handling two possible input formats:
    • [NDOFx1] (no coupling): step_block.motorReflectedInertiaFormat = 'vector'
    • [N_DOFxN_DOF] (supports coupling): step_block.motorReflectedInertiaFormat = 'matrix'
  2. computation of M depending on step_block.motorReflectedInertiaFormat
    • 'vector': Mout = M + diag([zeros(6,1);motorInertias]);
    • 'matrix': Mout = M + blkdiag(zeros(6),motorInertias);

Design Details

  1. Changes on block RobotDynWithContacts interface
  • Add 'motorReflectedInertiaFormat' popup parameter to the simulator mask.

image

=> A parameter #4 was added in the "parameters & Dialog" pane of the mask editing.
=> The mask initialization was updated for setting propMotorReflectedInertiaFormat input to MATLAB System lying under the mask.
=> input parameter propMotorReflectedInertiaFormat was added to the MATLAB System.

Working combinations are as shown below:

  • motor inertia input format [NDOFx1] :

image

  • motor inertia input format [NDOFxNDOF] :

image

All other combinations fail.

  1. computation of M depending on step_block.motorReflectedInertiaFormat
  • The addition of the motor inertia to the mass matrix depends on the flag step_block.motorReflectedInertiaFormat.
  • That processing had to be done in 'step_block', as the code generation considers
    at compilation time also the branching paths not accessible at runtime, causing a
    size mismatch in the computation of M if the branching consition is not a constant,
    or if it is "Tunable".

PR verification

Check the working and failing combinations described above, for instance on model iCubGenova04.
When setting a "failing" combination, the model compiles but fails early at runtime:
image
or...
image

- Add 'motorReflectedInertiaFormat' popup parameter to the simulator mask.
  'vector': the input 'motorInertias' is the vector of diagonal terms of Im*inv(G)
  'matrix': the input 'motorInertias' is the matrix inv(TG)'*Im*inv(TG). The inertia
            can be coupled.
- Propagated 'motorReflectedInertiaFormat' to the underlying MATLAB System.
- The addition of the motor inertia to the mass matrix depends on this flag.
  'matrix'=> M = M + blkdiag(zeros(6),motorInertias), accounting for all the
  coupling terms in 'motorInertias'.
- That processing had to be done in 'step_block', as the code generation considers
  at compilation time also the branching paths not accessible at runtime, causing a
  size mismatch in the computation of M if the branching consition is not a constant,
  or if it is "Tunable".
…lization

- fixed the mask initialization: the param needs to be retrieved through get_param,
  otherwise it gets the wrong value.
- the initialization of 'motorReflectedInertiaFormat' to 'vector' in the 'step_block'
  class was corrupting its value and causing the switch case to fall on the 'otherwise'
  case when processing the mass matrix. As a result, even with wrong motor inertia dimensions,
  the model would run successfully but without ever applying the motor inertias.
- Checked that the combinations [input inertia vector/param 'matrix'] and [input inertia matrix/
  param 'vector'] fail at runtime as expected.
@nunoguedelha nunoguedelha self-assigned this May 7, 2021
@nunoguedelha
Copy link
Collaborator Author

Side note on model RRbot1

For using this model you need to comment the IMU block in the main model.

@nunoguedelha
Copy link
Collaborator Author

@traversaro , this is ready for review. I will be checking the installation of the library and integration with the controller (robotology/whole-body-controllers#122).

@nunoguedelha nunoguedelha marked this pull request as ready for review May 7, 2021 14:55
@nunoguedelha nunoguedelha requested review from Giulero and traversaro May 7, 2021 14:55
@nunoguedelha nunoguedelha added the enhancement New feature or request label May 7, 2021
nunoguedelha added a commit to robotology/whole-body-controllers that referenced this pull request May 7, 2021
@traversaro
Copy link
Contributor

cc @CarlottaSartore

@nunoguedelha
Copy link
Collaborator Author

CC @VenusPasandi

@nunoguedelha nunoguedelha merged commit d851c2b into devel May 8, 2021
@nunoguedelha nunoguedelha deleted the feature/add-optional-format-alternative-to-motor-reflected-inertia branch May 8, 2021 10:53
nunoguedelha added a commit that referenced this pull request May 10, 2021
Update with respect to the last PR #44 .
@nunoguedelha nunoguedelha mentioned this pull request May 10, 2021
nunoguedelha added a commit that referenced this pull request May 10, 2021
Update with respect to the last PR #44 .
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants