| 306 | } |
| 307 | |
| 308 | BodyNode* addBody( |
| 309 | const SkeletonPtr& pendulum, BodyNode* parent, const std::string& name) |
| 310 | { |
| 311 | // Set up the properties for the Joint |
| 312 | RevoluteJoint::Properties properties; |
| 313 | properties.mName = name + "_joint"; |
| 314 | properties.mAxis = Eigen::Vector3d::UnitY(); |
| 315 | properties.mT_ParentBodyToJoint.translation() |
| 316 | = Eigen::Vector3d(0, 0, default_height); |
| 317 | properties.mRestPositions[0] = default_rest_position; |
| 318 | properties.mSpringStiffnesses[0] = default_stiffness; |
| 319 | properties.mDampingCoefficients[0] = default_damping; |
| 320 | |
| 321 | // Create a new BodyNode, attached to its parent by a RevoluteJoint |
| 322 | BodyNodePtr bn = pendulum |
| 323 | ->createJointAndBodyNodePair<RevoluteJoint>( |
| 324 | parent, properties, BodyNode::AspectProperties(name)) |
| 325 | .second; |
| 326 | |
| 327 | // Make a shape for the Joint |
| 328 | const double R = default_width / 2.0; |
| 329 | const double h = default_depth; |
| 330 | std::shared_ptr<CylinderShape> cyl(new CylinderShape(R, h)); |
| 331 | |
| 332 | // Line up the cylinder with the Joint axis |
| 333 | Eigen::Isometry3d tf(Eigen::Isometry3d::Identity()); |
| 334 | tf.linear() = dart::math::eulerXYZToMatrix( |
| 335 | Eigen::Vector3d(dart::math::toRadian(90.0), 0, 0)); |
| 336 | |
| 337 | auto shapeNode = bn->createShapeNodeWith<VisualAspect>(cyl); |
| 338 | shapeNode->getVisualAspect()->setColor(dart::Color::Blue()); |
| 339 | shapeNode->setRelativeTransform(tf); |
| 340 | |
| 341 | // Set the geometry of the Body |
| 342 | setGeometry(bn); |
| 343 | |
| 344 | return bn; |
| 345 | } |
| 346 | |
| 347 | int main(int argc, char* argv[]) |
| 348 | { |
no test coverage detected