model_generator.cc
Go to the documentation of this file.
2 #include "rdl_dynamics/Model.h"
3 
4 using namespace RobotDynamics;
5 using namespace RobotDynamics::Math;
6 
7 void generate_planar_tree_recursive(ModelPtr model, unsigned int parent_body_id, int depth, double length)
8 {
9  if(depth == 0)
10  {
11  return;
12  }
13 
14  // create left child
16  Body body(length, Vector3d(0., -0.25 * length, 0.), Vector3d(length, length, length));
17 
18  Vector3d displacement(-0.5 * length, -0.25 * length, 0.);
19  unsigned int child_left = model->addBody(parent_body_id, Xtrans(displacement), joint_rot_z, body);
20 
21  generate_planar_tree_recursive(model, child_left, depth - 1, length * 0.4);
22 
23  displacement.set(0.5 * length, -0.25 * length, 0.);
24  unsigned int child_right = model->addBody(parent_body_id, Xtrans(displacement), joint_rot_z, body);
25 
26  generate_planar_tree_recursive(model, child_right, depth - 1, length * 0.4);
27 }
28 
29 void generate_planar_tree(ModelPtr model, int depth)
30 {
31  // we first add a single body that is hanging straight down from
32  // (0, 0, 0). After that we generate the tree recursively such that each
33  // call adds two children.
34  //
35  double length = 1.;
36 
38  Body body(length, Vector3d(0., -0.25 * length, 0.), Vector3d(length, length, length));
39 
40  unsigned int base_child = model->addBody(0, Xtrans(Vector3d(0., 0., 0.)), joint_rot_z, body);
41 
42  generate_planar_tree_recursive(model, base_child, depth, length * 0.4);
43 }
44 
Joint joint_rot_z(SpatialVector(0., 0., 1., 0., 0., 0.))
void generate_planar_tree(ModelPtr model, int depth)
std::shared_ptr< Model > ModelPtr
SpatialTransform Xtrans(const Vector3d &r)
void generate_planar_tree_recursive(ModelPtr model, unsigned int parent_body_id, int depth, double length)
void set(const Eigen::Vector3d &v)


rdl_benchmark
Author(s):
autogenerated on Tue Apr 20 2021 02:25:39