Repository navigation
Add method to get the next position for each foot of SOLO, add ROS 2 demos, and transform project to ROS2 package #20
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
Open
swuuu
wants to merge
19
commits into
machines-in-motion:master
Choose a base branch
from
swuuu:master
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
19 commits
Select commit
Hold shift + click to select a range
57ae758
Add method to get next step position for each foot of solo
swuuu 755b7c4
Remove .vscode
swuuu 471469a
Add reactive planner script for C++ and modify cmake and package.xml …
swuuu 4688e82
Add reactive planner python and C++ scripts and add package.xml & mod…
swuuu 7c5054b
Merge branch 'master' of github.com:swuuu/reactive_planners
swuuu e1e32a6
Update package.xml
swuuu 94769e2
Add copyright info
swuuu 97c4aea
Add back license tag to avoid build error
swuuu 770748d
Remove ament_cmake
swuuu 89aa097
Add license
swuuu ab13ef1
Add demo_reactive_planners_solo12 file as source file, link with mim_…
swuuu 9d6b1ec
Remove normalizing quaternion step
swuuu e960493
Rename y_des to yaw_velocity_des in cpp files
swuuu 409cf57
Rename demo files, add reactive_planners_controller_solo12 to CMake, …
swuuu bf0529d
Remove ROS comment in CMake file
swuuu a4c9a91
Simplify vector assignment
swuuu bc43fc7
Add newline to end of file
swuuu fd742f3
Add missing dependencies in package.xml
swuuu ebb1502
Rename to reactive_planners_controller_solo and refactor v_des
swuuu File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -354,3 +354,9 @@ ENV/ | |
| # Rope project settings | ||
| .ropeproject | ||
|
|
||
| # CLion | ||
| .idea/ | ||
|
|
||
| # VSCode | ||
| .vscode/ | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
223 changes: 223 additions & 0 deletions
223
include/reactive_planners/reactive_planners_controller_solo12.hpp
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,223 @@ | ||
| /** | ||
| * @file | ||
| * @license BSD 3-clause | ||
| * @copyright Copyright (c) 2023, New York University and Max Planck | ||
| * Gesellschaft | ||
| * | ||
| * @brief A C++ translation of the demos/demo_reactive_planners_solo12_step_adjustment_walk.ipynb script (the first part) | ||
| * | ||
| * The 4 fields to control the direction of SOLO are yaw_velocity_des, yaw_des, com_des, and v_des | ||
| */ | ||
| #pragma once | ||
|
|
||
| #include <Eigen/Dense> | ||
| #include <pinocchio/parsers/urdf.hpp> | ||
| #include <pinocchio/multibody/data.hpp> | ||
| #include "mim_control/impedance_controller.hpp" | ||
| #include "mim_control/centroidal_pd_controller.hpp" | ||
| #include "mim_control/centroidal_force_qp_controller.hpp" | ||
| #include "reactive_planners/quadruped_dcm_reactive_stepper.hpp" | ||
|
|
||
| namespace reactive_planners | ||
| { | ||
| class ReactivePlannersControllerSolo { | ||
| public: | ||
| ReactivePlannersControllerSolo(); | ||
|
|
||
| ~ReactivePlannersControllerSolo(); | ||
|
|
||
| /** | ||
| * @brief Initializes the class | ||
| * | ||
| * @param path_to_urdf path to SOLO's URDF to build the pinocchio model | ||
| */ | ||
| ReactivePlannersControllerSolo(std::string path_to_urdf); | ||
|
|
||
| /** | ||
| * @brief Initializes the quadruped_dcm_reactive_stepper | ||
| * Sets the parameters for some controllers used by the script (e.g., params related to SOLO's direction). | ||
| * | ||
| * @param q base + joint configuration | ||
| * @param v_des {velocity desired in x, velocity desired in y, desired yaw velocity} | ||
| */ | ||
| void initialize(Eigen::Matrix<double, 19, 1> &q, Eigen::Vector3d &v_des); | ||
|
|
||
| /** | ||
| * @brief Main function: computes the torques from the reactive planner | ||
| * | ||
| * @param q vector of 19 elements composed on [base position (3 elements), base orientation (4 elements), joint configurations (12 elements)] | ||
| * @param dq vector of 18 elements composed of [base velocity (3), base ang vel (3), joint velocities (12)] | ||
| * @param control_time time parameter for the quadruped_dcm_reactive_stepper | ||
| * @param v_des {velocity desired in x, velocity desired in y, desired yaw} | ||
| * @return torques to send to SOLO | ||
| */ | ||
| Eigen::VectorXd compute_torques(Eigen::Matrix<double, 19, 1> &q, Eigen::Matrix<double, 18, 1> &dq, double control_time, Eigen::Vector3d &v_des); | ||
|
|
||
| /** | ||
| * @brief Start the stepping | ||
| */ | ||
| void quadruped_dcm_reactive_stepper_start(); | ||
|
|
||
| /** | ||
| * @brief Stop the stepping | ||
| */ | ||
| void quadruped_dcm_reactive_stepper_stop(); | ||
|
|
||
| private: | ||
|
|
||
| /* Pinocchio */ | ||
|
|
||
| /** @brief Pinocchio model */ | ||
| pinocchio::Model model; | ||
|
|
||
| /** @brief Pinoochio data */ | ||
| pinocchio::Data data; | ||
|
|
||
| /* Impedance controller variables */ | ||
|
|
||
| /** @brief Impedance control proportional gain */ | ||
| Eigen::VectorXd kp; | ||
|
|
||
| /** @brief Impedance control derivative gain */ | ||
| Eigen::VectorXd kd; | ||
|
|
||
| /** @brief End effector names */ | ||
| std::vector<std::string> endeff_names; | ||
|
|
||
| /** @brief Vector of impedance controllers for each foot */ | ||
| std::vector<mim_control::ImpedanceController> imp_ctrls; | ||
|
|
||
| /* Centroidal Controller Variables*/ | ||
|
|
||
| /** @brief Friction coefficient */ | ||
| double mu; | ||
|
|
||
| /** @brief Proportional gain for COM position */ | ||
| Eigen::Vector3d kc; | ||
|
|
||
| /** @brief Derivative gain for COM position */ | ||
| Eigen::Vector3d dc; | ||
|
|
||
| /** @brief Proportional gain for COM orientation */ | ||
| Eigen::Vector3d kb; | ||
|
|
||
| /** @brief Derivative gain for COM orientation */ | ||
| Eigen::Vector3d db; | ||
|
|
||
| /** @brief QP linear penalty */ | ||
| Eigen::Vector3d qp_penalty_lin; | ||
|
|
||
| /** @brief QP angular penalty */ | ||
| Eigen::Vector3d qp_penalty_ang; | ||
|
|
||
| /** @brief linear velocity desired */ | ||
| Eigen::Vector3d linear_vel_des; | ||
|
|
||
| /** @brief Centroidal PD controller */ | ||
| mim_control::CentroidalPDController centrl_pd_ctrl; | ||
|
|
||
| /** @brief Quadratic program for desired wrench */ | ||
| mim_control::CentroidalForceQPController force_qp; | ||
|
|
||
| /* Quadruped DCM reactive stepper */ | ||
|
|
||
| /** @brief Left foot is in contact with the ground, if | ||
| * not then the right foot is. */ | ||
| bool is_left_leg_in_contact; | ||
|
|
||
| /** @brief Lower bound in the forward direction where to step. */ | ||
| double l_min; | ||
|
|
||
| /** @brief Upper bound in the forward direction where to step. */ | ||
| double l_max; | ||
|
|
||
| /** @brief Lower bound in the lateral direction where to step. */ | ||
| double w_min; | ||
|
|
||
| /** @brief Upper bound in the lateral direction where to step. */ | ||
| double w_max; | ||
|
|
||
| /** @brief The minimum time required to step. */ | ||
| double t_min; | ||
|
|
||
| /** @brief The maximum time required to step. */ | ||
| double t_max; | ||
|
|
||
| /** @brief The nominal stride length. */ | ||
| double l_p; | ||
|
|
||
| /** @brief Center of mass height from the ground. */ | ||
| double com_height; | ||
|
|
||
| /** @brief Total weight of the robot. */ | ||
| Eigen::VectorXd weight; | ||
|
|
||
| /** @brief Maximum height of the foot in mid-air. */ | ||
| double mid_air_foot_height; | ||
|
|
||
| /** @brief Robot control period */ | ||
| double control_period; | ||
|
|
||
| /** @brief Period of the end-effector trajectory update */ | ||
| double planner_loop; | ||
|
|
||
| /** @brief Quadruped DCM reactive stepper*/ | ||
| QuadrupedDcmReactiveStepper quadruped_dcm_reactive_stepper; | ||
|
|
||
| /* fields related to the direction of SOLO */ | ||
|
|
||
| /** @brief desired speed of yaw angle */ | ||
| double yaw_velocity_des; | ||
|
|
||
| /** @brief desired yaw */ | ||
| double yaw_des; | ||
|
|
||
| /** @brief desired base position */ | ||
| Eigen::Vector3d com_des; | ||
|
|
||
| bool open_loop; | ||
|
|
||
| /* Other variables */ | ||
|
|
||
| /** @brief 3D front left foot position */ | ||
| Eigen::Vector3d front_left_foot_position = Eigen::Vector3d::Zero(); | ||
|
|
||
| /** @brief 3D front right foot position */ | ||
| Eigen::Vector3d front_right_foot_position = Eigen::Vector3d::Zero(); | ||
|
|
||
| /** @brief 3D hind left foot position */ | ||
| Eigen::Vector3d hind_left_foot_position = Eigen::Vector3d::Zero(); | ||
|
|
||
| /** @brief 3D hind right foot position */ | ||
| Eigen::Vector3d hind_right_foot_position = Eigen::Vector3d::Zero(); | ||
|
|
||
| /** @brief Desired feet positions in local frame */ | ||
| Eigen::Matrix<double, 12, 1> x_des_local = Eigen::Matrix<double, 12, 1>::Zero(12); | ||
|
|
||
| /** @brief Temporary variable holding the position of a foot*/ | ||
| Eigen::Vector3d foot_des_local = Eigen::Vector3d::Zero(); | ||
|
|
||
| /** @brief The desired pos of a foot */ | ||
| Eigen::Vector3d desired_pos; | ||
|
|
||
| /** @brief The desired velocity of a foot */ | ||
| pinocchio::Motion xd_des; | ||
|
|
||
| /** @brief Impedance proportional gains */ | ||
| Eigen::Matrix<double, 6, 1> kp_array; | ||
|
|
||
| /** @brief Impedance derivative gains */ | ||
| Eigen::Matrix<double, 6, 1> kd_array; | ||
|
|
||
| /** | ||
| * @brief Extracts the yaw from the current position of the robot | ||
| * | ||
| * @param q The base position, orientation, and joint positions of the robot | ||
| * @return double The yaw of the robot | ||
| */ | ||
| static double yaw(Eigen::Matrix<double, 19, 1> &q); | ||
|
|
||
| bool print_once = true; | ||
| }; | ||
|
|
||
| } // namespace reactive_planners |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,25 @@ | ||
| <?xml version="1.0"?> | ||
| <?xml-model href="http://download.ros.org/schema/package_format3.xsd" schematypens="http://www.w3.org/2001/XMLSchema"?> | ||
| <package format="3"> | ||
| <name>reactive_planners</name> | ||
| <version>0.0.0</version> | ||
| <description>Reactive planners for locomotion of legged robots</description> | ||
| <maintainer email="stanley.wu@mail.mcgill.ca">Stanley Wu</maintainer><!-- Maintainer for anything related to ROS --> | ||
| <license>BSD-3-Clause</license> | ||
|
|
||
| <depend>eiquadprog</depend> | ||
| <depend>pinocchio</depend> | ||
| <depend>mpi_cmake_modules</depend> | ||
| <depend>yaml_utils</depend> | ||
| <depend>mim_control</depend> | ||
|
|
||
| <!-- The following tags are recommended by REP-136 --> | ||
| <exec_depend condition="$ROS_VERSION == 1">catkin</exec_depend> | ||
| <exec_depend condition="$ROS_VERSION == 2">ament_cmake</exec_depend> | ||
|
|
||
| <buildtool_depend>cmake</buildtool_depend> | ||
| <export> | ||
| <build_type>cmake</build_type> | ||
| </export> | ||
|
|
||
| </package> | ||
Empty file.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
make sure you list all dependencies if you use such package.xml
make sure you add the build_tool you want use and export it: