Features
This is a function that controls the motor torque from an external controller.
Parameter
|
Parameter Name |
Data Type |
Default Value |
Description |
|
fMotorTor |
float[6] |
- |
Target Motor Torque [Nm] |
|
fTargetTime |
float |
- |
Target Time [s] |
-
Asnyc Command
-
Interpolate profile to be fMotorTor at fTargetTime.
-
If fTargetTime <= controller’s control period (=1ms), control is performed with the corresponding motor torque without interpolation.
-
If the next command is not received until arriving at fMotorTor, the last input torque is maintained.
-
However, for safety, if the next command is not received for 0.1[s], an error is generated as a time-out and stops.
In the case of the H series, there is a gravity compensator on the second axis, so the input motor torque and the torque generated by the gravitational compensator are added to move the robot. The gravity_torque of the external controller output data means (=link gravity torque – the torque of the gravity compensator)
Return
|
Value |
Description |
|
0 |
Error |
|
1 |
Success |
Example
// main.cpp
CDRFLEx drfl;
drfl.connect_rt_control();
string version = “v1.0”;
float period = 0.001; // 1 msec
int losscount = 4;
Drfl.set_on_rt_monitoring_data(OnRTMonitoringData);
drfl.set_rt_control_output(version, period, losscount);
drfl.start_rt_control();
float time = 0.0;
int count = 0;
float q[NUMBER_OF_JOINT] = {0.0, };
float q_dot[NUMBER_OF_JOINT] = {0.0, };
float q_d[NUMBER_OF_JOINT] = {0.0, };
float q_dot_d[NUMBER_OF_JOINT] = {0.0, };
float trq_g[NUMBER_OF_JOINT] = {0.0, };
float trq_d[NUMBER_OF_JOINT] = {0.0, };
float kp[NUMBER_OF_JOINT] = {1.0, 1.0, 1.0, 1.0, 1.0, 1.0}; // have to tune
float kd[NUMBER_OF_JOINT] = {1.0, 1.0, 1.0, 1.0, 1.0, 1.0}; // have to tune
while (1)
{
time=(++count)*period;
// get current state
memcpy(q, drfl.read_data_rt()->actual_joint_position, sizeof(float)*6);
memcpy(q_dot, drfl.read_data_rt()->actual_joint_velocity, sizeof(float)*6);
memcpy(trq_g, drfl.read_data_rt()->gravity_torque, sizeof(float)*6);
// make trajectory
TrajectoryGenerator(q_d, q_dot_d); // Custom Trajectory Generation Function
// gravity compensation + pd control
for (int i=0; i<6; i++) {
trq_d[i] = trq_g[i] + kp[i]*(q_d[i] – q[i]) + kd[i]*(q_dot_d[i] – q_dot[i]);
}
drfl.torque_rt(trq_d, 0);
if(time > plan1.time)
{
time=0;
Drfl.stop(STOP_TYPE_SLOW);
break;
}
rt_task_wait_period(NULL); // RTOS function
}