Input to coordinate actuator

Provide easy-to-use, extensible software for modeling, simulating, controlling, and analyzing the neuromusculoskeletal system.
POST REPLY
User avatar
Nithin Kurup
Posts: 149
Joined: Sat Jan 18, 2014 5:13 am

Input to coordinate actuator

Post by Nithin Kurup » Tue Nov 04, 2014 2:11 pm

Hi,

I am trying to create a prescribed controller, for a coordinate actuator ( range 0- 360 deg)so that it will produce a constant angular velocity of 50 rpm (5.2359 rad/s ) to get a 30 W power output(target) during the simulation.

Now, I am having trouble in defining the torque input and also the optimal force and power.

I know that I have to produce an avg power of 30 w, so using the the equation:
power (W) = torque (Nm)* angular velocity (rad/s)

I get a torque of 5.7296 Nm . Now my doubt is how to find the corresponding control value which will give this torque or is this value the control input or is the control value in range of -1 to 1 and also how to find the corresponding optimal force which will give the desired rpm.


I tried to perform a intial simulation for a 1 sec duration, with Optimal force (10 N), defualt coordinate speed (1 rad/s). control i/p signal ( 1) and after simulation I am getting around 100 cycles . Dont know if its correct.

Looking forward to any reply,

nithin.

User avatar
Ajay Seth
Posts: 136
Joined: Thu Mar 15, 2007 10:39 am

Re: Input to coordinate actuator

Post by Ajay Seth » Tue Nov 04, 2014 4:10 pm

It would be easier to prescribe the motion of the coordinate. Inside the Coordinate block that you want to prescribe, add:

Code: Select all

<!--If specified, the coordinate can be prescribed by a function of time. It can be any OpenSim Function with valid second order derivatives.-->
 <prescribed_function>
    <LinearFunction>
       <!-- Slope and intercept of the linear function. -->
       <coefficients> 1 0</coefficients>
    </LinearFunction>
 </prescribed_function>
 <!--Flag indicating whether or not the values of the coordinates should be prescribed according to the function above. It is ignored if the no prescribed function is specified.-->
 <prescribed> true </prescribed>
You would change the slope of the linear function to be the constant speed that you require.

User avatar
Nithin Kurup
Posts: 149
Joined: Sat Jan 18, 2014 5:13 am

Re: Input to coordinate actuator

Post by Nithin Kurup » Tue Nov 04, 2014 4:32 pm

Dear Ajay,

Thank you so much for your reply. So, I just need to insert this into the coordinate section to get the corresponging speed (slope), and in the coding section I dont need to insert any extra prescibed controllers
to move the coordinate.
1. Do I need to put my <default speed >= my desired speed or put it as 0.
2. Also, in the coordinate actuator part in xml file, there is optimal force and control values. So I should just leave the control values from 0-1 clockwise rotation and Optimal force? default is 1000 N I guess. Does it have any influence?

Sorry got a bit confused, as I I need visualise the rotation of my crank:
I wanted to run forward simulation (plan to perform Dynamic Optimisation), I have 2 actuator: muscles and 1 coordinate. I have already made my muscles into controllers, and the last actuator is the coordinate. So, I want to know if I perform the above step in xml file, I dont need to make a separate prescribed function for my coordinate as shown below and can leave it out of my simulation by only using muscle actuators.

If, need to add a prescribed controller for the coordinate actuator , but then I wont be able to specify the control inputs( as I dont know what torque is produced for the corresponding control value).

So is there any method to check if I am getting the corresponding power (30w) or get the torque input ? for validation.

If i want to run a forward simulation, then is it possible -sample eg:

Code: Select all

double t[] = {initialTime, finalTime };
double tork[] = {1 , 1};
PrescribedController *Control = new PrescribedController();
Control->prescribeControlForActuator(osimModel.getActuators().get(0).getName(), new PiecewiseConstantFunction (2,t,tork));
Thanking you so much, sorry again for troubling you.

Nithin

User avatar
Ajay Seth
Posts: 136
Joined: Thu Mar 15, 2007 10:39 am

Re: Input to coordinate actuator

Post by Ajay Seth » Tue Nov 04, 2014 5:30 pm

