Bodies, joints and coordinates

Provide easy-to-use, extensible software for modeling, simulating, controlling, and analyzing the neuromusculoskeletal system.
POST REPLY
User avatar
Marta Carrilho
Posts: 13
Joined: Mon Oct 10, 2016 1:13 am

Bodies, joints and coordinates

Post by Marta Carrilho » Wed Mar 29, 2017 7:26 am

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

User avatar
Dídac Coll
Posts: 8
Joined: Tue Jan 31, 2017 6:59 pm

Re: Bodies, joints and coordinates

Post by Dídac Coll » Wed Mar 29, 2017 7:56 am

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);

        

        

User avatar
Thomas Uchida
Posts: 1792
Joined: Wed May 16, 2012 11:40 am

Re: Bodies, joints and coordinates

Post by Thomas Uchida » Fri Mar 31, 2017 7:54 pm

The "From the Ground Up: Building a Passive Dynamic Walker Model" example may be helpful: http://simtk-confluence.stanford.edu:80 ... lker+Model.

POST REPLY