How to construct a kinematic chain that is closed in Opensim? (Solved)

Provide easy-to-use, extensible software for modeling, simulating, controlling, and analyzing the neuromusculoskeletal system.
POST REPLY
User avatar
Sietse Achterop
Posts: 72
Joined: Tue Sep 14, 2021 3:01 am

How to construct a kinematic chain that is closed in Opensim? (Solved)

Post by Sietse Achterop » Thu Oct 28, 2021 8:56 am

The use case is a rower in a boat.
The rower is sitting on a movable seat and his single feet is fixed to the stretcher.
The rower can now use his (upper, lower) legs to propel the boat. Both seat (via SliderJoint) and stretcher (via WeldJoint) are connected to the boat so we have a closed kinematic chain.

I tried to solve this as follows, using a PointConstraint:

Code: Select all

hip1Joint = osim.PinJoint("hip1Joint",
                        seat,
                        osim.Vec3(0, seatHeight/2, 0),
                        osim.Vec3(0, 0, 0),
                        upper,
                        osim.Vec3(0, -ulegl/2, 0),
                        osim.Vec3(0, 0, 0))
bbaan.addJoint(hip1Joint)
coord = hip1Joint.updCoordinate()
coord.setName('hip1angle')
coord.setRangeMin(-0.3)
coord.setRangeMax(pi/2)
coord.setDefaultValue(pi/2)

kneeJoint = osim.PinJoint("knee_Joint",
                        upper,
                        osim.Vec3(0, ulegl/2, 0),
                        osim.Vec3(0, 0, 0),
                        lower,
                        osim.Vec3(0, llegl/2, 0),
                        osim.Vec3(0, 0, 0))
bbaan.addJoint(kneeJoint)

coord = kneeJoint.updCoordinate()
coord.setName('kneeangle')
coord.setRangeMin(-pi)
coord.setRangeMax(-0.2)
coord.setDefaultValue(-pi)

legtostretcher = osim.PointConstraint(lower, osim.Vec3(0,llegl/2,0), stretcher, osim.Vec3(0,seatHeight/2,0))

The complete code, bootbaan.py and BootBaan.osim, can be found here https://github.com/SietseAchterop/Rowin ... r/BootBaan.
The default values are such that the rower has his feet completely stretched.
See the image kinematic.png in the url above where you can see the "leg" on the boat in the stretched position.

But if I change a joint you see that the upperleg (the reddish cylinder) is not connected to the seat at all!
I would have hoped that by moving the stretcher the knee would bend.

Am I missing something?
Thanks in advance, Sietse

UPDATE: OOPS, I forgot to addContraint(legtostretcher)
Last edited by Sietse Achterop on Fri Oct 29, 2021 5:52 am, edited 1 time in total.

Tags:

User avatar
Sietse Achterop
Posts: 72
Joined: Tue Sep 14, 2021 3:01 am

Re: How to construct a kinematic chain that is closed in Opensim? (Updated)

Post by Sietse Achterop » Fri Oct 29, 2021 5:51 am

Solved it!
Little by little I get the hang of it :)

The constraint setting had to be

Code: Select all

legtostretcher = osim.PointConstraint(lower, osim.Vec3(0,-llegl/2,0), stretcher, osim.Vec3(0,seatHeight/2,0))
bbaan.addConstraint(legtostretcher)
The was also a minus sign missing in the first position.
Now the knee is bending if I move the seat!
Thanks for your attention.

POST REPLY