1. Good question. The default coordinate value and its speed are overruled by the prescribed motion when the constraint is satisfied (when the model is assembled e.g. at initSystem()).
2. What is the purpose of the CoordinateActuator if the motion is prescribed? The prescribed motion will compensate for any resistance torque. You do not require the coordinate actuator to run a forward simulation.

If you want to know what the prescribed motion is doing, workwise, you can ask the Joint (i assume it is a PinJoint for the crank) to calculate its power. This is the internal power used to satisfy the constraint, it is not power due to actuators about the joint. The call is joint.calcPower(const SimTK::State &s). There is also a JointInternalPowerProbe that will integrate the power to provide you with the internal joint work done by the constraint.

User avatar
Nithin Kurup
Posts: 149
Joined: Sat Jan 18, 2014 5:13 am

Re: Input to coordinate actuator

Post by Nithin Kurup » Tue Nov 11, 2014 10:59 am

Dear Ajay,

Thank you so much for your reply,I had inserted the prescribed function in the coordinate section, replaced the slope with my needed speed in rad/s and the forward simulation runs and crank rotates.

I had tried to run the internal power for the joint.. but I am getting this error output as output. dont know where I made mistake.
Exception in the trial model fwd_simulation:SimTK Exception thrown at State.cpp:2069:
Expected stage to be at least Dynamics in StateImpl::getCacheEntry() but current stage was Velocity

Code: Select all

      	// Getting the number of joints
	        const JointSet &JointSet = osimModel.getJointSet();
		int joint = JointSet.getSize();
		cout<<"The Number of Joints in the Model is :" <<joint<< std::endl
		Array <double> Power = osimModel.getJointSet().get(13).calcPower(s);
               	// 13: index   number for Pin.joint
		manager.integrate(s);
		cout<<"Internal Power produced is :" << Power[0]<< std::endl;	
Thanking you,
Nithin

User avatar
Jiang Ping
Posts: 132
Joined: Sun Aug 26, 2012 4:09 am

Re: Input to coordinate actuator

Post by Jiang Ping » Tue Nov 11, 2014 11:17 am

Update your state to Dynamics stage to calculate force related information

if (s.getSystemStage() < Stage::Dynamics)
osimModel.getMultibodySystem().realize(s, Stage::Dynamics);

User avatar
Nithin Kurup
Posts: 149
Joined: Sat Jan 18, 2014 5:13 am

Re: Input to coordinate actuator

Post by Nithin Kurup » Tue Nov 11, 2014 11:33 am

Dear Jiang,

Thanks a lot for your reply, I tried to put the dynamics section, but still get the error.
Error because:SimTK Exception thrown at State.cpp:2080:
State Cache entry was out of date at Stage Dynamics. This entry depends on version 6175 of Stage Dynamics but was last updated at version 6174.

Code: Select all

               manager.integrate(s);
		osimModel.getMultibodySystem().realize(s, Stage::Dynamics); 
		Array <double> Power = osimModel.getJointSet().get("crank_Joint").calcPower(s); 
		cout<<"Internal Power produced is :" << Power[0] << std::endl;

Thanks again,

Nithin

User avatar
Jiang Ping
Posts: 132
Joined: Sun Aug 26, 2012 4:09 am

Re: Input to coordinate actuator

Post by Jiang Ping » Tue Nov 11, 2014 11:41 am

How about using update method instead of get

manager.integrate(s);
osimModel.updMultibodySystem().realize(s, Stage::Dynamics);
// Getting the number of joints
const JointSet &JointSet = osimModel.getJointSet();
int joint = JointSet.getSize();
Array <double> Power = osimModel.updJointSet().get("crank_Joint").calcPower(s);
cout<<"Internal Power produced is :" << Power[0] << std::endl;

User avatar
Nithin Kurup
Posts: 149
Joined: Sat Jan 18, 2014 5:13 am

Re: Input to coordinate actuator

Post by Nithin Kurup » Tue Nov 11, 2014 11:50 am

Hi Jiang,

Unfortunately, its showing the same error.the simulation works properly, but this calculation is the problem. Thanks a lot for taking time to reply.

Nithin

User avatar
Ajay Seth
Posts: 136
Joined: Thu Mar 15, 2007 10:39 am

Re: Input to coordinate actuator

Post by Ajay Seth » Tue Nov 11, 2014 11:51 am

calcPower returns a double not an Array<double>

POST REPLY