How to use the ikSolver.computeCurrentMarkerLocation function

Provide easy-to-use, extensible software for modeling, simulating, controlling, and analyzing the neuromusculoskeletal system.
POST REPLY
User avatar
Hanzhe Li
Posts: 4
Joined: Sat Aug 03, 2024 2:12 am

How to use the ikSolver.computeCurrentMarkerLocation function

Post by Hanzhe Li » Mon Dec 09, 2024 12:44 am

Hello everyone,

I am trying to use openSim4.2 to calculate the position coordinates of knee joint in real time. This work is based on the openSim demo and is carried out in the Raspberry Pi 4B with Ubuntu 18.
But there is a problem here that when using the ikSolver.computeCurrentMarkerLocation function, it displays: segmentation fault (core dumped) in openSim4.2 and unused marker name knee in openSim 4.5. However, I set the knee maker in the model.

Therefore, I need the help to solve this problem.

Thank a lot.

Hanzhe Li

Tags:

User avatar
Ayman Habib
Posts: 2252
Joined: Fri Apr 01, 2005 12:24 pm

Re: How to use the ikSolver.computeCurrentMarkerLocation function

Post by Ayman Habib » Mon Dec 09, 2024 10:35 am

Hello Hanzhe Li,

This looks very similar to an issue we fixed lately that was caused by calling the method on markers that are not in the intersection of model markers and those in the trc file. Code innocently assumed names passed in to be valid. Now we throw exceptions but earlier versions would have crashed. So, please make sure the name you're passing is in the intersection of the two sets (model markers, data-to-be-tracked).

Hope this helps,
-Ayman

User avatar
Hanzhe Li
Posts: 4
Joined: Sat Aug 03, 2024 2:12 am

Re: How to use the ikSolver.computeCurrentMarkerLocation function

Post by Hanzhe Li » Mon Dec 09, 2024 6:31 pm

Dear Ayman,

Thank you very much for your reply, but I still don't know how to solve this problem.
Could you provide some correct examples, demos, or instructional notes to help me set up the marker in model and its str files?

Looking forward to your reply.

Thank you very much.
Hanzhe Li

User avatar
Ayman Habib
Posts: 2252
Joined: Fri Apr 01, 2005 12:24 pm

Re: How to use the ikSolver.computeCurrentMarkerLocation function

Post by Ayman Habib » Tue Dec 10, 2024 1:30 pm

Hello,

A reasonable approach would be to get the number of markers in use from the solver

Code: Select all

solver.getNumMarkersInUse()
Then cycle through this list in turn and print the corresponding names using

Code: Select all

solver.getMarkerNameForIndex(index)
The challenge that the solver is dealing with is that there're multiple lists of potential marker names in Model, data-files and potentially in marker-weight-set. The solver aggregates all these into one internal list that it solves and the above calls will allow you to know what markers made it to the list and in what order if that matters.

Hope this helps,
-Ayman

User avatar
Hanzhe Li
Posts: 4
Joined: Sat Aug 03, 2024 2:12 am

Re: How to use the ikSolver.computeCurrentMarkerLocation function

Post by Hanzhe Li » Tue Dec 10, 2024 6:59 pm

Dear Ayman,

Thank you very much for your reply. I had tried those functions ( ikSolver.getNumMarkersInUse() / computeCurrentMarkerLocation / computeCurrentMarkerLocations /getMarkerNameForIndex) in ikSolver, so the result show that segmentation fault (core dumped) in openSim4.2 with Ubuntu18, and program stucked in openSim4.5 with windows.
So, i used the model.getMarkerSet() function to check the markers in the model, that can get the markers' name.
Then, i used the following code to set the marker to ikSolver:

marker_file = '****.xml'
markers_ref = osim.MarkersReference()
markers_ref.set_marker_file(marker_file)
ikSolver = osim.InverseKinematicsSolver(model, markers_ref, oRefs, coordinateReferences, constraint_var)

Unfortunately, the same results were observed. Besides, i tested this method in leg39 model, it was the same result.
So I still need your further help and guidance.

Looking forward to your reply.

Best wish.
Hanzhe Li

POST REPLY