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

Integrate the YOGA++ (floating-base-balancing-torque-control) with the matlab-whole-body-simulator #122

Merged
merged 20 commits into from
May 10, 2021

Conversation

nunoguedelha
Copy link
Contributor

Implements #121 .

…licate of floating-base-balancing-torque-control
- Replaced Gazebo interface blocks (setTorque, getPosition, etc) by:
    - RobotDynWithContacts,
    - IMUsensor,
    - RobotVisualizer.
- Added configRobotSim.m config file specfic to the simulation, making
  sure there were no collisions with configRobot.m.
- Defined Visualizer init configuration.
…kHz and the controller at 100Hz

- Define additional joints for the simulation robot model: neck joints.
  The neck joints are not part of the joints controlled by the high-level torque controller.
- Fixes in the controller sub-system for settling the same Config.tStep sample time in all
  the sub-system blcoks:
    - Set "Inf" sampling time in reflected inertia block.
    - Replaced the Holder blocks from the WBT library by a re-implementation in the "utilityBlocks"
      library ("Joint Torque Saturation", "LFoot to base link transform", "RFoot to base link transform",
      "State Machine").
    - In the "neck transform" block, replaced port read of neck joints by input from the simulator.
      (Routed neck position from main inputs of the controller system)
      (Added selectors to the controller inputs for removing the neck joints, as these are processed
      separately)
    - Added a zero order hold to the clock input of the state machine, otherwise the sampling time type
      becomes "continuous" and propagates throughout the model, preventing the compilation.
    - Added a unit delay between the controller output and the simulator.
- Other minor fixes in the controller sub-system, inr:
    - Removed "measured joint torques" from the visualizer.
    - Routed the joint acceleration "measurements" from the main input to the joint reflected
      inertia block (tags are not authorized across sub-systems when treating the parent sub-system
      as an atomic unit).
- Treat the controller sub-system as an atomic unit.
…UM_BASED_TORQUE_CONTROL" as atomic unit.

- Moved "Dump and visualze" into "MOMENTUM_BASED_TORQUE_CONTROL" sub-system.
- Moved the "STATE_MACHINE" clock outside the controller sub-system.
- Removed zero-order holder in front of that clock.
- Set all controller input ports sample time to inherited.
- Treat "MOMENTUM_BASED_TORQUE_CONTROL" sub-system as an atomic unit.
- Replaced delay block by memory block between the controller and the simulator.
- Fixed model tasking and sampling time options:
  Removed "Treat each dicrete rate as a separate task" option, which was
  causing data rates transition problems between the simulator (1kHz) and the
  controller (100Hz).
- The model is now fully compiling.
- Used QP interface with constraints lower bound input "lbA". Set lbA=-Inf.
- For more details refer to original issue tracker
  https://github.com/dic-iit/element_ironcub-control/issues/164
…+ configuration)

- Base position was set to [0 0 0.619], tuned to get positive contact forces from the
  very first simulation step.
…ualizer at 10ms

