MCPcopy Create free account
hub / github.com/dartsim/dart / createHybridBody

Function createHybridBody

tutorials/tutorial_collisions_finished/main.cpp:563–591  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

561}
562
563SkeletonPtr createHybridBody()
564{
565 SkeletonPtr hybrid = Skeleton::create("hybrid");
566
567 // Add a soft body
568 BodyNode* bn = addSoftBody<FreeJoint>(hybrid, "soft sphere", SOFT_ELLIPSOID);
569
570 // Add a rigid body attached by a WeldJoint
571 bn = hybrid->createJointAndBodyNodePair<WeldJoint>(bn).second;
572 bn->setName("rigid box");
573
574 double box_shape_height = default_shape_height;
575 std::shared_ptr<BoxShape> box
576 = std::make_shared<BoxShape>(box_shape_height * Eigen::Vector3d::Ones());
577 bn->createShapeNodeWith<VisualAspect, CollisionAspect, DynamicsAspect>(box);
578
579 Eigen::Isometry3d tf(Eigen::Isometry3d::Identity());
580 tf.translation() = Eigen::Vector3d(box_shape_height / 2.0, 0, 0);
581 bn->getParentJoint()->setTransformFromParentBodyNode(tf);
582
583 Inertia inertia;
584 inertia.setMass(default_shape_density * box->getVolume());
585 inertia.setMoment(box->computeInertia(inertia.getMass()));
586 bn->setInertia(inertia);
587
588 setAllColors(hybrid, dart::Color::Green());
589
590 return hybrid;
591}
592
593SkeletonPtr createGround()
594{

Callers 1

mainFunction · 0.70

Calls 10

getParentJointMethod · 0.80
setMomentMethod · 0.80
setInertiaMethod · 0.80
setAllColorsFunction · 0.70
setNameMethod · 0.45
setMassMethod · 0.45
getVolumeMethod · 0.45
computeInertiaMethod · 0.45
getMassMethod · 0.45

Tested by

no test coverage detected