Parsing a SkeletonPtr and then fixing it to the world

I have a URDF file for an obstacle and I am parsing it as a SkeletonPtr. Once I parsed it, I set the position and orientation and then add it to the world. However, it is currently in the air and therefore it falls down with simulation. I want it to be fixedly to the world, where I am placing it even if its in the air.

I tried the following steps:

  1. Create a skeletonPtr class, which does the following:

a) Parse the SkeletonPtr.
b) Set the Position and orientation.
c) Create it as bodynodeptr as follow
dart::dynamics::BodyNodePtr body
= obstacle->createJointAndBodyNodePair dart::dynamics::WeldJoint (nullptr).second;
d) Return the skeletonPtr

 2) Add it to the world.

However, the obstacle is not attached to the world and it still falls down. Any help will be appreciated.

Thanks

p.s I see that forum is not showing greater than and less than sign with createJointBodyNodePair. dart::dynamics::WeldJoint is in the greater and less than sign

Hello @mamurtaza,

If the only object you are placing in your world is the robot, then the robot, acting under the influence of gravity, will immediately start falling when placed in the world.

You can two things to prevent this:

  1. Change the default gravity of the world to be 0 or,
  2. Add a “floor” SkeletonPtr which will exert a normal force on the robot and prevent it from falling.

@mamurtaza You have the right idea with using a weld joint. The problem with the way you are doing it is that you are creating a brand new body node that’s attached to the world, but that new body node is not being attached to any of the other body nodes in your skeleton. The new body node (which will have no visual or collision geometry) will remain fixed in place attached to the world while all the body nodes that were parsed from the URDF will simply fall under gravity.

What you should do instead is:

auto* root = obstacle->getRootBodyNode();
dart::dynamics::WeldJoint::Properties properties;
properties.mT_ParentBodyToJoint = root->getTransform();
root->moveTo<dart::dynamics::WeldJoint>(nullptr, properties);

This will get the root body node of the obstacle’s skeleton and attach it to the world using a weld joint. Further, it should make sure that the location of the obstacle is wherever it originally was.

Disclaimer: I have not actually tested the above code, so it might contain some errors.