- Tuning tests 1 to 3 (Refer to #121)
- Tuning tests 4,5,6
    Controller Motor reflected inertia ON/OFF / Harmonic Drive inertia ON/OFF / Coupling ON/OFF
    Simulator Motor reflected inertia ON
    Simulator Friction = 0.2
- Test 7
    Controller Motor reflected inertia OFF
    Simulator Motor reflected inertia ON
    Simulator Friction = 0.2 for all except the ankle pitch and roll = 0.6

=> More stable for the first 5s then same instability and divergence.
- Changed the initial joint configuration in order to bend the knees.
- lower by 10cm the desired CoM hight: `StateMachine.CoM_delta(:,3) = -0.10`.
…`. Increase KD gains.

- No need to add an offset to the desired CoM since the initial joint configuration already
  has the knees bent. There is enough margin to maintain the CoM hight when transitioning the
  CoM to the left or ight foot.
- Increase the Gain.KD_CoM and Gain.KD_postural as the velocity feedback in the simulator is
  accurate. This stabilizes significantly the joint trajectory.

At this point, the YOGA with support on left foot works and is stable. The robot falls when
attempting the second YOGA on the right foot.
@nunoguedelha
Copy link
Contributor Author

How to test this PR

  • Install the superbuild as usual, lates release (LatestRelease set to LatestRelease).
  • in src/matlab-whole-body-simulator checkout devel.
  • re-install matlab-whole-body-simulator target.
  • in whole-body-controllers set working directory src/whole-body-controllers/controllers/floating-base-balancing-torque-control-with-simulator
  • open model torqueControlBalancingWithSimu.mdl
  • set robot model setenv('YARP_ROBOT_NAME','iCubGazeboV2_5')
  • run

@nunoguedelha
Copy link
Contributor Author

@traversaro @gabrielenava , the PR is ready for review.

@nunoguedelha nunoguedelha marked this pull request as ready for review May 7, 2021 15:38
@traversaro
Copy link
Member

Thanks @nunoguedelha , two comments:

  • Could we install torqueControlBalancingWithSimu.mdl, perhaps in a matlab/examples directory or similar? In this way the example is available also for people that install whole-body-controllers via conda, otherwise if the use need to know how to use git to download the examples we would lose the main advantage of a one line installation.
  • Why do we need to set manually setenv('YARP_ROBOT_NAME','iCubGazeboV2_5') ? Can't we set it somewhere in the example initialization or similar?

@gabrielenava
Copy link
Collaborator

gabrielenava commented May 10, 2021

Tested following #122 (comment) on my PC with Ubuntu 20.04 LTS.

Seems working fine:
image

I've found it a bit slow in the initializing and terminating processes, is it normal? The simulation instead was running with a quite good update rate.

A couple of comments:

  • Could you add matlab-whole-body-simulator also to the list of dependencies in the main WBC readme, and specify that it is an optional dependency for Gazebo-free simulations?

  • Also, feel free to remove the previous simulink-balancing simulator, also from the list of available controllers (and to add instead your simulator). We can add the simulink-balancing-simulator to the list of legacy controllers in the README, in the past I moved old controllers in WBI-Toolbox-Controllers but in this case maybe it is just sufficient to point the last commit where the simulink-balancing simulator is still present.

@nunoguedelha
Copy link
Contributor Author

Sure @gabrielenava , I'll do a mini-PR to update the documentation covering all the points you've listed. Thanks.

@nunoguedelha
Copy link
Contributor Author

nunoguedelha commented May 10, 2021

Thanks @nunoguedelha , two comments:

* Could we install `torqueControlBalancingWithSimu.mdl`, perhaps in a `matlab/examples` directory or similar? In this way the example is available also for people that install `whole-body-controllers` via conda, otherwise if the use need to know how to use git to download the examples we would lose the main advantage of a one line installation.

* Why do we need to set manually `setenv('YARP_ROBOT_NAME','iCubGazeboV2_5')` ? Can't we set it somewhere in the example initialization or similar?

and addressing this too @traversaro .

Could we install torqueControlBalancingWithSimu.mdl,

Yes indeed.

Why do we need to set manually ...

It makes usually sense to set it separately when there are several models. It makes also sense to have a working model set by default, and right now iCubGazeboV2_5 is the only one, so I'll add the setting of a default YARP_ROBOT_NAME = iCubGazeboV2_5 in the model initialization as you suggested.

@nunoguedelha nunoguedelha merged commit c217f05 into devel May 10, 2021
@nunoguedelha
Copy link
Contributor Author

I've found it a bit slow in the initializing and terminating processes, is it normal? The simulation instead was running with a quite good update rate.

It's slow for me too. Probably because there are more sub-systems treated as atomic blocks (the cntroller, the simulator, the visualizer), which results in more code generation, which is slower at compilation but faster at runtime.

@nunoguedelha nunoguedelha deleted the feature/replace-gazebo-by-matlab-simulator branch May 10, 2021 17:02
nunoguedelha added a commit that referenced this pull request May 10, 2021
nunoguedelha added a commit that referenced this pull request May 10, 2021
Update with w.r.t. changes from after #122.
nunoguedelha added a commit that referenced this pull request May 11, 2021
Update with w.r.t. changes from after #122.
nunoguedelha added a commit that referenced this pull request May 11, 2021
- Update README (after #122)
- Converted floating-base-balancing-torque-control-with-simulator into a package +floatingBaseBalancingTorqueControlWithSimulator
- Added the package installation through CMake.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants