Update rra_actuators.xml file

Provide easy-to-use, extensible software for modeling, simulating, controlling, and analyzing the neuromusculoskeletal system.
POST REPLY
User avatar
Mohammadreza Rezaie
Posts: 408
Joined: Fri Nov 24, 2017 12:48 am

Update rra_actuators.xml file

Post by Mohammadreza Rezaie » Sat Mar 27, 2021 2:18 pm

Dear Experts,

I'm trying to update the "point" location of "FX", "FY", and "FZ" point actuators in rra_actuators.xml file. I did:

Code: Select all

actuators = osim.ForceSet('rra_actuators.xml')
FX = actuators.get('FX')
or

Code: Select all

n_actuators = actuators.getSize()
actuators_name = list()
for i in range(n_actuators):
    actuators_name.append(actuators.get(i).getName())
FX = actuators.get(actuators_name.index('FY'))
My problem is that the FX is now an "OpenSim::Force" not an "OpenSim::PointActuator" and I can't get or update "point" location. Is there any solution instead of creating a new actuator file (e.g. createActuatorsFile.m)?

Any help is much appreciated.

Regards,
Mohammadreza

Tags:

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

Re: Update rra_actuators.xml file

Post by Thomas Uchida » Sun Mar 28, 2021 7:59 am

Please refer to the "Common Scripting Commands" page in the documentation (https://simtk-confluence.stanford.edu/d ... g+Commands) and search for the word "downcast".

User avatar
Mohammadreza Rezaie
Posts: 408
Joined: Fri Nov 24, 2017 12:48 am

Re: Update rra_actuators.xml file

Post by Mohammadreza Rezaie » Sun Mar 28, 2021 1:57 pm

Dear Thomas,

Thank you so much for your guidance and I appreciate it. The problem was solved.

Code: Select all

FX = osim.PointActuator().safeDownCast(actuators.get('FX'))
FY = osim.PointActuator().safeDownCast(actuators.get('FY'))
FZ = osim.PointActuator().safeDownCast(actuators.get('FZ'))

FX.set_point(pelvisMassCenter)
FY.set_point(pelvisMassCenter)
FZ.set_point(pelvisMassCenter)

actuators.printToXML('f_new.xml')
Regards,
Mohammadreza

POST REPLY