Skip to content

Commit 0738ad8

Browse files
committed
Add more data in the C++ example
1 parent 779fffa commit 0738ad8

File tree

1 file changed

+66
-0
lines changed

1 file changed

+66
-0
lines changed

src/NewRobotModule.in.cpp

+66
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22

33
#include <RBDyn/parsers/urdf.h>
44

5+
#include <boost/filesystem.hpp>
6+
namespace bfs = boost::filesystem;
7+
58
namespace
69
{
710

@@ -19,6 +22,69 @@ NewRobotModule::NewRobotModule() : mc_rbdyn::RobotModule(JVRC_DESCRIPTION_PATH,
1922
bool fixed = false;
2023
// Makes all the basic initialization that can be done from an URDF file
2124
init(rbd::parsers::from_urdf_file(urdf_path, fixed));
25+
26+
// Automatically load the convex hulls associated to each body
27+
std::string convexPath = path + "/convex/" + name + "/";
28+
bfs::path p(convexPath);
29+
if(bfs::exists(p) && bfs::is_directory(p))
30+
{
31+
std::vector<bfs::path> files;
32+
std::copy(bfs::directory_iterator(p), bfs::directory_iterator(), std::back_inserter(files));
33+
for(const bfs::path & file : files)
34+
{
35+
size_t off = file.filename().string().rfind("-ch.txt");
36+
if(off != std::string::npos)
37+
{
38+
std::string name = file.filename().string();
39+
name.replace(off, 7, "");
40+
_convexHull[name] = std::pair<std::string, std::string>(name, file.string());
41+
}
42+
}
43+
}
44+
45+
// Define some force sensors
46+
_forceSensors.push_back(mc_rbdyn::ForceSensor("RightFootForceSensor", "R_ANKLE_P_S", sva::PTransformd::Identity()));
47+
_forceSensors.push_back(mc_rbdyn::ForceSensor("LeftFootForceSensor", "L_ANKLE_P_S", sva::PTransformd::Identity()));
48+
_forceSensors.push_back(mc_rbdyn::ForceSensor("RightHandForceSensor", "R_WRIST_Y_S", sva::PTransformd::Identity()));
49+
_forceSensors.push_back(mc_rbdyn::ForceSensor("LeftHandForceSensor", "L_WRIST_Y_S", sva::PTransformd::Identity()));
50+
51+
// Define body sensors
52+
_bodySensors.emplace_back("Accelerometer", "PELVIS_S", sva::PTransformd(Eigen::Vector3d(-0.0325, 0, 0.1095)));
53+
_bodySensors.emplace_back("FloatingBase", "PELVIS_S", sva::PTransformd::Identity());
54+
55+
// Define a minimal set of self-collisions
56+
_minimalSelfCollisions = {
57+
{"WAIST_R_S", "L_SHOULDER_Y_S", 0.02, 0.001, 0.}, {"WAIST_R_S", "R_SHOULDER_Y_S", 0.02, 0.001, 0.},
58+
{"PELVIS_S", "R_ELBOW_P_S", 0.05, 0.001, 0.}, {"PELVIS_S", "L_ELBOW_P_S", 0.05, 0.001, 0.},
59+
{"R_WRIST_Y_S", "R_HIP_Y_S", 0.05, 0.025, 0.}, {"L_WRIST_Y_S", "L_HIP_Y_S", 0.05, 0.025, 0.}};
60+
_commonSelfCollisions = _minimalSelfCollisions;
61+
62+
// Define simple grippers
63+
_grippers = {{"l_gripper", {"L_UTHUMB"}, true}, {"r_gripper", {"R_UTHUMB"}, false}};
64+
65+
// Default configuration of the floating base
66+
_default_attitude = {{1., 0., 0., 0., 0., 0., 0.8275}};
67+
68+
// Default joint configuration, if a joint is omitted the configuration is 0 or the middle point of the limit range if
69+
// 0 is not a valid configuration
70+
_stance["L_ANKLE_P"] = {-0.33};
71+
_stance["L_ANKLE_R"] = {-0.02};
72+
_stance["L_ELBOW_P"] = {-0.52};
73+
_stance["L_HIP_P"] = {-0.38};
74+
_stance["L_HIP_R"] = {0.02};
75+
_stance["L_KNEE"] = {0.72};
76+
_stance["L_SHOULDER_P"] = {-0.052};
77+
_stance["L_SHOULDER_R"] = {0.17};
78+
_stance["L_SHOULDER_Y"] = {0.0};
79+
_stance["R_ANKLE_P"] = {-0.33};
80+
_stance["R_ANKLE_R"] = {-0.01};
81+
_stance["R_ELBOW_P"] = {-0.52};
82+
_stance["R_HIP_P"] = {-0.38};
83+
_stance["R_HIP_R"] = {-0.01};
84+
_stance["R_KNEE"] = {0.72};
85+
_stance["R_SHOULDER_P"] = {-0.052};
86+
_stance["R_SHOULDER_R"] = {-0.17};
87+
_stance["WAIST_P"] = {0.13};
2288
}
2389

2490
} // namespace mc_robots

0 commit comments

Comments
 (0)