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

Method addRing

tutorials/tutorial_collisions_finished/main.cpp:268–287  ·  view source on GitHub ↗

Add a ring to the world, and create a BallJoint constraint to ensure that it stays in a ring shape

Source from the content-addressed store, hash-verified

266 /// Add a ring to the world, and create a BallJoint constraint to ensure that
267 /// it stays in a ring shape
268 void addRing(const SkeletonPtr& ring)
269 {
270 setupRing(ring);
271
272 if (!addObject(ring))
273 return;
274
275 // Create a closed loop to turn the chain into a ring
276 BodyNode* head = ring->getBodyNode(0);
277 BodyNode* tail = ring->getBodyNode(ring->getNumBodyNodes() - 1);
278
279 // Compute the offset where the JointConstraint should be located
280 Eigen::Vector3d offset = Eigen::Vector3d(0, 0, default_shape_height / 2.0);
281 offset = tail->getWorldTransform() * offset;
282 auto constraint = std::make_shared<dart::constraint::BallJointConstraint>(
283 head, tail, offset);
284
285 mWorld->getConstraintSolver()->addConstraint(constraint);
286 mJointConstraints.push_back(constraint);
287 }
288
289 /// Remove a Skeleton and get rid of the constraint that was associated with
290 /// it, if one existed

Callers

nothing calls this directly

Calls 5

getConstraintSolverMethod · 0.80
setupRingFunction · 0.70
getBodyNodeMethod · 0.45
getNumBodyNodesMethod · 0.45
addConstraintMethod · 0.45

Tested by

no test coverage detected