Provide easy-to-use, extensible software for modeling, simulating, controlling, and analyzing the neuromusculoskeletal system.
-
Maarten Afschrift
- Posts: 7
- Joined: Sat Oct 20, 2012 4:09 am
Post
by Maarten Afschrift » Sun Jan 08, 2017 3:05 am
Hi,
I want to acces the position of a specific body inside the computeControls function of my controller class.
I tried this as follows
Code: Select all
void COM_MuscleController::computeControls(const SimTK::State& s, SimTK::Vector& controls) const
{
OpenSim::Body body_sel = getModel().getBodySet().get("calcn_l"); // get body
getModel().getMultibodySystem().realize(s, Stage::Velocity); // needed ?
Vec3 p1 = Vec3(0, 0, 0); Vec3 p2 = Vec3(0, 0, 0);
getModel().getSimbodyEngine().getPosition(s, body_sel, p1, p2); // compute position (p2)
};
There is something wrong with this code, but I have no idea why is doesn't want to compute the position information.
The code does not run on the line: [getModel().getSimbodyEngine().getPosition(s, body_sel, p1, p2);]. Can anyone help me ?
regards,
Maarten
-
Dimitar Stanev
- Posts: 1096
- Joined: Fri Jan 31, 2014 5:14 am
Post
by Dimitar Stanev » Sun Jan 08, 2017 6:05 am
I think the problem originates in this line:
Code: Select all
OpenSim::Body body_sel = getModel().getBodySet().get("calcn_l");
that should be:
Code: Select all
const OpenSim::Body& body_sel = getModel().getBodySet().get("calcn_l");
Also, you have to realize to position stage and not velocity, since this is a kinematic variable. Also you have to provide the offset of the station of interest define in the local frame of the body. You assumed Vec3(0).
Code: Select all
_model->realizePosition(s);
Vec3 temp;
_model->getSimbodyEngine().getPosition(s, _model->getBodySet().get(body), offset, temp);
-
Maarten Afschrift
- Posts: 7
- Joined: Sat Oct 20, 2012 4:09 am
Post
by Maarten Afschrift » Sun Jan 08, 2017 9:25 am
Hi Dimitar,
Thanks for you response.
Indeed, the problems originated in this line:
Code: Select all
const OpenSim::Body& body_sel = getModel().getBodySet().get("calcn_l");
Thanks,
Maarten