top of page
4.22. Joint Torque Control Start
New in version C++SDK-v2.1.5.0.
/**
* @brief Joint torque control start
* @return Error code
*/
errno_t ServoJTStart();
4.23. Joint Torque Control
New in version C++SDK-v2.1.5.0.
/**
* @brief Joint Torque Control 1
* @param [in] torque Torque for joints j1~j6, unit: Nm
* @param [in] interval Command cycle, unit: s, range: [0.001~0.008]
* @param [in] checkFlag Detection strategy 0-No restrictions; 1-Power limit; 2-Velocity limit; 3-Both power and velocity limits
* @param [in] jPowerLimit Maximum joint power limit (W)
* @param [in] jVelLimit Maximum joint velocity (°/s)
* @return Error code
*/
errno_t ServoJT(float torque[], double interval);
4.24. Joint Torque Control End
New in version C++SDK-v2.1.5.0.
/**
* @brief Joint torque control end
* @return Error code
*/
errno_t ServoJTEnd();
4.25. Joint Torque Control Example
New in version C++SDK-v2.1.5.0.
int TestServoJT(void)
{
ROBOT_STATE_PKG pkg = {};
FRRobot robot;
robot.LoggerInit();
robot.SetLoggerLevel(1);
int rtn = robot.RPC("192.168.58.2");
if (rtn != 0)
{
return -1;
}
robot.SetReConnectParam(true, 30000, 500);
robot.DragTeachSwitch(1);
float torques[] = { 0, 0, 0, 0, 0, 0 };
robot.GetJointTorques(1, torques);
int count = 100;
robot.ServoJTStart();
int error = 0;
while (count > 0)
{
error = robot.ServoJT(torques, 0.001);
count = count - 1;
robot.Sleep(1);
}
error = robot.ServoJTEnd();
robot.DragTeachSwitch(0);
robot.CloseRPC();
return 0;
}
4.26. Joint Torque Control Code Example with Overspeed Protection
int ServoJTWithSafety(FRRobot* robot)
{
robot->ResetAllError();
robot->Sleep(500);
float torques[] = { 0, 0, 0, 0, 0, 0 };
robot->GetJointTorques(1, torques);
robot->ServoJTStart();
ROBOT_STATE_PKG pkg = {};
robot->DragTeachSwitch(1);
int checkFlag = 3;
//double jPowerLimit[6] = {1, 1, 1, 1, 1, 1};
double jPowerLimit[6] = { 10.0, 10.0, 10.0, 10.0, 10.0, 10.0 };
double jVelLimit[6] = { 181, 80, 80, 80, 80, 80 };
int count = 800000;
int error = 0;
while (count > 0)
{
torques[2] = torques[2] + 0.01;
error = robot->ServoJT(torques, 0.008, checkFlag, jPowerLimit, jVelLimit);
if (error != 0)
{
robot->ServoJTEnd();
}
printf("ServoJT rtn is %d\n", error);
count = count - 1;
robot->Sleep(1);
robot->GetRobotRealTimeState(&pkg);
printf("maincode %d, subcode %d\n", pkg.main_code, pkg.sub_code);
}
robot->DragTeachSwitch(0);
error = robot->ServoJTEnd();
return 0;
}
4.27. Cartesian Space Servo Mode Motion
/**
* @brief Cartesian space servo mode motion
* @param [in] mode 0-Absolute motion (base coordinate system), 1-Incremental motion (base coordinate system), 2-Incremental motion (tool coordinate system)
* @param [in] desc_pos Target Cartesian pose or pose increment
* @param [in] exaxis Extended axis position
* @param [in] pos_gain Pose increment proportionality coefficient, only effective in incremental motion, range [0~1]
* @param [in] acc Acceleration percentage, range [0~100], temporarily not available, default 0
* @param [in] vel Velocity percentage, range [0~100], temporarily not available, default 0
* @param [in] cmdT Command transmission period, unit s, recommended range [0.001~0.016]
* @param [in] filterT Filter time, unit s, temporarily not available, default 0
* @param [in] gain Proportional amplifier for target position, temporarily not available, default 0
* @return Error code
*/
errno_t ServoCart(int mode, DescPose *desc_pose, ExaxisPos exaxis, float pos_gain[6], float acc, float vel, float cmdT, float filterT, float gain);
4.28. Cartesian Space Servo Mode Motion Code Example
int TestServoCart(void)
{
ROBOT_STATE_PKG pkg = {};
FRRobot robot;
robot.LoggerInit();
robot.SetLoggerLevel(1);
int rtn = robot.RPC("192.168.58.2");
if (rtn != 0)
{
return -1;
}
robot.SetReConnectParam(true, 30000, 500);
DescPose desc_pos_dt = { 83.00800, 50.525000 , 29.246 , 179.629 , -7.138 , -166.975 };
ExaxisPos exaxis = { 100.0, 0.0, 0.0, 0.0 };
float pos_gain[6] = { 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 };
int mode = 0;
float vel = 0.0;
float acc = 0.0;
float cmdT = 0.001;
float filterT = 0.0;
float gain = 0.0;
uint8_t flag = 0;
int count = 5000;
robot.SetSpeed(20);
while (count)
{
rtn = robot.ServoCart(mode, &desc_pos_dt, exaxis, pos_gain, acc, vel, cmdT, filterT, gain);
printf("ServoCart rtn is %d\n", rtn);
count -= 1;
desc_pos_dt.tran.x += 0.01;
exaxis.ePos[0] += 0.01;
}
robot.CloseRPC();
return 0;
}
4.29. Spline Motion Start
/**
* @brief Spline motion start
* @return Error code
*/
errno_t SplineStart();
4.30. Joint Space Spline Motion (Auto Forward Kinematics Calculation)
/**
* @brief Joint space spline motion (auto forward kinematics calculation)
* @param [in] joint_pos Target joint position, unit: deg
* @param [in] tool Tool coordinate system number, range [0~14]
* @param [in] user User coordinate system number, range [0~14]
* @param [in] vel Velocity percentage, range [0~100]
* @param [in] acc Acceleration percentage, range [0~100], currently not open
* @param [in] ovl Velocity scaling factor, range [0~100]
* @return Error code
*/
errno_t SplinePTP(JointPos* joint_pos, int tool, int user, float vel, float acc, float ovl);
4.31. Spline PTP Motion
/**
* @brief Joint space spline motion
* @param [in] joint_pos Target joint position in deg
* @param [in] desc_pos Target Cartesian pose
* @param [in] tool Tool coordinate number [0~14]
* @param [in] user Workpiece coordinate number [0~14]
* @param [in] vel Speed percentage [0~100]
* @param [in] acc Acceleration percentage [0~100] (not yet available)
* @param [in] ovl Speed scaling factor [0~100]
* @return Error code
*/
errno_t SplinePTP(JointPos *joint_pos, DescPose *desc_pos, int tool, int user, float vel, float acc, float ovl);
4.32. Spline Motion End
/**
* @brief Spline motion end
* @return Error code
*/
errno_t SplineEnd();
4.33. Spline Motion Example
int TestSpline(void)
{
ROBOT_STATE_PKG pkg = {};
FRRobot robot;
robot.LoggerInit();
robot.SetLoggerLevel(1);
int rtn = robot.RPC("192.168.58.2");
if (rtn != 0)
{
return -1;
}
robot.SetReConnectParam(true, 30000, 500);
JointPos j1(-11.904, -99.669, 117.473, -108.616, -91.726, 74.256);
JointPos j2(-45.615, -106.172, 124.296, -107.151, -91.282, 74.255);
JointPos j3(-61.954, -84.409, 108.153, -116.316, -91.283, 74.260);
JointPos j4(-89.575, -80.276, 102.713, -116.302, -91.284, 74.267);
DescPose desc_pos1(-419.524, -13.000, 351.569, -178.118, 0.314, 3.833);
DescPose desc_pos2(-321.222, 185.189, 335.520, -179.030, -1.284, -29.869);
DescPose desc_pos3(-327.622, 402.230, 320.402, -178.067, 2.127, -46.207);
DescPose desc_pos4(-104.066, 544.321, 327.023, -177.715, 3.371, -73.818);
DescPose offset_pos(0, 0, 0, 0, 0, 0);
ExaxisPos epos(0, 0, 0, 0);
int tool = 0;
int user = 0;
float vel = 100.0;
float acc = 100.0;
float ovl = 100.0;
float blendT = -1.0;
uint8_t flag = 0;
robot.SetSpeed(20);
int err1 = robot.MoveJ(&j1, &desc_pos1, tool, user, vel, acc, ovl, &epos, blendT, flag, &offset_pos);
printf("movej errcode:%d\n", err1);
robot.SplineStart();
robot.SplinePTP(&j1, &desc_pos1, tool, user, vel, acc, ovl);
robot.SplinePTP(&j2, &desc_pos2, tool, user, vel, acc, ovl);
robot.SplinePTP(&j3, &desc_pos3, tool, user, vel, acc, ovl);
robot.SplinePTP(&j4, &desc_pos4, tool, user, vel, acc, ovl);
robot.SplineEnd();
err1 = robot.MoveJ(&j1, tool, user, vel, acc, ovl, &epos, blendT, flag, &offset_pos);
printf("movej errcode:%d\n", err1);
robot.SplineStart();
robot.SplinePTP(&j1, tool, user, vel, acc, ovl);
robot.SplinePTP(&j2, tool, user, vel, acc, ovl);
robot.SplinePTP(&j3, tool, user, vel, acc, ovl);
robot.SplinePTP(&j4, tool, user, vel, acc, ovl);
robot.SplineEnd();
robot.CloseRPC();
return 0;
}
4.34. New Spline Motion Start
Changed in version C++SDK-v2.1.3.0.
/**
* @brief New spline motion start
* @param [in] type 0-Circular transition, 1-Given points as path points
* @param [in] averageTime Global average transition time in ms (10 ~ ), default 2000
* @return Error code
*/
errno_t NewSplineStart(int type, int averageTime=2000);
4.35. New Spline Command Point
/**
* @brief New spline command point
* @param [in] joint_pos Target joint position in deg
* @param [in] desc_pos Target Cartesian pose
* @param [in] tool Tool coordinate number [0~14]
* @param [in] user Workpiece coordinate number [0~14]
* @param [in] vel Speed percentage [0~100]
* @param [in] acc Acceleration percentage [0~100] (not yet available)
* @param [in] ovl Speed scaling factor [0~100]
* @param [in] blendR [-1.0]-Move to position (blocking), [0~1000.0]-Smoothing radius (non-blocking) in mm
* @param [in] lastFlag Whether it's the last point, 0-No, 1-Yes
* @return Error code
*/
errno_t NewSplinePoint(JointPos *joint_pos, DescPose *desc_pos, int tool, int user, float vel, float