Page 1 of 1

Update rra_actuators.xml file

Posted: Sat Mar 27, 2021 2:18 pm
by kernalnet
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

Re: Update rra_actuators.xml file

Posted: Sun Mar 28, 2021 7:59 am
by tkuchida
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".

Re: Update rra_actuators.xml file

Posted: Sun Mar 28, 2021 1:57 pm
by kernalnet
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