"live" simulation,External controller with path actuator

Provide easy-to-use, extensible software for modeling, simulating, controlling, and analyzing the neuromusculoskeletal system.
POST REPLY
User avatar
Oskar Åsbrink
Posts: 5
Joined: Fri Mar 26, 2021 12:29 am

"live" simulation,External controller with path actuator

Post by Oskar Åsbrink » Thu May 06, 2021 2:00 pm

I added a pathActuator to Arm26 model. writing a python script, Im just trying to set a force for the muscle to contract, updating and sending pos and vel for every iteration. Output handled later.
something like this is what I had in mind (the loop especially):

Code: Select all

arm = osim.Model('Arm26.osim')
arm.setUseVisualizer(True)
body1 = arm.getBodySet().get('r_humerus')
point1 = osim.Vec3(0.007,-0.174,-0.004)
body2 = arm.getBodySet().get('r_ulna_radius_hand')
point2 = osim.Vec3(-0.003,-0.024,0.001)

pathAct = osim.PathActuator()
pathAct.setName('pathAct')
pathAct.setOptimalForce(100.0)
from numpy import inf
pathAct.setMinControl(-inf)
pathAct.setMaxControl(inf)
pathAct.addNewPathPoint('pathAct_point1',body1,point1)
pathAct.addNewPathPoint('pathAct_point2',body2,point2)
arm.addForce(pathAct)
arm.finalizeConnections()

state = arm.initSystem()
shoulder = arm.get_JointSet().get('r_shoulder')
shoulder.getCoordinate().setLocked(state, True)

state.setTime(0)
manager = osim.Manager(arm)
manager.initialize(state)

stepsize = 0.01
asd = pathAct.computeActuation(state)
for i in range(500):
        #set force, how?(with input from external controller)
        manager.integrate(stepsize*(i+1))
        #send output(veloc and pos)
EDIT: so the iteration works fine when I changed the loop a bit, I just need to apply a constant force every iteration. How do I apply a constant force to the pathActuator without a controller?
The pathActuator does not seem to do anything yet. not sure how to activate it every iteration. computeActuation gives an error and computeForce I can't seem to grasp.
are there any good examples?
cheers

Tags:

POST REPLY