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

Adds the expressions for writing planners for a humanoid robot #10

Merged
merged 106 commits into from
Jan 22, 2024

Conversation

S-Dafarra
Copy link
Member

@S-Dafarra S-Dafarra commented Jan 16, 2024

This PR adds all the functions I needed to write planners for a humanoid robot. In particular:

  • a set of variables from which it is possible to start when writing the optimal control problems
  • a set of functions (that return casadi functions) to have prebuilt expressions useful when writing costs and constraints
  • a generic terrain definition as done by @rob-mau
  • interpolation utilities
  • visualization utilities

Renamed a parameter in dcc_complementarity_margin for better clarity
…ion task

Renamed the yaw alignment function for consistency
@S-Dafarra S-Dafarra self-assigned this Jan 16, 2024
@DanielePucci
Copy link
Member

CC @ami-iit/artificial-mechanical-intelligence

Copy link
Member

@diegoferigo diegoferigo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks really good @S-Dafarra! I have mainly comments on patterns plus some other minor ones. I skipped the visualization files, and went quickly on the terrains since probably @rob-mau had a better look at them.

The pattern using variable names seems working fine. However, it might be quite difficult to extend from the user point of view. Probably on the long term it would be helpful to have a sort of database (like a dict or a enum) containing all the names already used internally as casadi variables (and using them as default function parameters instead of using plain strings - quite helpful also for refactoring).

Nothing blocking though, approving regardless.

src/hippopt/robot_planning/expressions/centroidal.py Outdated Show resolved Hide resolved
src/hippopt/robot_planning/expressions/centroidal.py Outdated Show resolved Hide resolved
src/hippopt/robot_planning/expressions/centroidal.py Outdated Show resolved Hide resolved
src/hippopt/robot_planning/expressions/centroidal.py Outdated Show resolved Hide resolved
src/hippopt/robot_planning/expressions/centroidal.py Outdated Show resolved Hide resolved
src/hippopt/robot_planning/utilities/interpolators.py Outdated Show resolved Hide resolved
src/hippopt/robot_planning/variables/contacts.py Outdated Show resolved Hide resolved
@S-Dafarra S-Dafarra force-pushed the humanoidPlanning_robot_planning branch 2 times, most recently from ecfa28f to eb1e074 Compare January 19, 2024 10:54
S-Dafarra and others added 2 commits January 19, 2024 12:06
@S-Dafarra S-Dafarra force-pushed the humanoidPlanning_robot_planning branch from eb1e074 to f01632b Compare January 19, 2024 11:07
@S-Dafarra
Copy link
Member Author

The pattern using variable names seems working fine. However, it might be quite difficult to extend from the user point of view. Probably on the long term it would be helpful to have a sort of database (like a dict or a enum) containing all the names already used internally as casadi variables (and using them as default function parameters instead of using plain strings - quite helpful also for refactoring).

Right now, I used a dictionary (will be added in the next PR, see

function_inputs = {
"mass_name": sym.mass.name(),
"momentum_name": sym.system.centroidal_momentum.name(),
"com_name": sym.system.com.name(),
"quaternion_xyzw_name": "q",
"gravity_name": sym.gravity.name(),
"point_position_names": [],
"point_force_names": [],
"point_position_in_frame_name": "p_parent",
"base_position_name": "pb",
"base_quaternion_xyzw_name": "qb",
"joint_positions_name": "s",
"base_position_derivative_name": "pb_dot",
"base_quaternion_xyzw_derivative_name": "qb_dot",
"joint_velocities_name": "s_dot",
"point_position_name": "p",
"point_force_name": "f",
"point_velocity_name": "v",
"point_force_derivative_name": "f_dot",
"point_position_control_name": "u_p",
"height_multiplier_name": "kt",
"dcc_gain_name": "k_bs",
"dcc_epsilon_name": "eps",
"static_friction_name": "mu_s",
"desired_quaternion_xyzw_name": "qd",
"first_point_name": "p_0",
"second_point_name": "p_1",
"desired_yaw_name": "yd",
"desired_height_name": "hd",
"options": self.settings.casadi_function_options,
}
). I thought a bit about using a more structured way, but the functions might need different types of inputs and I did not manage to find a way to unify in a clean way.

In any case, the user can also avoid defining custom names. Nonetheless, when specifying a dynamics, the name of the variables used in the function is important. The integrators automatically call the dynamics' functions with the input variables matching the name used in the functions. This is why I needed to keep this possibility open. Let me know if it is not clear 😉

@diegoferigo I should also have dealt with your comments, if you are ok with it, I would merge 😉

@S-Dafarra S-Dafarra merged commit e375b05 into main Jan 22, 2024
16 checks passed
@S-Dafarra S-Dafarra deleted the humanoidPlanning_robot_planning branch January 26, 2024 18:00
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.

5 participants