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

CoM Trajectory Generation from HMC #140

Draft
wants to merge 43 commits into
base: master
Choose a base branch
from

Conversation

arntanguy
Copy link
Collaborator

This PR is an ongoing implementation of some of HMC's CoM generation features, mainly the long-term and short-term CoM trajectory generation introduced in

Online 3D CoM Trajectory Generation for Multi-Contact Locomotion Synchronizing Contact, Mitsuharu Morisawa et al., IROS 2018

In its current state it is not necessarily meant to be merged, but mostly to show that the current status of this implementation should someone wish to take over (@mmurooka, @mitsuharu-morisawa). It might be worth splitting this work into its own mc_planning project, and merging it with @mmurooka's own planning developments of #109.

  • For a minimalist usage code sample, please refer to mc_sample_CoMGeneration (code / documentation). It is roughly equivalent to hmc's generator example

  • This can be tested using the new sample controller CoMTrajectoryGeneration (code). It uses the same generator class used by mc_sample_CoMGeneration to generate a CoM trajectory between footsteps, and tracks it using LIPMStabilizer. You can run this sample controller with

MainRobot: HRP5P # or HRP2DRC, HRP4, etc
Timestep: 0.002
Enabled: CoMTrajectoryGeneration

Here is a video of what to expect:

vokoscreen-2021-03-30_16-56-52.mp4

The generated documentation for this branch is available at https://arntanguy.github.io/mc_rtc/doxygen.html:

  • The main changes are implemented in the mc_planning namespace.
  • The most relevant class to look at is the generator class that implements an easy to use .

In addition this PR implements:

  • A generic LookupTable implementation (code / documentation) to pre-compute computationally expensive functions (in this case cosh/sinh that are called for the whole time-horizon at every iteration

  • A basic tool mc_bin_compare (81f44d8) to compare data between log files. This is used here to check for regressions (
    9b1bd15) against a reference log file of what the generator sample mc_sample_CoMGeneration should do.

  • Utilities to safely iterate over preview windows and convert between time/indices. The intent was to limit the risk of mistakes in handling indices when iterating over preview windows. You can see for instance the PreviewWindowView

Missing:

  • feeding back the real robot state into the CoM trajectory generation. I believe that implementing this would provide a significant improvement in the quality of stabilization in mc_rtc, by no longer only relying on the stabilizer's tracking performance, but also adapting the reference trajectory to account for perturbations.
  • Multi-contact implementation from

    Multi-contact Stabilization of a Humanoid Robot for Realizing Dynamic Contact Transitions on Non-coplanar Surfaces - Morisawa et al.

  • walking example

- Import implementation of LinearTimeInvariantInvertedPendulum from HMC2
- Adapt to mc_rtc
- Remove custom types
- clang-format code
Adds a LookupTable implementation for convenient pre-computation,
storing and access of heavy functions.
- Import LinearControl systems used for generating short-term com
trajectories
- Replace openhrp eigen types with Eigen
- Cleanup formatting and unused commented-out code
- Import all necessary dependencies
- Run HMC's sample generator.cpp as-is
Replace the old confusing and inaccurate implementation with the new
generic LookupTable implementation:

```
[info] Omega2         = 12.258312499999999
[info] Original omega = 3.498714049475893
[info] New      omega = 3.5033993502025997
[info] Actual   omega = 3.5011872986174275
[info] Original cosh  = 1.0003195295150686
[info] New      cosh  = 1.0001534265107093
[info] Actual   cosh  = 1.0001532328194729
[info] Original sinh  = 0.02528163620591862 (previous code)
[info] New      sinh  = 0.01751789259907999 (new lookup table implementation)
[info] Actual   sinh  = 0.017506830645288594 (expected value)
```

Note better accuracy could be achieved using a non-uniform distribution.
Bugfix: out-of-bounds access to array m_steps
…ctory

Write a first simple example that:
- Generates the CoM/ZMP trajectory (open-loop)
- Tracks it with the LIPMStabilizer from Stephane
- Adds GUI/live plot visualization
If a log file contains one column or less, mc_log_ui would crash as it
expects more entries to be available. This commit displays an error
message instead.
Bug: Does not interpolate the reference ZMP trajectory
Implements helpers to handle the logic behind discrete reference
provided as a step function:
- Ensures that steps are ordered by time (using std::set)
- Convenience to create steps, add step, find predecessors/successors
- Implement efficient logic for sequentially exploiting footsteps in an
online setting: removing old footsteps, updating the previous/next step,
etc

This leads to a more readable and safer implementation of the original
generator class, and allows to cleanly change footsteps at any time.
The sample state CoMTrajectoryGeneration has been updated accordingly.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant