Skip to content

Commit b3e583a

Browse files
author
earlaud
committed
Add 6D foot in model handler
1 parent 425472b commit b3e583a

File tree

14 files changed

+166
-45
lines changed

14 files changed

+166
-45
lines changed

benchmark/go2.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,10 +40,10 @@ int main()
4040
ref_FR_foot.translation() = Eigen::Vector3d(0.17, -0.15, 0.0);
4141
ref_RL_foot.translation() = Eigen::Vector3d(-0.24, 0.15, 0.0);
4242
ref_RR_foot.translation() = Eigen::Vector3d(-0.24, -0.15, 0.0);
43-
model_handler.addFoot("FL_foot", base_joint_name);
44-
model_handler.addFoot("FR_foot", base_joint_name);
45-
model_handler.addFoot("RL_foot", base_joint_name);
46-
model_handler.addFoot("RR_foot", base_joint_name);
43+
model_handler.addPointFoot("FL_foot", base_joint_name);
44+
model_handler.addPointFoot("FR_foot", base_joint_name);
45+
model_handler.addPointFoot("RL_foot", base_joint_name);
46+
model_handler.addPointFoot("RR_foot", base_joint_name);
4747
model_handler.setFootReferencePlacement("FL_foot", ref_FL_foot);
4848
model_handler.setFootReferencePlacement("FR_foot", ref_FR_foot);
4949
model_handler.setFootReferencePlacement("RL_foot", ref_RL_foot);

benchmark/talos.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,8 +72,8 @@ int main()
7272
RobotModelHandler model_handler(model, "half_sitting", base_joint);
7373

7474
// Add feet
75-
model_handler.addFoot("left_sole_link", base_joint);
76-
model_handler.addFoot("right_sole_link", base_joint);
75+
model_handler.add6DFoot("left_sole_link", base_joint);
76+
model_handler.add6DFoot("right_sole_link", base_joint);
7777

7878
model_handler.setFootReferencePlacement(
7979
"left_sole_link", pinocchio::SE3(Eigen::Quaternion(0., 0., 0., 1.), Eigen::Vector3d(0., 0.1, 0.)));

bindings/expose-robot-handler.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,8 @@ namespace simple_mpc
2323
bp::class_<RobotModelHandler>(
2424
"RobotModelHandler", bp::init<const pinocchio::Model &, const std::string &, const std::string &>(
2525
bp::args("self", "model", "reference_configuration_name", "base_frame_name")))
26-
.def("addFoot", &RobotModelHandler::addFoot)
26+
.def("addPointFoot", &RobotModelHandler::addPointFoot)
27+
.def("add6DFoot", &RobotModelHandler::add6DFoot)
2728
.def("setFootReferencePlacement", &RobotModelHandler::setFootReferencePlacement)
2829
.def("difference", &RobotModelHandler::difference)
2930
.def("getBaseFrameName", &RobotModelHandler::getBaseFrameName)

examples/go2_fulldynamics.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,10 @@
2323
# Create Model and Data handler
2424
model_handler = RobotModelHandler(robot_wrapper.model, "standing", base_joint_name)
2525

26-
model_handler.addFoot("FL_foot", base_joint_name)
27-
model_handler.addFoot("FR_foot", base_joint_name)
28-
model_handler.addFoot("RL_foot", base_joint_name)
29-
model_handler.addFoot("RR_foot", base_joint_name)
26+
model_handler.addPointFoot("FL_foot", base_joint_name)
27+
model_handler.addPointFoot("FR_foot", base_joint_name)
28+
model_handler.addPointFoot("RL_foot", base_joint_name)
29+
model_handler.addPointFoot("RR_foot", base_joint_name)
3030
model_handler.setFootReferencePlacement("FL_foot", pin.XYZQUATToSE3(np.array([ 0.17, 0.15, 0.0, 0,0,0,1])))
3131
model_handler.setFootReferencePlacement("FR_foot", pin.XYZQUATToSE3(np.array([ 0.17,-0.15, 0.0, 0,0,0,1])))
3232
model_handler.setFootReferencePlacement("RL_foot", pin.XYZQUATToSE3(np.array([-0.24, 0.15, 0.0, 0,0,0,1])))

examples/go2_kinodynamics.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,10 @@
1414

1515
# Create Model and Data handler
1616
model_handler = RobotModelHandler(robot_wrapper.model, "standing", base_joint_name)
17-
model_handler.addFoot("FL_foot", base_joint_name)
18-
model_handler.addFoot("FR_foot", base_joint_name)
19-
model_handler.addFoot("RL_foot", base_joint_name)
20-
model_handler.addFoot("RR_foot", base_joint_name)
17+
model_handler.addPointFoot("FL_foot", base_joint_name)
18+
model_handler.addPointFoot("FR_foot", base_joint_name)
19+
model_handler.addPointFoot("RL_foot", base_joint_name)
20+
model_handler.addPointFoot("RR_foot", base_joint_name)
2121
model_handler.setFootReferencePlacement("FL_foot", pin.XYZQUATToSE3(np.array([ 0.17, 0.15, 0.0, 0,0,0,1])))
2222
model_handler.setFootReferencePlacement("FR_foot", pin.XYZQUATToSE3(np.array([ 0.17,-0.15, 0.0, 0,0,0,1])))
2323
model_handler.setFootReferencePlacement("RL_foot", pin.XYZQUATToSE3(np.array([-0.24, 0.15, 0.0, 0,0,0,1])))

examples/talos_centroidal.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@
1515

1616
# Create Model and Data handler
1717
model_handler = RobotModelHandler(rmodel, reference_configuration_name, base_joint_name)
18-
model_handler.addFoot("left_sole_link", base_joint_name)
19-
model_handler.addFoot("right_sole_link", base_joint_name)
18+
model_handler.add6DFoot("left_sole_link", base_joint_name)
19+
model_handler.add6DFoot("right_sole_link", base_joint_name)
2020
model_handler.setFootReferencePlacement("left_sole_link", pin.XYZQUATToSE3(np.array([ 0.0, 0.1, 0.0, 0,0,0,1])))
2121
model_handler.setFootReferencePlacement("right_sole_link", pin.XYZQUATToSE3(np.array([ 0.0,-0.1, 0.0, 0,0,0,1])))
2222

examples/talos_fulldynamics.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@
2222

2323
# Create Model and Data handler
2424
model_handler = RobotModelHandler(rmodel, reference_configuration_name, base_joint_name)
25-
model_handler.addFoot("left_sole_link", base_joint_name)
26-
model_handler.addFoot("right_sole_link", base_joint_name)
25+
model_handler.add6DFoot("left_sole_link", base_joint_name)
26+
model_handler.add6DFoot("right_sole_link", base_joint_name)
2727
model_handler.setFootReferencePlacement("left_sole_link", pin.XYZQUATToSE3(np.array([ 0.0, 0.1, 0.0, 0,0,0,1])))
2828
model_handler.setFootReferencePlacement("right_sole_link", pin.XYZQUATToSE3(np.array([ 0.0,-0.1, 0.0, 0,0,0,1])))
2929

examples/talos_kinodynamics.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@
1515

1616
# Create Model and Data handler
1717
model_handler = RobotModelHandler(rmodel, reference_configuration_name, base_joint_name)
18-
model_handler.addFoot("left_sole_link", base_joint_name)
19-
model_handler.addFoot("right_sole_link", base_joint_name)
18+
model_handler.add6DFoot("left_sole_link", base_joint_name)
19+
model_handler.add6DFoot("right_sole_link", base_joint_name)
2020
model_handler.setFootReferencePlacement("left_sole_link", pin.XYZQUATToSE3(np.array([ 0.0, 0.1, 0.0, 0,0,0,1])))
2121
model_handler.setFootReferencePlacement("right_sole_link", pin.XYZQUATToSE3(np.array([ 0.0,-0.1, 0.0, 0,0,0,1])))
2222
data_handler = RobotDataHandler(model_handler)

include/simple-mpc/inverse-dynamics.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ namespace simple_mpc
8383
tsid::InverseDynamicsFormulationAccForce formulation_;
8484

8585
std::vector<bool> active_tsid_contacts_;
86-
std::vector<tsid::contacts::ContactPoint> tsid_contacts;
86+
std::vector<std::shared_ptr<tsid::contacts::ContactBase>> tsid_contacts;
8787
std::shared_ptr<tsid::tasks::TaskJointPosture> postureTask_;
8888
std::shared_ptr<tsid::tasks::TaskSE3Equality> baseTask_;
8989
std::shared_ptr<tsid::tasks::TaskJointPosVelAccBounds> boundsTask_;

include/simple-mpc/robot-handler.hpp

Lines changed: 58 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,13 @@ namespace simple_mpc
2727
*/
2828
struct RobotModelHandler
2929
{
30+
enum FootType
31+
{
32+
POINT,
33+
SIX_D
34+
};
35+
typedef Eigen::Matrix<double, 4, 3> ContactPointsMatrix;
36+
3037
private:
3138
/**
3239
* @brief Model to be used by ocp
@@ -49,6 +56,16 @@ namespace simple_mpc
4956
*/
5057
std::vector<std::string> feet_names_;
5158

59+
/**
60+
* @brief Is the foot a contact point or a 6D contact
61+
*/
62+
std::vector<FootType> feet_types_;
63+
64+
/**
65+
* @brief List of contact points for each 6D feets
66+
*/
67+
std::map<size_t, Eigen::Matrix<double, 4, 3>> feet_contact_points_;
68+
5269
/**
5370
* @brief Ids of the frames to be in contact with the environment
5471
*/
@@ -77,15 +94,34 @@ namespace simple_mpc
7794
const Model & model, const std::string & reference_configuration_name, const std::string & base_frame_name);
7895

7996
/**
80-
* @brief
97+
* @brief Create a point foot, that can apply 3D force to the ground. (in comparison to 6D foot)
8198
*
8299
* @param foot_name Frame name that will be used a a foot
83100
* @param reference_frame_name Frame to which the foot reference
84101
* frame will be attached.
85102
*
103+
* @return the foot number
104+
*
86105
* @note The foot placement will be set by default using the reference configuration of the RobotModelHandler
87106
*/
88-
FrameIndex addFoot(const std::string & foot_name, const std::string & reference_frame_name);
107+
size_t addPointFoot(const std::string & foot_name, const std::string & reference_frame_name);
108+
109+
/**
110+
* @brief Create a point foot, that can apply 6D wrench to the ground. (in comparison to point foot)
111+
*
112+
* @param foot_name Frame name that will be used a a foot
113+
* @param reference_frame_name Frame to which the foot reference
114+
* frame will be attached.
115+
* @param contactPoints 3D positions (in the local frame) of the foot 4 extremum point
116+
*
117+
* @return the foot number
118+
*
119+
* @note The foot placement will be set by default using the reference configuration of the RobotModelHandler
120+
*/
121+
size_t add6DFoot(
122+
const std::string & foot_name,
123+
const std::string & reference_frame_name,
124+
const ContactPointsMatrix & contactPoints);
89125

90126
/**
91127
* @brief Update the reference placement of the foot wrt to the frame it is attached to
@@ -115,6 +151,16 @@ namespace simple_mpc
115151
return size_t(std::find(feet_names_.begin(), feet_names_.end(), foot_name) - feet_names_.begin());
116152
}
117153

154+
FootType getFootType(size_t i) const
155+
{
156+
return feet_types_[i];
157+
}
158+
159+
const ContactPointsMatrix & get6DFootContactPoints(size_t i) const
160+
{
161+
return feet_contact_points_.at(i);
162+
}
163+
118164
const std::vector<FrameIndex> & getFeetIds() const
119165
{
120166
return feet_ids_;
@@ -159,6 +205,16 @@ namespace simple_mpc
159205
{
160206
return model_;
161207
}
208+
209+
private:
210+
/**
211+
* @brief Common operation to perform to add a foot (of any type) : Create the reference frame and set it default
212+
* pose using the default pose of the robot
213+
*
214+
* @param foot_name Name of the frame foot
215+
* @param reference_frame_name Name of the frame where the reference frame of the foot will be attached
216+
*/
217+
void addFootFrames(const std::string & foot_name, const std::string & reference_frame_name);
162218
};
163219

164220
class RobotDataHandler

0 commit comments

Comments
 (0)