Hello,
I am creating a model, so I have to bodies connected through a PinJoint. When I move the lower body using coordinates it separates from the upper body like if they are independent. Any ideia how to solve this?
Regards,
Marta
Bodies, joints and coordinates
- Dídac Coll
- Posts: 8
- Joined: Tue Jan 31, 2017 6:59 pm
Re: Bodies, joints and coordinates
I suppose that you want to move all the body not only the lower body. If it is the case, then I put the following example in C++.
Code: Select all
// This create all the bodies
OpenSim::Body* link1 = new OpenSim::Body("link1", linkageMass, linkageMassCenter,
linkageMass*linkageInertia);
// Graphical representation
link1->addDisplayGeometry("cylinder.vtp");
// This cylinder.vtp geometry is 1 meter tall, 1 meter diameter. Sclae it
GeometrySet& geometry = link1->updDisplayer()->updGeometrySet();
DisplayGeometry& thinCylinder = geometry[0];
thinCylinder.setScaleFactors(linkageDimensions);
thinCylinder.setTransform(Transform(Vec3(0.0, linkageLength/2.0, 0.0)));
link1->addDisplayGeometry("sphere.vtp");
// This sphere.vtp is 1 meter in diameter. Scale it.
geometry[1].setScaleFactors(Vec3(0.1));
// Create a second linkage body
OpenSim::Body* link2 = new OpenSim::Body(*link1);
link2->setName("link2");
OpenSim::Body* link3 = new OpenSim::Body(*link1);
link3->setName("link3");
// Now we use the pinjoint class to link them.
// Create 1 degree-of-freedom pin joints between the bodies to create a kinematic chain
Vec3 orientationInGround(0), locationInGround(0), locationInParent(0.0, linkageLength, 0.0),
orientationInChild(0), locationInChild(0);
PinJoint *ankle = new PinJoint("ankle", ground, locationInGround, orientationInGround, *link1,
locationInChild, orientationInChild);
PinJoint *knee = new PinJoint("knee", *link1, locationInParent, orientationInChild, *link2,
locationInChild, orientationInChild);
PinJoint *hip1 = new PinJoint("hip1", *link2, locationInParent, orientationInChild, *link3,
locationInChild, orientationInChild);
// In this case we have three joints, then if we want to move all the body,
// we have to move the first one because it is attached to the ground
ankle->setLocationInParent(Vec3(0,1,0));
// Add all the bodies to the model
osimModel.addBody(link1);
osimModel.addBody(link2);
osimModel.addBody(link3);
- Thomas Uchida
- Posts: 1793
- Joined: Wed May 16, 2012 11:40 am
Re: Bodies, joints and coordinates
The "From the Ground Up: Building a Passive Dynamic Walker Model" example may be helpful: http://simtk-confluence.stanford.edu:80 ... lker+Model.