Input to coordinate actuator
- Nithin Kurup
- Posts: 149
- Joined: Sat Jan 18, 2014 5:13 am
Input to coordinate actuator
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.
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.
Re: Input to coordinate actuator
It would be easier to prescribe the motion of the coordinate. Inside the Coordinate block that you want to prescribe, add:
You would change the slope of the linear function to be the constant speed that you require.
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>
- Nithin Kurup
- Posts: 149
- Joined: Sat Jan 18, 2014 5:13 am
Re: Input to coordinate actuator
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:
Thanking you so much, sorry again for troubling you.
Nithin
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));
Nithin
Re: Input to coordinate actuator
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.
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.
- Nithin Kurup
- Posts: 149
- Joined: Sat Jan 18, 2014 5:13 am
Re: Input to coordinate actuator
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.
Thanking you,
Nithin
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;
Nithin
- Jiang Ping
- Posts: 132
- Joined: Sun Aug 26, 2012 4:09 am
Re: Input to coordinate actuator
Update your state to Dynamics stage to calculate force related information
if (s.getSystemStage() < Stage::Dynamics)
osimModel.getMultibodySystem().realize(s, Stage::Dynamics);
if (s.getSystemStage() < Stage::Dynamics)
osimModel.getMultibodySystem().realize(s, Stage::Dynamics);
- Nithin Kurup
- Posts: 149
- Joined: Sat Jan 18, 2014 5:13 am
Re: Input to coordinate actuator
Dear Jiang,
Thanks a lot for your reply, I tried to put the dynamics section, but still get the error.
Thanks again,
Nithin
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;
Nithin
- Jiang Ping
- Posts: 132
- Joined: Sun Aug 26, 2012 4:09 am
Re: Input to coordinate actuator
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;
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;
- Nithin Kurup
- Posts: 149
- Joined: Sat Jan 18, 2014 5:13 am
Re: Input to coordinate actuator
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
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
Re: Input to coordinate actuator
calcPower returns a double not an Array<double>