3. SDK Function Introduction
Interface call return value type:
1typedef enum _ARMErrorCode {
2} ARMErrorCode;
3.1. Introduction to the Robotic Arm SDK Functions
3.1.1. Instantiate the robotic arm
1/**
2* @brief Instantiates a robotic arm
3* @param [in] robotype Robotic arm model
4* @param [in] robotname Single arm, left arm, or right arm
5* @param [in] DHCompensations DH parameter compensation values for the robotic arm
6**/
7SingleRobot(int robotype, RobotName robotname, double DHCompensations[28] = nullptr);
3.1.2. Turn off the robotic arm
1/**
2 * @brief Close the robotic arm
3 **/
4~SingleRobot();
3.1.3. Joint-space motion
1/**
2* @brief Joint-space motion
3* @param [in] destJointPos Target joint positions in degrees
4* @param [in] velocity Velocity percentage, range [0–100]
5* @param [in] acceleration Acceleration percentage, range [0–100]; currently not supported
6* @param [out] errMsg Error message string
7* @return Error code
8**/
9ARMErrorCode MoveJ(double* destJointPos, double velocity, double acceleration, char errMsg[1024]);
3.1.4. Joint-Space Motion Code Example – Single Arm
1int MoveJTest()
2{
3 SingleRobot robot(SingleRobot::ART3_R7, SingleRobot::LeftArm); // Instantiate the robotic arm
4
5 // Target joint position data
6 double j1_left[7] = {10, 10, 10, 10, 10, -10, 10}; // Joint position data is for reference only
7 double velocity = 20;
8 double acceleration = 20;
9 robot.SetSpeed(10); // Set maximum motion speed
10 robot.SetAccScale(10); // Set motion acceleration
11 char errMsg[1024];
12 ARMErrorCode rtnCode = robot.MoveJ(j1_left, velocity, acceleration, errMsg);
13 if (rtnCode != ARMErrorCode::Success)
14 {
15 return -1;
16 }
17 // Check whether motion is complete
18 while(true)
19 {
20 std::this_thread::sleep_for(std::chrono::milliseconds(1000));
21 uint8_t state;
22 robot.GetRobotMotionDone(state);
23 if (state == 1)
24 {
25 break;
26 }
27 }
28 printf("moveJ error code: %d\n", rtnCode);
29
30 return 0;
31}
3.1.5. Joint-Space Motion Code Example – Dual-Arm
1int MoveJTest2()
2{
3 SingleRobot robot_left(SingleRobot::ART3_R7, SingleRobot::LeftArm); // Instantiate left robotic arm
4 SingleRobot robot_right(SingleRobot::ART3_R7, SingleRobot::RightArm); // Instantiate right robotic arm
5
6 // Target joint position data
7 double j1_left[7] = {10, 10, 10, 10, 10, -10, 10};
8 double j1_right[7] = {10, 10, 10, 10, 10, -10, 10};
9 double velocity = 20;
10 double acceleration = 20;
11 robot_left.SetSpeed(10); // Set maximum motion speed
12 robot_left.SetAccScale(10); // Set motion acceleration
13 robot_right.SetSpeed(10); // Set maximum motion speed
14 robot_right.SetAccScale(10); // Set motion acceleration
15 char errMsg[1024];
16 ARMErrorCode rtnCode = robot_left.MoveJ(j1_left, velocity, acceleration, errMsg);
17 if (rtnCode != ARMErrorCode::Success)
18 {
19 return -1;
20 }
21 memset(errMsg, 0, 1024);
22 rtnCode = robot_right.MoveJ(j1_right, velocity, acceleration, errMsg);
23 if (rtnCode != ARMErrorCode::Success)
24 {
25 return -1;
26 }
27 // Check whether motion is complete
28 uint8_t state_left = 0;
29 uint8_t state_right = 0;
30 while(true)
31 {
32 std::this_thread::sleep_for(std::chrono::milliseconds(1000));
33
34 robot_left.GetRobotMotionDone(state_left);
35 robot_right.GetRobotMotionDone(state_right);
36 if (state_left == 1 && state_right == 1)
37 {
38 break;
39 }
40 }
41 printf("moveJ errorcode: %d\n", rtnCode);
42
43 return 0;
44}
3.1.6. Cartesian space point-to-point motion
1/**
2* @brief Cartesian space point-to-point motion
3* @param [in] destCartPos Target Cartesian pose [mm, deg]
4* @param [in] destArmAngle Target arm angle in degrees
5* @param [in] velocity Velocity percentage, range [0–100]
6* @param [in] acceleration Acceleration percentage, range [0–100]; currently not supported
7* @param [out] errMsg Error message string
8* @return Error code
9**/
10ARMErrorCode MoveP(double* destCartPos, double destArmAngle, double velocity, double acceleration, char errMsg[1024]);
3.1.7. Linear motion in Cartesian space
1/**
2* @brief Cartesian space linear motion
3* @param [in] destCartPos Target Cartesian pose [mm, deg]
4* @param [in] destArmAngle Target arm angle in degrees
5* @param [in] velocity Velocity percentage, range [0–100]
6* @param [in] acceleration Acceleration percentage, range [0–100]; currently not supported
7* @param [out] errMsg Error message string
8* @return Error code
9**/
10ARMErrorCode MoveL(double* destCartPos, double destArmAngle, double velocity, double acceleration, char errMsg[1024]);
3.1.8. Cartesian Space Linear Motion Code Example – Single Arm
1int MoveLTest()
2{
3 SingleRobot robot(SingleRobot::ART3_R7, SingleRobot::LeftArm); // Instantiate the robotic arm
4
5 // Cartesian-space linear motion trajectory planning
6 double j0_left[7] = {10, 10, 10, 10, 10, -10, 10};
7 double desc_pos1_left[6] = {148.545536, 14.373573, 791.612359, 14.266475, 4.332141, 29.863598};
8 double armAngle1_left = 351.959826;
9 double velocity = 20;
10 double acceleration = 20;
11 robot.SetSpeed(10); // Set maximum motion speed
12 robot.SetAccScale(10); // Set motion acceleration
13 char errMsg[1024];
14 ARMErrorCode rtnCode = robot.MoveJ(j0_left, velocity, acceleration, errMsg); // Move to the starting point of the linear trajectory
15 if (rtnCode != ARMErrorCode::Success)
16 {
17 return -1;
18 }
19 // Check whether motion is complete
20 while(true)
21 {
22 std::this_thread::sleep_for(std::chrono::milliseconds(1000));
23 uint8_t state;
24 robot.GetRobotMotionDone(state);
25 if (state == 1)
26 {
27 break;
28 }
29 }
30
31 memset(errMsg, 0, 1024);
32 rtnCode = robot.MoveL(desc_pos1_left, armAngle1_left, velocity, acceleration, errMsg);
33 if (rtnCode != ARMErrorCode::Success)
34 {
35 return -1;
36 }
37 // Check whether motion is complete
38 while(true)
39 {
40 std::this_thread::sleep_for(std::chrono::milliseconds(1000));
41 uint8_t state;
42 robot.GetRobotMotionDone(state);
43 if (state == 1)
44 {
45 break;
46 }
47 }
48 printf("moveL errorcode: %d\n", rtnCode);
49
50 return 0;
51}
3.1.9. Cartesian Space Linear Motion Code Example – Dual-Arm
1int MoveLTest2()
2{
3 SingleRobot robot_left(SingleRobot::ART3_R7, SingleRobot::LeftArm); // Instantiate left robotic arm
4 SingleRobot robot_right(SingleRobot::ART3_R7, SingleRobot::RightArm); // Instantiate right robotic arm
5
6 // Cartesian-space linear motion trajectory planning
7 double j0_left[7] = {10, 10, 10, 10, 10, -10, 10};
8 double j0_right[7] = {10, 10, 10, 10, 10, -10, 10};
9 double desc_pos1_left[6] = {148.545536, 14.373573, 791.612359, 14.266475, 4.332141, 29.863598};
10 double armAngle1_left = 351.959826;
11 double desc_pos1_right[6] = {148.545536, 14.373573, 791.612359, 14.266475, 4.332141, 29.863598};
12 double armAngle1_right = 351.959826;
13 double velocity = 20;
14 double acceleration = 20;
15 robot_left.SetSpeed(10); // Set maximum motion speed
16 robot_left.SetAccScale(10); // Set motion acceleration
17 robot_right.SetSpeed(10); // Set maximum motion speed
18 robot_right.SetAccScale(10); // Set motion acceleration
19 char errMsg[1024];
20
21 // Move both arms to the start point of the linear trajectory
22 ARMErrorCode rtnCode = robot_left.MoveJ(j0_left, velocity, acceleration, errMsg);
23 if (rtnCode != ARMErrorCode::Success)
24 {
25 return -1;
26 }
27 memset(errMsg, 0, 1024);
28 rtnCode = robot_right.MoveJ(j0_right, velocity, acceleration, errMsg);
29 if (rtnCode != ARMErrorCode::Success)
30 {
31 return -1;
32 }
33 // Check whether motion is complete
34 uint8_t state_left = 0;
35 uint8_t state_right = 0;
36 while(true)
37 {
38 std::this_thread::sleep_for(std::chrono::milliseconds(1000));
39 robot_left.GetRobotMotionDone(state_left);
40 robot_right.GetRobotMotionDone(state_right);
41 if (state_left == 1 && state_right == 1)
42 {
43 break;
44 }
45 }
46
47 memset(errMsg, 0, 1024);
48 rtnCode = robot_left.MoveL(desc_pos1_left, armAngle1_left, velocity, acceleration, errMsg);
49 if (rtnCode != ARMErrorCode::Success)
50 {
51 return -1;
52 }
53 memset(errMsg, 0, 1024);
54 rtnCode = robot_right.MoveL(desc_pos1_right, armAngle1_right, velocity, acceleration, errMsg);
55 if (rtnCode != ARMErrorCode::Success)
56 {
57 return -1;
58 }
59 // Check whether motion is complete
60 state_left = 0;
61 state_right = 0;
62 while(true)
63 {
64 std::this_thread::sleep_for(std::chrono::milliseconds(1000));
65 robot_left.GetRobotMotionDone(state_left);
66 robot_right.GetRobotMotionDone(state_right);
67 if (state_left == 1 && state_right == 1)
68 {
69 break;
70 }
71 }
72 printf("moveL errorcode: %d\n", rtnCode);
73
74 return 0;
75}
3.1.10. Circular Arc Motion in Cartesian Space
1/**
2* @brief Cartesian space circular arc motion
3* @param [in] midCartPos Cartesian pose of the midpoint, units: [mm, deg]
4* @param [in] midArmAngle Arm angle of the robotic arm at the midpoint, units: deg
5* @param [in] destCartPos Cartesian pose of the destination point, units: [mm, deg]
6* @param [in] destArmAngle Arm angle of the robotic arm at the destination point, units: deg
7* @param [in] velocity Velocity percentage, range: [0–100]
8* @param [in] acceleration Acceleration percentage, range: [0–100]; currently not supported
9* @param [out] errMsg Error message output
10* @return Error code
11**/
12ARMErrorCode MoveC(double* midCartPos, double midArmAngle, double* destCartPos, double destArmAngle, double velocity, double acceleration, char errMsg[1024]);
3.1.11. Cartesian Space Arc Motion Code Example – Single Arm
1int MoveCTest()
2{
3 SingleRobot robot(SingleRobot::ART3_R7, SingleRobot::LeftArm); // Instantiate the robotic arm
4
5 // Position data for the arc trajectory: start point, intermediate point, and target point
6 double desc_pos1_left[6] = {148.545536, 14.373573, 791.612359, 14.266475, 4.332141, 29.863598};
7 double armAngle1_left = 351.959826;
8 double desc_pos2_left[6] = {237.686578, 36.090539, 763.929631, 16.922444, 13.941801, 30.475488};
9 double armAngle2_left = 352.413796;
10 double desc_pos3_left[6] = {321.576660, 56.804783, 723.049930, 19.871510, 23.501873, 31.687545};
11 double armAngle3_left = 352.574131;
12 double velocity = 10;
13 double acceleration = 10;
14 robot.SetSpeed(10); // Set maximum motion speed
15 robot.SetAccScale(10); // Set motion acceleration
16
17 // Move to the arc trajectory’s starting point
18 char errMsg[1024];
19 ARMErrorCode rtnCode = robot.MoveP(desc_pos1_left, armAngle1_left, velocity, acceleration, errMsg);
20 if (rtnCode != ARMErrorCode::Success)
21 {
22 return -1;
23 }
24 // Check whether motion is complete
25 while(true)
26 {
27 std::this_thread::sleep_for(std::chrono::milliseconds(1000));
28 uint8_t state;
29 robot.GetRobotMotionDone(state);
30 if (state == 1)
31 {
32 break;
33 }
34 }
35 printf("moveJ errorcode: %d\n", rtnCode);
36
37 // Cartesian-space arc trajectory planning
38 memset(errMsg, 0, 1024);
39 rtnCode = robot.MoveC(desc_pos2_left, armAngle2_left, desc_pos3_left, armAngle3_left, velocity, acceleration, errMsg);
40 if (rtnCode != ARMErrorCode::Success)
41 {
42 return -1;
43 }
44 // Check whether motion is complete
45 while(true)
46 {
47 std::this_thread::sleep_for(std::chrono::milliseconds(1000));
48 uint8_t state;
49 robot.GetRobotMotionDone(state);
50 if (state == 1)
51 {
52 break;
53 }
54 }
55 printf("moveC errorcode: %d\n", rtnCode);
56
57 return 0;
58}
3.1.12. Cartesian Space Arc Motion Code Example – Dual-Arm
1int MoveCTest2()
2{
3 SingleRobot robot_left(SingleRobot::ART3_R7, SingleRobot::LeftArm); // Instantiate left robotic arm
4 SingleRobot robot_right(SingleRobot::ART3_R7, SingleRobot::RightArm); // Instantiate right robotic arm
5
6 // Position data for the arc’s start point, intermediate point, and target point
7 double desc_pos1_left[6] = {148.545536, 14.373573, 791.612359, 14.266475, 4.332141, 29.863598};
8 double armAngle1_left = 351.959826;
9 double desc_pos1_right[6] = {148.545536, 14.373573, 791.612359, 14.266475, 4.332141, 29.863598};
10 double armAngle1_right = 351.959826;
11 double desc_pos2_left[6] = {237.686578, 36.090539, 763.929631, 16.922444, 13.941801, 30.475488};
12 double armAngle2_left = 352.413796;
13 double desc_pos2_right[6] = {237.686578, 36.090539, 763.929631, 16.922444, 13.941801, 30.475488};
14 double armAngle2_right = 352.413796;
15 double desc_pos3_left[6] = {321.576660, 56.804783, 723.049930, 19.871510, 23.501873, 31.687545};
16 double armAngle3_left = 352.574131;
17 double desc_pos3_right[6] = {321.576660, 56.804783, 723.049930, 19.871510, 23.501873, 31.687545};
18 double armAngle3_right = 352.574131;
19 double velocity = 10;
20 double acceleration = 10;
21 robot_left.SetSpeed(10); // Set maximum motion speed
22 robot_left.SetAccScale(10); // Set motion acceleration
23 robot_right.SetSpeed(10); // Set maximum motion speed
24 robot_right.SetAccScale(10); // Set motion acceleration
25 char errMsg[1024];
26
27 // Move both arms to the arc trajectory’s starting point
28 ARMErrorCode rtnCode = robot_left.MoveP(desc_pos1_left, armAngle1_left, velocity, acceleration, errMsg);
29 if (rtnCode != ARMErrorCode::Success)
30 {
31 return -1;
32 }
33 memset(errMsg, 0, 1024);
34 rtnCode = robot_right.MoveP(desc_pos1_right, armAngle1_right, velocity, acceleration, errMsg);
35 if (rtnCode != ARMErrorCode::Success)
36 {
37 return -1;
38 }
39 // Check whether motion is complete
40 uint8_t state_left = 0;
41 uint8_t state_right = 0;
42 while(true)
43 {
44 std::this_thread::sleep_for(std::chrono::milliseconds(1000));
45 robot_left.GetRobotMotionDone(state_left);
46 robot_right.GetRobotMotionDone(state_right);
47 if (state_left == 1 && state_right == 1)
48 {
49 break;
50 }
51 }
52
53 // Cartesian-space arc trajectory planning
54 memset(errMsg, 0, 1024);
55 rtnCode = robot_left.MoveC(desc_pos2_left, armAngle2_left, desc_pos3_left, armAngle3_left, velocity, acceleration, errMsg);
56 if (rtnCode != ARMErrorCode::Success)
57 {
58 return -1;
59 }
60 memset(errMsg, 0, 1024);
61 rtnCode = robot_right.MoveC(desc_pos2_right, armAngle2_right, desc_pos3_right, armAngle3_right, velocity, acceleration, errMsg);
62 if (rtnCode != ARMErrorCode::Success)
63 {
64 return -1;
65 }
66 // Check whether motion is complete
67 state_left = 0;
68 state_right = 0;
69 while(true)
70 {
71 std::this_thread::sleep_for(std::chrono::milliseconds(1000));
72 robot_left.GetRobotMotionDone(state_left);
73 robot_right.GetRobotMotionDone(state_right);
74 if (state_left == 1 && state_right == 1)
75 {
76 break;
77 }
78 }
79 printf("moveC errorcode: %d\n", rtnCode);
80
81 return 0;
82}
3.1.13. Servo motion starts
1/**
2 * @brief Starts servo motion; used in conjunction with the ServoJ command.
3 * @return Error code
4 **/
5ARMErrorCode ServoMoveStart();
3.1.14. Servo motion ended
1/**
2 * @brief Ends servo motion; used in conjunction with the ServoJ command.
3 * @return Error code
4 */
5ARMErrorCode ServoMoveEnd();
3.1.15. Joint-space servo mode motion
1/**
2* @brief Servo motion in joint space
3* @param [in] jointPos Target joint positions, in degrees
4* @param [in] period Command transmission period, in milliseconds
5* @param [out] errMsg Error message output
6* @return Error code
7**/
8ARMErrorCode ServoJ(double* jointPos, int period, char errMsg[1024]);
3.1.16. Cartesian space servo motion
1/**
2* @brief Cartesian space servo motion
3* @param [in] servo_cartPos Cartesian servo motion trajectory points, formatted as [end-flange coordinate system position, RPY angles of the coordinate system, robot arm angle], with length 7*len and units [mm, deg, deg]
4* @param [in] len Number of Cartesian servo motion trajectory points
5* @param [out] errMsg Error message string
6* @return Error code
7**/
8ARMErrorCode ServoCart(double* servo_cartPos, uint32_t len, char errMsg[1024]);
3.1.17. Joint-space servo mode motion – single arm
1int ServoJTest()
2{
3 SingleRobot robot(SingleRobot::ART3_R7, SingleRobot::LeftArm); // Instantiate the robotic arm
4
5 // Target joint position information
6 double j1_left[7] = {10, 10, 10, 10, 10, -10, 10};
7 double velocity = 20;
8 double acceleration = 20;
9 robot.SetSpeed(10); // Set maximum motion speed
10 robot.SetAccScale(10); // Set motion acceleration
11 char errMsg[1024];
12 ARMErrorCode rtnCode = robot.MoveJ(j1_left, velocity, acceleration, errMsg);
13 // if (rtnCode != ARMErrorCode::Success)
14 // {
15 // return -1;
16 // }
17 // Check whether motion is complete
18 while(true)
19 {
20 std::this_thread::sleep_for(std::chrono::milliseconds(1000));
21 uint8_t state;
22 robot.GetRobotMotionDone(state);
23 if (state == 1)
24 {
25 break;
26 }
27 }
28 printf("moveJ error code: %d\n", rtnCode);
29
30 int stepTime = 5; // ms
31 double speed = 5;
32 double runTime = 1.0; // s
33 int totalNum = static_cast<int>(runTime * 1000.0 / stepTime);
34 double nextJoint[7] = {0};
35
36 memset(errMsg, 0, 1024);
37 rtnCode = robot.ServoMoveStart();
38 if (rtnCode != ARMErrorCode::Success)
39 {
40 return -1;
41 }
42 for (int i = 0; i < totalNum; i++)
43 {
44 for (int j = 0; j < 7; j++)
45 {
46 nextJoint[j] = j1_left[j] + i * 1.0 / totalNum * speed;
47 }
48 rtnCode = robot.ServoJ(nextJoint, stepTime, errMsg);
49 if (rtnCode != ARMErrorCode::Success)
50 {
51 std::cout << static_cast<int>(rtnCode) << std::endl;
52 break;
53 }
54 }
55 printf("servoJ error code: %d\n", rtnCode);
56 rtnCode = robot.ServoMoveEnd();
57 if (rtnCode != ARMErrorCode::Success)
58 {
59 return -1;
60 }
61
62 return 0;
63}
3.1.18. Joint-space servo mode motion—dual-arm
1int ServoJTest2()
2{
3 std::thread th_left([]{
4 SingleRobot robot_left(SingleRobot::ART3_R7, SingleRobot::LeftArm); // Instantiate left arm
5 // Target joint position data
6 double j1_left[7] = {10, 10, 10, 10, 10, -10, 10};
7 double velocity = 20;
8 double acceleration = 20;
9 robot_left.SetSpeed(10); // Set maximum motion speed
10 robot_left.SetAccScale(10); // Set motion acceleration
11 char errMsg_l[1024];
12
13 ARMErrorCode rtnCode = robot_left.MoveJ(j1_left, velocity, acceleration, errMsg_l);
14 if (rtnCode != ARMErrorCode::Success)
15 {
16 return -1;
17 }
18 // Check whether motion is complete
19 uint8_t state_left = 0;
20 while(true)
21 {
22 std::this_thread::sleep_for(std::chrono::milliseconds(1000));
23
24 robot_left.GetRobotMotionDone(state_left);
25 if (state_left == 1)
26 {
27 break;
28 }
29 }
30 printf("left arm moveJ errorcode: %d\n", rtnCode);
31
32 int stepTime = 5; // ms
33 double speed = 5;
34 double runTime = 1.0; // s
35 int totalNum = static_cast<int>(runTime * 1000.0 / stepTime);
36 double nextJoint[7] = {0};
37 ARMErrorCode rtnCode_l = robot_left.ServoMoveStart();
38 if (rtnCode_l != ARMErrorCode::Success)
39 {
40 std::cout << static_cast<int>(rtnCode_l) << std::endl;
41 robot_left.ServoMoveEnd();
42 return -1;
43 }
44 for (int i = 0; i < totalNum; i++)
45 {
46 for (int j = 0; j < 7; j++)
47 {
48 nextJoint[j] = j1_left[j] + i * 1.0 / totalNum * speed;
49 }
50 rtnCode_l = robot_left.ServoJ(nextJoint, stepTime, errMsg_l);
51 if (rtnCode_l != ARMErrorCode::Success)
52 {
53 break;
54 }
55 }
56 printf("servoJ errorcode: %d\n", rtnCode_l);
57 rtnCode_l = robot_left.ServoMoveEnd();
58 if (rtnCode_l != ARMErrorCode::Success)
59 {
60 return -1;
61 }
62 });
63 if (th_left.joinable())
64 {
65 th_left.join();
66 }
67
68 std::this_thread::sleep_for(std::chrono::microseconds(1000));
69 std::thread th_right([]{
70 SingleRobot robot_right(SingleRobot::ART3_R7, SingleRobot::RightArm); // Instantiate right arm
71 // Target joint position data
72 double j1_right[7] = {10, 10, 10, 10, 10, -10, 10};
73 double velocity = 20;
74 double acceleration = 20;
75 robot_right.SetSpeed(10); // Set maximum motion speed
76 robot_right.SetAccScale(10); // Set motion acceleration
77 char errMsg_r[1024];
78
79 ARMErrorCode rtnCode = robot_right.MoveJ(j1_right, velocity, acceleration, errMsg_r);
80 if (rtnCode != ARMErrorCode::Success)
81 {
82 return -1;
83 }
84 // Check whether motion is complete
85 uint8_t state_right = 0;
86 while(true)
87 {
88 std::this_thread::sleep_for(std::chrono::milliseconds(1000));
89
90 robot_right.GetRobotMotionDone(state_right);
91 if (state_right == 1)
92 {
93 break;
94 }
95 }
96 printf("right arm moveJ errorcode: %d\n", rtnCode);
97
98 int stepTime = 5; // ms
99 double speed = 5;
100 double runTime = 1.0; // s
101 int totalNum = static_cast<int>(runTime * 1000.0 / stepTime);
102 double nextJoint[7] = {0};
103 ARMErrorCode rtnCode_r = robot_right.ServoMoveStart();
104 if (rtnCode_r != ARMErrorCode::Success)
105 {
106 std::cout << static_cast<int>(rtnCode_r) << std::endl;
107 robot_right.ServoMoveEnd();
108 return -1;
109 }
110 for (int i = 0; i < totalNum; i++)
111 {
112 for (int j = 0; j < 7; j++)
113 {
114 nextJoint[j] = j1_right[j] + i * 1.0 / totalNum * speed;
115 }
116 rtnCode_r = robot_right.ServoJ(nextJoint, stepTime, errMsg_r);
117 if (rtnCode_r != ARMErrorCode::Success)
118 {
119 break;
120 }
121 }
122 printf("servoJ errorcode: %d\n", rtnCode_r);
123 rtnCode_r = robot_right.ServoMoveEnd();
124 if (rtnCode_r != ARMErrorCode::Success)
125 {
126 return -1;
127 }
128 });
129 if (th_right.joinable())
130 {
131 th_right.join();
132 }
133
134 return 0;
135}
3.1.19. Stop exercising
1/**
2* @brief Stop motion
3* @return Error code
4**/
5ARMErrorCode StopMotion();
3.1.20. Pause exercise
1/**
2* @brief Pause motion
3* @return Error code
4**/
5ARMErrorCode PauseMotion();
3.1.21. Resume exercise
1/**
2* @brief Resumes motion
3* @return Error code
4**/
5ARMErrorCode ResumeMotion();
3.1.22. Clear motion command queue
1/**
2* @brief Clears the motion command queue.
3* @return Error code
4*/
5ARMErrorCode MotionQueueClear();
3.1.23. Multi-point joint-space motion
1/**
2* @brief Multi-point joint-space motion
3* @param [in] jointPos Joint positions, unit: deg
4* @param [in] pointNum Number of joint-space points
5* @param [in] velocity Velocity percentage, range: [0–100]
6* @param [in] acceleration Acceleration percentage, range: [0–100]; currently not supported
7* @param [out] errMsg Error message string
8* @return Error code
9**/
10ARMErrorCode MoveJ_path(double jointPos[256][7], uint8_t pointNum, double velocity, double acceleration, char errMsg[1024]);
3.1.24. Multi-point joint-space motion
1/**
2* @brief Multi-point Cartesian space motion
3* @param [in] cartPos Cartesian pose, unit: [mm, deg]
4* @param [in] armAngle Arm angle, unit: deg
5* @param [in] pointNum Number of joint-space points
6* @param [in] velocity Velocity percentage, range[0-100]
7* @param [in] acceleration Acceleration percentage, range[0-100], not available yet
8* @param [out] errMsg Error message printing
9* @return Error code
10**/
11ARMErrorCode MoveL_path(double cartPos[256][6], double armAngle[256], uint8_t pointNum, double velocity, double acceleration, char errMsg[1024]);
3.1.25. Robot Arm Returning to Home Position
1/**
2* @brief Home the robotic arm
3* @param [in] velocity Velocity percentage, range [0-100]
4* @param [in] acceleration Acceleration percentage, range [0-100] (currently not supported)
5* @param [out] errMsg Error message string
6* @return Error code
7**/
8ARMErrorCode RobotHoming(double velocity, double acceleration, char errMsg[1024]);
3.1.26. Jog Start
1/**
2* @brief Start JOG operation
3* @param [in] ref 0 - Joint JOG
4* @param [in] number Joint number: 1 - Joint 1, 2 - Joint 2, 3 - Joint 3, 4 - Joint 4, 5 - Joint 5, 6 - Joint 6, 7 - Joint 7
5* @param [in] dir Direction: 0 - Negative direction, 1 - Positive direction
6* @param [in] vel Velocity percentage, range [0–100]
7* @param [in] acc Acceleration percentage, range [0–100]; currently not supported
8* @param [in] max_dis Maximum single JOG angle, unit: deg
9* @param [out] errMsg Error message string
10* @return Error code
11**/
12ARMErrorCode StartJOG(uint8_t ref, uint8_t number, uint8_t dir, double vel, double acc, double max_dis, char errMsg[1024]);
3.1.27. Jogging ends
1/**
2* @brief Stop jogging
3* @return Error code
4**/
5ARMErrorCode StopJOG();
3.1.28. Start Singular Pose Protection
1/**
2 * @brief Start singularity avoidance protection
3 * @param [in] dist Singularity distance range, in mm
4 * @param [in] ang Singularity angle range, in deg
5 * @return Error code
6 */
7ARMErrorCode SingularAvoidStart(double dist, double ang);
3.1.29. Disable Singular Pose Protection
1/**
2* @brief Stop singularity avoidance protection
3* @return Error code
4**/
5ARMErrorCode SingularAvoidEnd();
3.1.30. Set Tool Coordinate System
1/**
2* @brief Sets the tool coordinate system
3* @param [in] toolNum Tool coordinate system ID, range: 1–19
4* @param [in] corrd Tool coordinate system {x, y, z, rx, ry, rz}, units: [mm, deg]
5* @return Error code
6**/
7ARMErrorCode SetToolCorrd(int toolNum, double* corrd);
3.1.31. Set robotic arm acceleration percentage
1/**
2* @brief Sets the acceleration percentage of the robotic arm.
3* @param [in] scale Acceleration percentage.
4* @return Error code.
5**/
6ARMErrorCode SetAccScale(double scale);
3.1.32. Set Global Speed Percentage
1/**
2* @brief Sets the global speed percentage.
3* @param [in] speed Speed percentage.
4* @return Error code.
5**/
6ARMErrorCode SetSpeed(double speed);
3.1.33. Forward Kinematics Solution
1/**
2* @brief Solves forward kinematics
3* @param [in] joint_val Joint positions, in degrees
4* @param [out] xyzrpy Cartesian pose
5* @param [out] arm_angle Robotic arm angle
6* @return Error code
7**/
8ARMErrorCode GetForwardKin(double* joint_val, double* desc_pos, double& arm_angle);
3.1.34. Inverse Kinematics Solution
1/**
2 * @brief Solves inverse kinematics
3 * @param [in] trans End-effector Cartesian pose, units: [mm, deg]
4 * @param [in] arm_angle Arm angle of the robotic arm, units: deg
5 * @param [out] joint_val Joint positions, units: deg
6 * @return Error code
7 **/
8ARMErrorCode GetInverseKin(double* desc_pos, double arm_angle, double* joint_val);
3.1.35. Inverse Kinematics Solution (Reference Position)
1/**
2* @brief Solves inverse kinematics with reference to a specified joint position.
3* @param [in] trans Cartesian pose of the end-effector, units: [mm, deg]
4* @param [in] arm_angle Arm angle of the robotic arm, units: deg
5* @param [in] ref_joint_val Reference joint positions, units: deg
6* @param [out] joint_val Joint positions, units: deg
7* @return Error code
8**/
9ARMErrorCode GetInverseKinRef(double* desc_pos, double arm_angle, double* ref_joint_val, double* joint_val);
3.1.36. Get current joint position (angle)
1/**
2* @brief Gets the current joint positions (angles).
3* @param [out] joint_pos: Joint positions in degrees [deg].
4* @return Error code.
5**/
6ARMErrorCode GetActualJointPosDegree(double joint_pos[7]);
3.1.37. Obtain the current tool pose
1/**
2* @brief Gets the current tool pose
3* @param [out] pose, units [mm, deg]
4* @return Error code
5**/
6ARMErrorCode GetActualTCPPose(double pose[6]);
3.1.38. Check whether the robotic arm movement is completed
1/**
2* @brief Checks whether the robotic arm's motion is complete.
3* @param [out] state: 0 - incomplete, 1 - complete
4* @return Error code
5**/
6ARMErrorCode GetRobotMotionDone(uint8_t& state);
3.1.39. Get current end-effector velocity
1/**
2* @brief Gets the current end-effector speed.
3* @param [out] eeVal: speed values, in units of [mm/s, deg/s]
4* @return Error code
5**/
6ARMErrorCode GetActualToolFlangeSpeed(double eeVal[6]);
3.1.40. Obtain joint torque
1/**
2* @brief Gets the joint torques.
3* @param [out] torques: Torques in Nm.
4* @return Error code.
5**/
6ARMErrorCode GetJointTorques(double torques[7]);
3.1.41. Obtain joint actuator torque
1/**
2* @brief Gets the joint driver torque.
3* @param [out] torques: Torque values in Nm.
4* @return Error code.
5**/
6ARMErrorCode GetJointDriverTorque(double torques[7]);
3.1.42. Query Robot Error Codes
1/**
2* @brief Queries the robot error code.
3* @param [out] errCode The error code.
4* @return The error code.
5**/
6ARMErrorCode GetRobotErrorCode(unsigned int& errCode);
3.1.43. Check whether the robot is singular
1/**
2* @brief Gets the robot's singularity state.
3* @param [in] judgeDist Singularity distance threshold, in mm.
4* @param [in] judgeAng Singularity angle threshold, in degrees.
5* @param [out] state 0—non-singular; 1—singular.
6* @return Error code.
7**/
8ARMErrorCode GetRobotSingularState(double judgeDist, double judgeAng, uint8_t& state);
3.1.44. Obtain Robot DH Parameter Compensation Values
1/**
2* @brief Gets the robot's DH parameter compensation values.
3* @param [out] dh_theta Zero-position angles.
4* @param [out] dh_a Link offsets.
5* @param [out] dh_d Link lengths.
6* @param [out] dh_alpha Link twists.
7* @return Error code.
8**/
9ARMErrorCode GetDHCompensation(double dh_theta[7], double dh_a[7], double dh_d[7], double dh_alpha[7]);
3.1.45. Joint Enable
1/**
2* @brief Enables a joint.
3* @param [in] joint_id Joint index: 0 for all robot arm joints, 1–7 for corresponding individual joints.
4* @return Error code.
5**/
6ARMErrorCode AxisEnable(int joint_id);
3.1.46. Joint Disable
1/**
2* @brief Disables a joint.
3* @param [in] joint_id Joint index: 0 for all robotic arm joints, 1–7 for corresponding individual joints.
4* @return Error code.
5**/
6ARMErrorCode AxisDisable(int joint_id);
3.1.47. Joint Zero Calibration
1/**
2* @brief Perform joint zeroing calibration
3* @param [in] joint_id Joint index: 0 for all robotic arm joints, 1–7 for corresponding individual joints
4* @return Error code
5**/
6ARMErrorCode AxisZeroing(int joint_id);
3.1.48. Clear Controller Errors
1/**
2* @brief Clears controller errors
3* @return Error code
4**/
5ARMErrorCode AxisResetError();
3.1.49. Set Load Weight and Center of Gravity(OnlyJK2.0Robotic Arm Use)
1/**
2* @brief Set payload weight and center of mass
3* @param [in] index Payload list index, range:[0-19]
4* @param [in] mess Payload weight, unit:kg
5* @param [in] mess Payload center of mass coordinates(ARTseries relative to the end coordinate system(Zaxis points outward,Xpoints toward the button)), unit:mm
6* @return Error code
7**/
8ARMErrorCode SetLoadcoord(uint8_t index, double mess, double messCenter[3]);
3.1.50. Set joint friction compensation switch(onlyJK2.0manipulator use)
1/**
2* @brief Enables or disables joint friction compensation
3* @param [in] onOff Compensation switch: 0 - disabled, 1 - enabled
4* @return Error code
5**/
6ARMErrorCode FrictionCompensationOnOff(uint8_t onOff);
3.1.51. Set joint friction compensation coefficient(onlyJK2.0manipulator use)
1/**
2* @brief Sets the joint friction compensation coefficient
3* @param [in] value Friction compensation coefficient, range: [0, 1]
4* @return Error code
5**/
6ARMErrorCode SetFrictionValue(double value[7]);
3.1.52. Set robotic arm soft limit protection switch ( only JK2.0 robotic arm use )
1/**
2* @brief Enables or disables the robotic arm's soft limit protection.
3* @param [in] onOff Soft limit switch: 0 for disabled, 1 for enabled.
4* @return Error code.
5**/
6ARMErrorCode SetJointSoftLimitOnOff(uint8_t onOff);
3.1.53. Set current loop teaching drag ( only JK2.0 robotic arm use )
1/**
2 * @brief Sets the current-loop teaching mode.
3 * @param [in] enable Teaching mode enable flag: 0 - disabled, 1 - enabled.
4 * @param [in] mode Teaching method selection: 0 - current loop.
5 * @return Error code.
6 **/
7ARMErrorCode SetTeachMode(uint8_t enable, uint8_t mode = 0);
3.1.54. Set current loop drag teach debug test case ( only for use with JK2.0 robotic arm )
1#include <iostream>
2#include "humanorid_sdk.h"
3
4int main() {
5 // 1. Establish communication
6 RobotTool tool;
7 if (tool.RPC("192.168.58.1", 8081) != Success) {
8 std::cout << "RPC Connection failed" << std::endl;
9 return -1;
10 }
11
12 // 2. Create single-arm instance (7 axes)
13SingleRobot robot(ART7_R7, LeftArm);
14ARMErrorCode rtnCode;
15
16// 3. Set installation angle
17double yangle = -90;
18double zangle = 90;
19rtnCode = robot.SetRobotInstallAngle(yangle, zangle); // Note that the installation angle varies depending on the robotic arm model or whether it is a left or right arm, and the installation angle should be determined based on the actual situation.
20if (rtnCode != ARMErrorCode::Success)
21{
22 Std::cout << "Installation angle setting failed" << std::endl;
23}
24
25// 4. Set load mass and center of mass coordinates
26double messCenter[3] = {0.0, 0.0, 0.0};
27rtnCode = robot.SetLoadcoord(1, 0.0, messCenter);
28if (rtnCode != ARMErrorCode::Success)
29{
30 Std::cout << "Load mass and center of mass coordinates setting failed" << std::endl;
31}
32
33// 5. Joint soft limit protection on
34double limitNegative[7] = {-172.0, -112.0, -172.0, -77.0, -172.0, -72.0, -87.0};
35double limitPositive[7] = {172.0, 112.0, 172.0, 112.0, 172.0, 72.0, 87.0};
36rtnCode = robot.SetJointSoftLimitOnOff(1);
37if (rtnCode != ARMErrorCode::Success)
38{
39 Std::cout << "Failed to enable joint soft limit protection" << std::endl;
40}
41
42 // 6. Current loop drag function on
43rtnCode = robot.SetTeachMode(1);
44if (rtnCode != ARMErrorCode::Success)
45{
46 Std::cout << "Failed to enable current loop drag" << std::endl;
47}
48
49 // 6. Current loop drag function on
50rtnCode = robot.SetTeachMode(0);
51if (rtnCode != ARMErrorCode::Success)
52{
53 Std::cout << "Failed to disable current loop drag" << std::endl;
54}
55
56 // 7. Close communication
57 tool.CloseRPC();
58 return 0;
59}
3.1.55. Set Joint Torque Force Sensor Drag Teaching ( Only JK2.0 Robotic Arm Use )
1/**
2* @brief Enables or disables joint torque sensor-based drag teaching.
3* @param [in] enable Drag teaching toggle: 0 = disabled, 1 = enabled.
4* @param [in] mode Drag teaching method selection: 0 = torque sensor.
5* @return Error code.
6**/
7ARMErrorCode SetJointSensorTeachMode(uint8_t enable, uint8_t mode=0);
3.1.56. Get whether in drag-teaching mode(OnlyJK2.0robot arm uses)
1/**
2* @brief Checks whether the system is in drag-teaching mode.
3* @param [out] mode Flag indicating drag mode: 0 - not in drag mode, 1 - in drag mode.
4* @return Error code.
5**/
6ARMErrorCode IsInDragTeach(uint8_t& mode);
3.1.57. Enable collision detection(onlyJK2.0for robotic arm use)
1/**
2* @brief Sets collision detection
3* @param [in] enable Collision detection enable flag: 0 - disabled, 1 - enabled
4* @param [in] mode Collision detection method selection: 0 - current loop
5* @return Error code
6**/
7ARMErrorCode SetCollisionDetectionMode(uint8_t enable, uint8_t mode);
3.1.58. Set Collision Level ( Only JK2.0 Robotic Arm Uses )
1/**
2* @brief Sets the anti-collision level
3* @param [in] level Anti-collision level, range: [1–10]
4* @return Error code
5**/
6ARMErrorCode SetAnticollision(uint8_t level[7]);
3.1.59. Set Collision Response Strategy(OnlyJK2.0Robot Arm Use)
1/**
2* @brief Sets the collision response strategy.
3* @param [in] strategy Collision response strategy: 0 - stop, 1 - gravity torque mode.
4* @return Error code.
5**/
6ARMErrorCode SetCollisionStrategy(uint8_t strategy);
3.1.60. Set post-collision policy debug test case(onlyJK2.0robotic arm use)
1#include <iostream>
2#include "humanorid_sdk.h"
3
4int main() {
5 // 1. Establish communication
6 RobotTool tool;
7 if (tool.RPC("192.168.58.1", 8081) != Success) {
8 std::cout << "RPC Connection failed" << std::endl;
9 return -1;
10 }
11
12 // 2. Create single-arm instance (7 axis)
13SingleRobot robot(ART7_R7, LeftArm);
14ARMErrorCode rtnCode;
15
16// 3. Set installation angle
17double yangle = -90;
18double zangle = 90;
19rtnCode = robot.SetRobotInstallAngle(yangle, zangle); // Note that the installation angle should be determined based on the actual situation, as robotic arm models may differ or the left and right arms may have different installation angles.
20if (rtnCode != ARMErrorCode::Success)
21{
22 std::cout << "Installation angle setting failed" << std::endl;
23return -1;
24}
25
26// 4. Enable collision detection
27rtnCode = robot.SetCollisionDetectionMode(1, 0);
28if (rtnCode != ARMErrorCode::Success)
29{
30 std::cout << "Failed to enable collision detection" << std::endl;
31return -1;
32}
33
34// 5. Set collision level and strategy
35uint8_t level[7] = {5, 5, 5, 5, 5, 5, 5}; // Collision level
36rtnCode = robot.SetAnticollision(level);
37if (rtnCode != ARMErrorCode::Success)
38{
39 std::cout << "Collision level setting failed" << std::endl;
40return -1;
41}
42rtnCode = robot.SetCollisionStrategy(1); // Collision strategy: gravity torque
43if (rtnCode != ARMErrorCode::Success)
44{
45 std::cout << "Collision strategy setting failed" << std::endl;
46return -1;
47}
48
49// 6. Joint space motion
50double target[7] = {10, 20, 0, 0, 0, 0, 0};
51char err_msg[1024];
52rtnCode = robot.MoveJ(target, 30.0, 20.0, 0, err_msg);
53if (rtnCode != ARMErrorCode::Success)
54{
55 std::cout << "MoveJMotion failed" << std::endl;
56return -1;
57}
58
59 // 7. Disable collision detection
60rtnCode = robot.SetCollisionDetectionMode(0, 0);
61if (rtnCode != ARMErrorCode::Success)
62{
63 std::cout << "Failed to disable collision detection" << std::endl;
64return -1;
65}
66
67 // 7. Close communication
68 tool.CloseRPC();
69 return 0;
70}
3.1.61. Set Joint Torque Sensor Zero Calibration ( Only JK2.0 Robotic Arm Use )
1/**
2* @brief Sets the zero-point calibration for the joint torque sensor.
3* @param [in] joint_val Joint angles, unit: deg
4* @param [in] speed Speed percentage
5* @return Error code
6**/
7ARMErrorCode SetJointSensorZero(double joint_val[7], double speed);
3.1.62. Set Robot Installation Angle(OnlyJK2.0Robotic Arm Use)
1/**
2* @brief Sets the robot installation angle
3* @param [in] yangle Tilt angle, unit: deg
4* @param [in] zangle Rotation angle, unit: deg
5* @return Error code
6**/
7ARMErrorCode SetRobotInstallAngle(double yangle, double zangle);
3.1.63. Obtain robot installation angle(OnlyJK2.0manipulator use)
1/**
2* @brief Gets the robot installation angle
3* @param [in] yangle Tilt angle, unit: deg
4* @param [in] zangle Rotation angle, unit: deg
5* @return Error code
6**/
7ARMErrorCode GetRobotInstallAngle(double& yangle, double& zangle);
3.1.64. Obtain the current end-effector flange pose
1/**
2* @brief Gets the current tool flange pose.
3* @param [in] jointPos Current robotic arm joint positions, in degrees.
4* @param [out] fLangePos [Tool flange position, orientation, and arm angle], in units of [mm, degrees, degrees].
5* @return Error code.
6**/
7ARMErrorCode GetActualToolFlangePose(double jointPos[7], double fLangePos[7]);
3.1.65. Set the robotic arm’s positive limit
1/**
2* @brief Sets the positive limit for the robotic arm.
3* @param [in] limitPositive Positive joint limits, in degrees.
4* @return Error code.
5**/
6ARMErrorCode SetLimitPositive(double limitPositive[7]);
3.1.66. Set the mechanical arm’s negative limit
1/**
2* @brief Sets the negative limit for the robotic arm
3* @param [in] limitNegative Negative joint limits, in degrees
4* @return Error code
5**/
6ARMErrorCode SetLimitNegative(double limitNegative[7]);
3.1.67. Obtain joint soft limit angles
1/**
2* @brief Gets the soft limit angles of the robotic arm joints.
3* @param [out] limitNegative Negative joint limits, in degrees.
4* @param [out] limitPositive Positive joint limits, in degrees.
5* @return Error code.
6**/
7ARMErrorCode GetJointSoftLimitDeg(double limitNegative[7], double limitPositive[7]);
3.1.68. Retrieve the robotic arm firmware version
1/**
2* @brief Gets the robotic arm firmware version.
3* @param [out] driver1version Firmware version of driver 1.
4* @param [out] driver2version Firmware version of driver 2.
5* @param [out] driver3version Firmware version of driver 3.
6* @param [out] driver4version Firmware version of driver 4.
7* @param [out] driver5version Firmware version of driver 5.
8* @param [out] driver6version Firmware version of driver 6.
9* @param [out] driver7version Firmware version of driver 7.
10* @return Error code.
11**/
12ARMErrorCode GetFirmwareVersion(char driver1version[128], char driver2version[128], char driver3version[128], char driver4version[128], char driver5version[128], char driver6version[128], char driver7version[128]);
3.1.69. Robot Control Authority Settings
1/**
2* @brief Robot Control Authority Setting
3* @param [in] controlMode 0-SDKControl 1-ROS2Control
4* @return Error Code
5**/
6ARMErrorCode SetControlAuthority(uint8_t controlMode);
3.1.70. Acceleration Smooth Start
1/**
2* @brief Acceleration Smoothing Enabled
3* @return Error Code
4**/
5ARMErrorCode AccSmoothStart();
3.1.71. Acceleration smoothing disabled
1/**
2* @brief Acceleration Smoothing Off
3* @return Error Code
4**/
5ARMErrorCode AccSmoothEnd();
3.1.72. Specify joint to enter drag / position mode
1/**
2* @brief Specify joint to enter drag / position mode
3* @param [in] joint_id joint ID, range :1~7
4* @param [in] flag 0- position mode, 1- drag mode
5* @return error code
6**/
7ARMErrorCode SetJointDrag(uint8_t joint_id, uint8_t flag);
3.1.73. Set Workpiece Coordinate System
1/**
2* @brief Set Workpiece Coordinate System
3* @param [in] corrd Pose of Workpiece Coordinate System, Unit:[mm, deg]
4* @return Error Code
5**/
6ARMErrorCode SetWObjCorrd(double corrd[6]);
3.1.74. Set Joint Torque Sensor Drag Teaching Parameters
1/**
2* @brief Set Joint Torque Sensor Drag Teaching Parameters
3* @param [in] drag_level 0-Soft, 1-Medium, 2-Hard
4* @return Error Code
5**/
6ARMErrorCode SetJointSensorTeachModeParam(uint8_t drag_level);
3.1.75. Get Joint Actuator Temperature
1/**
2* @brief Get Joint Actuator Temperature
3* @param [out] temperature Joint actuator temperature, unit: °C
4* @return Error code
5**/
6ARMErrorCode GetJointDriverTemperature(double temperature[7]);
3.1.76. Return to Safe Point
1/**
2* @brief Return to Safe Point
3* @param [in] safePoint Safe Point Joint Position, Unit: : deg
4* @param [in] velocity Speed Percentage, Range: [0, 100]
5* @param [in] acc Acceleration Percentage, Range: [0, 100]
6* @return Error Code
7**/
8ARMErrorCode MoveToSafePoint(double safePoint[7], double velocity, double acc);
3.1.77. Force Sensor Activated
1/**
2* @brief Force Sensor Activated
3* @param [in] onOff 0-Reset 1-Activate
4* @return Error Code
5**/
6ARMErrorCode FT_Activate(uint8_t onOff);
3.1.78. Force Sensor Zeroing
1/**
2* @brief Force Sensor Zero Calibration
3* @param [in] joints Zero Calibration Joint Position, Unit: : deg
4* @param [in] velocity Speed Percentage, Range: [0, 100]
5* @param [in] acceleration Acceleration Percentage, Range: [0, 100]
6* @return Error Code
7**/
8ARMErrorCode FT_SetZero(double joints[7], double velocity, double acceleration);
3.1.79. Force Sensor Load Identification
1/**
2* @brief Force sensor load identification
3* @param [in] joints Load identification points, unit: deg
4* @param [in] velocity Speed percentage, range:[0, 100]
5* @param [in] acceleration Acceleration percentage, range:[0, 100]
6* @return Error code
7**/
8ARMErrorCode FT_PdCogIden(double joints[3], double velocity, double acceleration);
3.1.80. Force Sensor Safety Inspection
1/**
2* @brief Force Sensor Safety Detection
3* @param [in] onOff Safety Detection Switch
4* @param [in] safeTime Safety Detection Time, Unit: ms
5* @return Error Code
6**/
7ARMErrorCode SetForceSensorSafetyInspection(uint8_t onOff, uint8_t safeTime);
3.1.81. Force Sensor Safety Detection Trigger Strategy
1/**
2* @brief Force Sensor Safety Detection Trigger Strategy
3* @param [in] tragger Safety Detection Trigger Strategy 0-Stop 1-Gravity Torque Mode
4* @return Error Code
5**/
6ARMErrorCode SetForceSensorSafetyTriggerStrategy(uint8_t tragger);
3.1.82. Set Force Sensor Coordinate System
1/**
2* @brief Set Force Sensor Coordinate System
3* @param [in] corrd Sensor coordinate system pose, unit:[mm, deg]
4* @return Error code
5**/
6ARMErrorCode SetForceSensorCorrd(double corrd[6]);
3.1.83. Set Force Sensor Safety Detection Threshold
1/**
2* @brief Set Force Sensor Safety Detection Threshold
3* @param [in] threshold Sensor Detection Threshold, Unit:
4* @return Error Code
5**/
6ARMErrorCode SetForceSensorThreshold(double threshold[6]);
3.1.84. Weak load identification initialization settings
1/**
2* @brief No force load identification initialization settings
3* @param [in] onOff Load identification switch,0-Off,1-On
4* @param [in] forceSource Source of force,0-Joint current,1-Torque sensor
5* @param [in] loadFlag 0-No load,1-With load
6* @return Error code
7**/
8ARMErrorCode LoadIdentifyInit(uint8_t onOff, uint8_t forceSource, uint8_t loadFlag);
3.1.85. Unpowered Load Identification Main Program
1/**
2* @brief No-force load identification main program
3* @param [in] joints Load identification point,unit: deg
4* @param [in] velocity Speed percentage,range:[0, 100]
5* @param [in] acceleration Acceleration percentage,range:[0, 100]
6* @param [in] loadFlag 0-No load,1-With load
7* @return Error code
8**/
9ARMErrorCode LoadIdentifyMain(double joints[9][7], double velocity, double acceleration, uint8_t loadFlag);
3.1.86. Get powerless load identification result
1/**
2* @brief obtain forceless payload identification result
3* @param [in] result payload identification result,result[0]: payload mass(kg) result[1]: payload centroidx(mm) result[2]: payload centroidy(mm) result[3]: payload centroidz(mm)
4* @return error code
5**/
6ARMErrorCode LoadIdentifyGetResult(double result[4]);
3.1.87. Activate gripper
1/**
2* @brief Activate gripper
3* @return Error code
4**/
5ARMErrorCode ActGripper();
3.1.88. Control gripper movement
1/**
2* @brief Control gripper movement
3* @param [in] position Position percentage
4* @param [in] speed Speed percentage
5* @param [in] force Force percentage
6* @return Error code
7**/
8ARMErrorCode MoveGripper(double position, double speed, double force);
3.1.89. Get whether gripper motion is completed
1/**
2* @brief Get whether gripper movement is completed
3* @param [out] motiontate 0-Moving,1-Movement completed
4* @return Error code
5**/
6ARMErrorCode GetGripperMotionDone(uint8_t &motionState);
3.1.90. Get Gripper Activation Status
1/**
2* @brief Get gripper activation status
3* @param [out] act 0-Not activated,1-Activated
4* @return Error code
5**/
6ARMErrorCode GetGripperActivateStatus(uint8_t &actState);
3.1.91. Get Gripper Position
1/**
2* @brief Get gripper position
3* @param [out] position Percentage
4* @return Error code
5**/
6ARMErrorCode GetGripperCurPosition(double &position);
3.1.92. Joint Space Impedance Control Enabled
1/**
2* @brief Joint space impedance control enabled
3* @param [in] forceSource 0-joint current 1-torque sensor
4* @param [in] forceThreshold trigger force threshold[30-150], unit: N
5* @param [in] m mass parameter
6* @param [in] b damping parameter
7* @param [in] k stiffness parameter
8* @param [in] maxVel maximum joint velocity
9* @param [in] maxAcc maximum joint acceleration
10* @param [in] maxAng maximum adjustment angle(Add)
11* @param [in] maxTor maximum limit torque(Add)
12* @return error code
13**/
14ARMErrorCode ImpedanceControlJointStart(int forceSource, double forceThreshold[7], double m[7], double b[7], double k[7], double maxVel[7], double maxAcc[7], double maxAng[7], double maxTor[7]);
3.1.93. Joint Space Impedance Control Off
1/**
2* @brief Joint space impedance control disabled
3* @return Error code
4**/
5ARMErrorCode ImpedanceControlJointEnd();
3.1.94. Cartesian Space Impedance Control Enabled
1/**
2* @brief Cartesian space impedance control enabled
3* @param [in] forceSource 0-six-axis force sensor 1-joint current
4* @param [in] forceThreshold trigger force threshold[30-150],unit: N
5* @param [in] m mass parameter
6* @param [in] b damping parameter
7* @param [in] k stiffness parameter
8* @param [in] maxV maximum linear velocity
9* @param [in] maxVA maximum linear acceleration
10* @param [in] maxW maximum angular velocity
11* @param [in] maxWA maximum angular acceleration
12* @param [in] maxDix maximum adjustment distance(Add)
13* @param [in] maxForce maximum force limit(Add)
14* @return error code
15**/
16ARMErrorCode ImpedanceControlCartStart(int forceSource, double forceThreshold[7], double m[7], double b[7], double k[7], double maxV, double maxVA, double maxW, double maxWA, double maxDix[6], double maxForce[6]);
3.1.95. Cartesian Space Impedance Control Off
1/**
2* @brief Cartesian space impedance control disabled
3* @return Error code
4**/
5ARMErrorCode ImpedanceControlCartEnd();
3.1.96. Variable Parameter Admittance Control Enabled
1/**
2* @brief Variable parameter admittance control enabled
3* @param [in] openDir Admittance function enabled direction[x y z rx ry rz] (0-not enabled,1-enabled) (rx ry rzAdmittance function temporarily not enabled,parameters are0)
4* @param [in] targetForce Desired force
5* @param [in] m Mass parameter
6* @param [in] b Damping parameter
7* @param [in] k Stiffness parameter
8* @param [in] maxDis Maximum adjustment distance, Range: (0, 1000],unit: mm
9* @param [in] maxAng Maximum adjustment angle, Range: (0, 90],unit: deg
10* @return Error code
11**/
12ARMErrorCode AdmittanceControlStart(uint8_t openDir[6], double targetForce[6], double m[6], double b[6], double k[6], double maxDis, double maxAng);
3.1.97. Variable Parameter Admittance Control Off
1/**
2* @brief Variable parameter admittance control disabled
3* @return Error code
4**/
5ARMErrorCode AdmittanceControlEnd();
3.1.98. Set Variable-Parameter Admittance Control Parameters
1/**
2* @brief Set variable parameter admittance control parameters
3* @param [in] m Mass parameter
4* @param [in] b Damping parameter
5* @param [in] k Stiffness parameter
6* @return Error code
7**/
8ARMErrorCode SetAdmittanceControlParam(double m[6], double b[6], double k[6]);
3.1.99. Contact Detection Enabled
1/**
2* @brief Contact detection enabled
3* @param [in] minVal Contact force lower limit(Relative value), range: (0 50](x, y, z), (0, 3](rx, ry, rz)
4* @param [in] maxVal Contact force upper limit(Relative value), range: (0 50](x, y, z), (0, 3](rx, ry, rz)
5* @return Error code
6**/
7ARMErrorCode ForceSensorContactDetectStart(double minVal[6], double maxVal[6]);
3.1.100. Contact Detection Off
1/**
2* @brief Contact detection off
3* @return Error code
4**/
5ARMErrorCode ForceSensorContactDetectEnd();
3.1.101. Configure Contact Detection Trigger Policy
1/**
2* @brief Set contact detection trigger strategy
3* @param [in] strategy contact detection strategy,0-Stop 1-Enter gravity torque mode
4* @return Error code
5**/
6ARMErrorCode SetContactDetectStrategy(uint8_t strategy);
3.1.102. Get Contact Detection Trigger Status
1/**
2* @brief Get contact detection trigger status
3* @param [out] state Contact detection status, 0-Not triggered 1-Triggered
4* @return Error code
5**/
6ARMErrorCode GetContactDetectState(uint8_t& state);
3.1.103. Force sensor data zeroing
1/**
2* @brief Force sensor data zeroing
3* @return Error code
4**/
5ARMErrorCode ForceSensorSetZero();
3.1.104. Force sensor data zeroing debug test case
1#include <iostream>
2#include "humanorid_sdk.h"
3
4int main() {
5 // 1. Establish communication
6 RobotTool tool;
7 if (tool.RPC("192.168.58.1", 8081) != Success) {
8 std::cout << "RPC Connection failed" << std::endl;
9 return -1;
10 }
11
12 // 2. Create single-arm instance (7 axis)
13 SingleRobot robot(ART7_R7, SingleArm);
14
15 // 3. Force sensor activation
16ARMErrorCode rtn = robot.FT_Activate(1);
17if (ret == ARMErrorCode::Success)
18{
19 std::cout << "Force sensor activation executed successfully" << std::endl;
20}
21else
22{
23 std::cout << "Force sensor activation execution failed, error code: " << (int)ret << std::endl;
24}
25
26// 4. Force sensor data zeroing
27rtn = robot.ForceSensorSetZero();
28if (ret == ARMErrorCode::Success)
29{
30 std::cout << "Force sensor data zeroing executed successfully" << std::endl;
31}
32else
33{
34 std::cout << "Force sensor data zeroing execution failed, error code: " << (int)ret << std::endl;
35}
36
37 // 5. Force sensor deactivation
38rtn = robot.FT_Activate(0);
39if (ret == ARMErrorCode::Success)
40{
41 std::cout << "Force sensor deactivation executed successfully" << std::endl;
42}
43else
44{
45 std::cout << "Force sensor deactivation execution failed, error code: " << (int)ret << std::endl;
46}
47
48 // 7. Cleanup
49 tool.CloseRPC();
50 return 0;
51}
3.1.105. Acquire the torque feedforward coefficients for each joint
1/**
2* @brief Get the torque feedforward coefficients for each joint
3* @param [out] gain Torque feedforward coefficients for each axis(0,2]
4* @return Error code
5**/
6ARMErrorCode GetForceForwardFeedGain(double gain);
3.1.106. Torque feedforward on and off
1/**
2* @brief Torque feedforward on and off
3* @param [in] enable Torque feedforward switch, 0-Torque feedforward off 1-Torque feedforward on
4* @param [in] gain Torque feedforward coefficient for each axis(0,2]
5* @return Error code
6**/
7ARMErrorCode SetForceForwardFeed(uint8_t enable,double gain);
3.1.107. Torque feedforward on and off code example
1#include <iostream>
2#include "humanorid_sdk.h"
3
4int main() {
5 // 1. Establish communication
6 RobotTool tool;
7 if (tool.RPC("192.168.58.1", 8081) != Success) {
8 std::cout << "RPC Connection failed" << std::endl;
9 return -1;
10 }
11
12 // 2. Create single-arm instance (axis)7Torque feedforward enabled
13 SingleRobot robot(ART7_R7, SingleArm);
14
15 // 3. Torque feedforward enable executed successfully
16 double gain_set[7] = {1.0,1.0, 1.0, 1.0, 1.0, 1.0, 1.0};
17 ARMErrorCode rtn = robot.SetForceForwardFeed(1, gain_set);
18 if (ret == ARMErrorCode::Success)
19 {
20 std::cout << "Torque feedforward enable execution failed, error code" << std::endl;
21 }
22 else
23 {
24 std::cout << "Torque feedforward coefficient retrieval: " << (int)ret << std::endl;
25 }
26
27 // 4. Retrieval of torque feedforward coefficient executed successfully
28 double gain_get[7] = {0};
29 rtn = robot.GetForceForwardFeedGain(gain_get);
30 if (ret == ARMErrorCode::Success)
31 {
32 std::cout << "Torque feedforward coefficient" << std::endl;
33 std::cout << "Retrieval of torque feedforward coefficient execution failed, error code: " << gain_get[0] << “,” << gain_get[1] << “,”
34 gain_get[2] << “,” << gain_get[3] << “,” << gain_get[4] << “,” << gain_get[5] << “,”
35 gain_get[6] << std::endl;
36 }
37 else
38 {
39 std::cout << "Torque feedforward disabled: " << (int)ret << std::endl;
40 }
41
42 // 5. Torque feedforward disable executed successfully
43 rtn = robot.SetForceForwardFeed(1, gain_set);
44 if (ret == ARMErrorCode::Success)
45 {
46 std::cout << "Torque feedforward disable execution failed, error code" << std::endl;
47 }
48 else
49 {
50 std::cout << "Cleanup: " << (int)ret << std::endl;
51 }
52
53 // 7.
3.1.108. Retrieve the specified joint movement speed
1/**
2* @brief Get the specified joint motion speed
3* @param [in] joint_id Joint number[1, 7]
4* @param [out] speed Joint speed, unit°/s (0,150|180]
5* @return Error code
6**/
7ARMErrorCode GetSingleAxisSpeed(uint8_t joint_id,double speed);
3.1.109. Get specified joint motion acceleration
1/**
2* @brief Retrieve the specified joint motion acceleration
3* @param [in] joint_id Joint number[1, 7]
4* @param [out] acc Joint acceleration, unit°/s^2 (0,300|360]
5* @return Error code
6**/
7ARMErrorCode GetSingleAxisAcc(uint8_t joint_id,double acc);
3.1.110. Set the specified joint movement speed
1/**
2* @brief Set the specified joint motion speed
3* @param [in] joint_id Joint number[1, 7]
4* @param [in] speed Joint speed to be set, unit°/s; 1 2joint;maximum speed150, 3-7joint maximum speed180 (0,150|180]
5* @return error code
6**/
7ARMErrorCode SetSingleAxisSpeed(uint8_t joint_id,double speed);
3.1.111. Set the specified joint motion acceleration
1/**
2* @brief Set the specified joint motion acceleration
3* @param [in] joint_id Joint number[1, 7]
4* @param [in] acc Acceleration to be set for the joint, unit° (0,300|360]
5* @return Error code
6**/
7ARMErrorCode SetSingleAxisAcc(uint8_t joint_id,double acc);
3.1.112. Setting the specified joint motion acceleration code example
1#include <iostream>
2#include "humanorid_sdk.h"
3
4int main() {
5 // 1. establish communication
6 RobotTool tool;
7 if (tool.RPC("192.168.58.1", 8081) != Success) {
8 std::cout << "RPC connection failed" << std::endl;
9 return -1;
10 }
11
12 // 2. create single-arm instance (axis)
13 SingleRobot robot(ART7_R7, SingleArm);
14
15// 3. get joint movement speed and acceleration
16double speed[7] = {0};
17double acc[7] = {0};
18ARMErrorCode rtn;
19for (uint8_t i = 0; i < 7; i++)
20{
21rtn = robot.GetSingleAxisSpeed(i+1, speed[i]);
22if (rtn != ARMErrorCode::Success)
23{
24std::cout << "failed to get joint speed" << std::endl;
25return -1;
26}
27rtn = robot.GetSingleAxisAcc(i+1, acc[i]);
28if (rtn != ARMErrorCode::Success)
29{
30std::cout << "failed to get joint acceleration" << std::endl;
31return -1;
32}
33}
34
35// 4. set joint movement speed and acceleration
36for (uint8_t i = 0; i < 7; i++)
37{
38rtn = robot.SetSingleAxisSpeed(i+1, speed[i]);
39if (rtn != ARMErrorCode::Success)
40{
41std::cout << "failed to set joint speed" << std::endl;
42return -1;
43}
44rtn = robot.SetSingleAxisAcc(i+1, acc[i]);
45if (rtn != ARMErrorCode::Success)
46{
47std::cout << "failed to set joint acceleration" << std::endl;
48return -1;
49}
50}
51 // 5. cleanup
52 tool.CloseRPC();
53 return 0;
54}
3.1.113. Acquire the zero point parameters of the torque sensors for each axis of the robotic arm
1/**
2* @brief Acquire the zero point parameters of the torque sensors for each axis of the robotic arm
3* @param [out] zero_param Zero point parameters of the robotic arm torque sensors
4* @return Error code
5**/
6ARMErrorCode GetJointSensorZeroParam(double zero_param);
3.1.114. Acquire mechanical arm each axis torque sensor zero point parameter code example
1#include <iostream>
2#include "humanorid_sdk.h"
3
4int main() {
5 // 1. Establish communication
6 RobotTool tool;
7 if (tool.RPC("192.168.58.1", 8081) != Success) {
8 std::cout << "RPC Connection failed" << std::endl;
9 return -1;
10 }
11
12 // 2. Create single-arm instance (7axis)
13 SingleRobot robot(ART7_R7, SingleArm);
14
15// 3. Get torque sensor zero point parameters
16double zero_param[7] = {0};
17ARMErrorCode rtn = robot.GetJointSensorZeroParam(zero_param);
18if (rtn == ARMErrorCode::Success)
19{
20 std::cout << "Execute getting torque sensor zero point parameters successfully" << std::endl;
21 std::cout << "Torque sensor zero point parameters: " << zero_param[0] << “,” << zero_param[1] << “,”
22 zero_param[2] << “,” << zero_param[3] << “,” << zero_param[4] << “,” <<
23zero_param[5] << “,” << zero_param[6] << std::endl;
24}
25else
26{
27 std::cout << "Executing get torque sensor zero point parameters failed, error code: " << (int)ret << std::endl;
28}
29
30 // 4. Cleanup
31 tool.CloseRPC();
32 return 0;
33}
3.1.115. Get collision detection enable flag
1/**
2* @brief get collision detection enable flag
3* @param [out] openState 0-collision detection not enabled 1-collision detection enabled
4* @return error code
5**/
6ARMErrorCode GetCollisionOpenState(double openState);
3.1.116. Get collision detection enable flag code example
1#include <iostream>
2#include "humanorid_sdk.h"
3
4int main() {
5 // 1. establish communication
6 RobotTool tool;
7 if (tool.RPC("192.168.58.1", 8081) != Success) {
8 std::cout << "RPC connection failed" << std::endl;
9 return -1;
10 }
11
12 // 2. create single-arm instance (axis)
13 SingleRobot robot(ART7_R7, SingleArm);
14
15// 3. get collision detection enable flag
16uint8_t openState;
17ARMErrorCode rtn = robot.GetCollisionOpenState(openState);
18if (rtn == ARMErrorCode::Success)
19{
20 std::cout << "get collision detection enable flag executed successfully" << std::endl;
21 std::cout << "collision detection enable flag: " << (int)openState << std::endl;
22}
23else
24{
25 std::cout << "get collision detection enable flag execution failed, error code: " << (int)ret << std::endl;
26}
27
28 // 4. clean up
29 tool.CloseRPC();
30 return 0;
31}
3.1.117. Get the current system time of the controller
1/**
2* @brief Get the current system time of the controller
3* @param [out] sysTime System Time, Format: year:month:data-hour:minute:second
4* @return Error Code
5**/
6ARMErrorCode GetControllerSystemTime(std::string sysTime);
3.1.118. Get controller current system time code example
1#include <iostream>
2#include <string>
3#include "humanorid_sdk.h"
4
5int main() {
6 // 1. establish communication
7 RobotTool tool;
8 if (tool.RPC("192.168.58.1", 8081) != Success) {
9 std::cout << "RPC connection failed" << std::endl;
10 return -1;
11 }
12
13// 2. get controller system time
14std::string sysTime;
15rtn = tool.GetControllerSystemTime(sysTime);
16if (rtn == ARMErrorCode::Success)
17{
18 std::cout << "execute get controller system time successfully" << std::endl;
19 std::cout << "system time: " << sysTime << std::endl;
20}
21else
22{
23 std::cout << "execute get controller system time failed, error code: " << (int)ret << std::endl;
24}
25
26 // 4. clean up
27 tool.CloseRPC();
28 return 0;
29}
3.1.119. Dexterous hand control initialization
1/**
2* @brief Dexterous hand control initialization.InitHand Only performs local registration, does not initiate network requests, therefore the return of Success does not represent that the device is online; the online status of the device is confirmed by subsequent ActHand and GetHandState .
3* @param [in] backend The backend shared by both hands; returns empty for TCP_ConnectErr. Both hands must pass the same instance. Non-empty
4* @param [in] config this hand's configuration: side / slave_id / hand_id / model.model.valid()
5* @param [in] arm_controllezr_id The controller index of the arm where this hand is located, obtained from RobotTool::GetControllerId ; for a single arm it is usually 0, for dual arms left is 0 / right is 1.
6* @param [in] errMsg Reason for failure, can be printed directly.
7* @return TCP_ConnectErr Not called InitHand, or the backend is not connected.
8 SDKServer_RunErr Server rejected (common status code 4); check the hand power supply, 485, end plate topology and hand_id.
9 CMD_RunErr Execution failed on this side (transmission or parsing exception).
10**/
11ARMErrorCode InitHand(std::shared_ptr<DexHandTcpBackend> backend,const HandConfig& config, uint8_t arm_controller_id, char[1024] errMsg);
3.1.120. Activate __PROTECT_X__
1/**
2* @brief Activate the dexterous hand, enable the hand motors. The interface uses config.hand_id as the addressing parameter, so both hands must be configured with the correct hand_id.
3* @param [out] errMsg Reason for failure can be printed directly.
4* @return TCP_ConnectErr Not calling InitHand, or the backend is not connected.
5 SDKServer_RunErr Server rejection (common status codes 4); check the power supply of the hand, 485, end plate topology, and hand_id.
6 CMD_RunErr Execution failed on this side (transmission or parsing exception).
7 CMD_OverTime Response timeout or incomplete.
8**/
9ARMErrorCode ActHand(char[1024] errMsg);
3.1.121. Reset dexterous hand
1/**
2* @brief Reset the dexterous hand, disabling the hand motors. After resetting, motion commands will be rejected by the server, and it needs to be ActHand again to recover.
3* @param [out] errMsg The reason for the failure can be printed directly.
4* @return TCP_ConnectErr Not called InitHand, or the backend is not connected.
5 SDKServer_RunErr Server rejected.
6 CMD_RunErr Execution failed on this side.
7**/
8ARMErrorCode ResetHand(char[1024] errMsg);
3.1.122. Clear this hand fault
1/**
2* @brief Clear the current fault. Clearing is the fault flag, does not fix mechanical jamming, step loss, or motor damage.
3* @param [out] errMsg Reason for failure, can be printed directly.
4* @return TCP_ConnectErr Not called InitHand, or backend not connected.
5 SDKServer_RunErr Server rejected.
6 CMD_RunErr Execution failed on this side.
7 CMD_OverTime Response timed out or incomplete.
8**/
9ARMErrorCode ClearError(char[1024] errMsg);
3.1.123. Control a single joint
1/**
2* @brief controls a single joint. The interface is mapped to the protocol slots according to the model table, generating mask = 1 << slot, with each of pos/speed/force containing only 1 elements.
3* @param [in] finger Finger numbers: 0 thumb, 1 index finger, 2 middle finger, 3 ring finger, 4 little finger. [0, 4]
4* @param [in] joint Finger number: Joint number; O6 thumb has 2 joints, while the rest of the fingers have 1 joints each. For the thumb, [0,1]; for the others, it's the target position; smaller values indicate bending, larger values indicate straightening. [0, 255]
5* @param [in] speed Target speed percentage. [0, 100]
6* @param [in] force Target force percentage. [0, 100]
7* @param [out] errMsg Reason for failure, can be printed directly.
8* @return InvalidInput_OutOfRange If the finger / joint exceeds limits, the semantic layer will directly reject and send zero.
9 TCP_ConnectErr Not called InitHand, or the backend is not connected.
10 SDKServer_RunErr Server refused (common status codes 5: hand not activated, disabled, or feedback not ready).
11 CMD_RunErr Execution failed on this side.
12 CMD_OverTime Response timeout or incomplete.
13**/
14ARMErrorCode MoveMotor(uint8_t finger, int joint, double pos, double speed, double force, char[1024] errMsg);
3.1.124. control the entire finger
1/**
2* @brief controls the entire finger. pos/speed/force 's length must be equal to the number of joints in the finger, passed in by joint number; internally, the interface compresses it in ascending slot order into mask and three-segment arrays.
3* @param [in] finger Finger numbers: 0 thumb, 1 index finger, 2 middle finger, 3 ring finger, 4 little finger. [0, 4]
4* @param [in] pos Target positions for each joint. Length = jointsOfFinger(finger)
5* @param [in] speed Target speeds for each joint. Length = jointsOfFinger(finger)
6* @param [in] force Target forces for each joint. Length = jointsOfFinger(finger)
7* @param [in] len Array length, which must be equal to the number of joints in the finger. 2 (thumb) / 1 (the rest)
8* @param [out] errMsg Reason for failure, can be printed directly.
9* @return InvalidInput_Nullptr pos/speed/force Null pointer exists.
10 InvalidInput_OutOfRange Finger out of bounds, or array length not equal to the number of joints; sent under zero.
11 TCP_ConnectErr Not called InitHand, or backend not connected.
12 SDKServer_RunErr Server refused.
13 CMD_RunErr Execution failed on this side.
14 CMD_OverTime Response timed out or was incomplete.
15**/
16ARMErrorCode MoveFinger(uint8_t finger, double pos, double speed, double force, int len, char[1024] errMsg);
3.1.125. Control all joints
1/**
2* @brief controls all joints. len must be equal to model.motor_count; the array is sorted in ascending order by non-reserved slots, and the interface internally generates mask and skips reserved slots. O6 of motor_count=6, mask=0x003F.
3* @param [in] pos target positions for each joint. Length = jointsOfFinger(finger)
4* @param [in] speed target velocities for each joint. Length = jointsOfFinger(finger)
5* @param [in] force target forces for each joint. Length = jointsOfFinger(finger)
6* @param [in] len the length of the array, must be equal to the number of finger joints. 2 (thumb) / 1 (the rest)
7* @param [out] errMsg reason for failure, can be printed directly.
8* @return InvalidInput_Nullptr pos/speed/force null pointer exists.
9 InvalidInput_OutOfRange len <= 0 or len is not equal to motor_count; sent below zero.
10 TCP_ConnectErr did not call InitHand or the backend is not connected.
11 SDKServer_RunErr server rejected (common status code 5).
12 CMD_RunErr execution failed on this side.
13 CMD_OverTime response timeout or incomplete.
14**/
15ARMErrorCode MoveAllFingers(double pos, double speed, double force, int len, char[1024] errMsg);
3.1.126. Read the latest status snapshot of this hand
1/**
2* @brief Read the latest status snapshot of this hand
3* @param [out] state status snapshot; stamp_ns==0 indicates that no data was retrieved.
4* @param [out] errMsg Reason for failure, can be printed directly.
5* @return CMD_OverTime Status not obtained (stamp_ns == 0): query failed, timed out, or response fields did not match.
6 TCP_ConnectErr Did not call InitHand, or the backend is not connected.
7**/
8ARMErrorCode GetHandState(HandState& state, char[1024] errMsg);
3.1.127. Reading the latest status snapshot code example
1#include <chrono>
2#include <iostream>
3#include <memory>
4#include <thread>
5#include "humanorid_sdk.h"
6#include "dexhand/robot_hand.h"
7
8int main() {
9 RobotTool tool;
10 if (tool.RPC("192.168.58.1", 8081) != ARMErrorCode::Success) {
11 std::cout << "RPC Connection failed" << std::endl;
12 return -1;
13 }
14
15 uint8_t arm = 0;
16 if (tool.GetControllerId("left_arm_controller", arm) !=
17 ARMErrorCode::Success) {
18 std::cout << "Not found left_arm_controller" << std::endl;
19 tool.CloseRPC();
20 return -1;
21 }
22
23 auto backend = std::make_shared<dexhand::DexHandTcpBackend>();
24 dexhand::HandConfig cfg;
25 cfg.side = dexhand::HandSide::kLeft;
26 cfg.slave_id = 0;
27 cfg.hand_id = 1;
28 cfg.model = dexhand::makeLinkerHandO6();
29
30 RobotHand hand;
31 char err[1024] = {0};
32 if (hand.InitHand(backend, cfg, arm, err) !=
33 ARMErrorCode::Success ||
34 hand.ActHand(err) != ARMErrorCode::Success) {
35 std::cout << "Initialization/Activation failed:" << err << std::endl;
36 tool.CloseRPC();
37 return -1;
38 }
39
40 const double open[6] = {254, 254, 254, 254, 254, 254};
41 const double speed[6] = {30, 30, 30, 30, 30, 30};
42 const double force[6] = {60, 60, 60, 60, 60, 60};
43 if (hand.MoveAllFingers(open, speed, force, 6, err) !=
44 ARMErrorCode::Success) {
45 std::cout << "Opening failed:" << err << std::endl;
46 tool.CloseRPC();
47 return -1;
48 }
49
50 dexhand::HandState st;
51 for (int i = 0; i < 30; ++i) {
52 if (hand.GetHandState(st, err) == ARMErrorCode::Success &&
53 st.move_done == 1) {
54 break;
55 }
56 std::this_thread::sleep_for(std::chrono::milliseconds(300));
57 }
58 std::cout << "joint_count=" << st.joint_count
59 << " move_done=" << st.move_done << std::endl;
60
61 tool.CloseRPC();
62 return 0;
63}
3.1.128. Speed feedforward function setting
1/**
2* @brief Speed feedforward function setting
3* @param [in] enable 0-Function disabled,1-Function enabled
4* @param [in] axis Axisid 1-Set 0-Not set
5* @return Error code
6**/
7ARMErrorCode SetVelForwardFeed(uint8_t enable, uint8_t axis[7]);
3.1.129. Speed Feedforward Function Setting Debug Test Cases
1#include <iostream>
2#include "humanorid_sdk.h"
3
4int main() {
5 // 1. Establish communication
6 RobotTool tool;
7 if (tool.RPC("192.168.58.1", 8081) != Success) {
8 std::cout << "RPC Connection failed" << std::endl;
9 return -1;
10 }
11
12 // 2. Create single-arm instance (7 axes)
13 SingleRobot robot(ART7_R7, SingleArm);
14
15// 3. Enable 2, 3, 4 axis velocity feedforward
16uint8_t axis[7] = {0, 1, 1, 1, 0, 0, 0};
17ArmErrorCode rtnCode = robot.SetVelForwardFeed(1, axis);
18if (rtnCode != ARMErrorCode::Success)
19{
20std::cout << "Failed to enable velocity feedforward" << std::endl;
21return -1;
22}
23
24 // 4. Disable 2 and 4 axis velocity feedforward
25axis[1] = 0;
26axis[3] = 0;
27rtnCode = robot.SetVelForwardFeed(0, axis);
28if (rtnCode != ARMErrorCode::Success)
29{
30std::cout << "Failed to disable velocity feedforward" << std::endl;
31return -1;
32}
33
34 // 7. Close communication
35 tool.CloseRPC();
36 return 0;
37}
3.2. Introduction to Waist SDK Functions (When the Waist Joint Exists)
3.2.1. Instantiate waist
1/**
2 * @brief Instantiate the waist module
3 **/
4RobotWaist();
3.2.2. Close waist
1/**
2 * @brief Close the waist
3 **/
4~RobotWaist();
3.2.3. Joint-space motion
1/**
2* @brief Joint-space motion
3* @param [in] destJointPos Target joint positions in degrees
4* @param [in] velocity Velocity percentage, range [0–100]
5* @param [in] acceleration Acceleration percentage, range [0–100]; currently not supported
6* @param [out] errMsg Error message string
7* @return Error code
8**/
9ARMErrorCode MoveJ(double* destJointPos, double velocity, double acceleration, char errMsg[1024]);
3.2.4. Stop exercising
1/**
2* @brief Stop motion
3* @return Error code
4**/
5ARMErrorCode StopMotion();
3.2.5. Get current joint position (angle)
1/**
2* @brief Gets the current joint position (angle).
3* @param [out] joint_pos: Joint position in degrees [deg].
4* @return Error code.
5**/
6ARMErrorCode GetActualJointPosDegree(double* joint_pos);
3.2.6. Check whether the motion is completed
1/**
2@brief Query whether the motion is completed.
3* @param [out] state: 0 - not completed, 1 - completed
4* @return Error code
5**/
6ARMErrorCode GetRobotMotionDone(uint8_t& state);
3.2.7. Joint Enable
1/**
2* @brief Enables a joint.
3* @param [in] joint_id Joint index: 0 enables all waist joints; 1, 2, ... enable the corresponding waist joints.
4* @return Error code.
5**/
6ARMErrorCode AxisEnable(int joint_id);
3.2.8. Joint Disable
1/**
2* @brief Disables a joint.
3* @param [in] joint_id Joint index: 0 - disables all waist joints; 1, 2, ... - disables the corresponding waist joint.
4* @return Error code.
5**/
6ARMErrorCode AxisDisable(int joint_id);
3.2.9. Joint Zero Calibration
1/**
2* @brief Perform joint zero calibration
3* @param [in] joint_id Joint index: 0 - enable all waist joints; 1, 2, ... - corresponding waist joints
4* @return Error code
5**/
6ARMErrorCode AxisZeroing(int joint_id);
3.2.10. Clear Controller Errors
1/**
2* @brief Clears controller errors
3* @return Error code
4**/
5ARMErrorCode AxisResetError();
3.2.11. Set waist positive limit
1/**
2* @brief Sets the positive limit for the waist joint.
3* @param [in] limitPositive Positive joint limit, in degrees.
4* @return Error code.
5**/
6ARMErrorCode SetLimitPositive(double* limitPositive);
3.2.12. Set waist negative limit
1/**
2* @brief Sets the negative limit for the waist joint
3* @param [in] limitNegative Negative joint limit, in degrees
4* @return Error code
5**/
6ARMErrorCode SetLimitNegative(double* limitNegative);
3.2.13. Obtain joint soft limit angles
1/**
2* @brief Gets the soft limit angles of the waist joint.
3* @param [out] limitNegative Negative joint limit, in degrees.
4* @param [out] limitPositive Positive joint limit, in degrees.
5* @return Error code.
6**/
7ARMErrorCode GetJointSoftLimitDeg(double* limitNegative, double* limitPositive);
3.2.14. Set Waist Acceleration Percentage
1/**
2* @brief Sets the waist acceleration scale factor.
3* @param [in] scale Acceleration scale factor (as a percentage).
4* @return Error code.
5**/
6ARMErrorCode SetAccScale(double scale);
3.2.15. Set Waist Global Speed Percentage
1/**
2* @brief Sets the global speed percentage of the waist.
3* @param [in] speed Speed percentage.
4* @return Error code.
5**/
6ARMErrorCode SetSpeed(double speed);
3.2.16. Retrieve the robotic arm firmware version
1/**
2* @brief Retrieve Robotic Arm Firmware Version
3* @param [out] driverversion Driver1Firmware Version
4* @return Error Code
5**/
6ARMErrorCode GetFirmwareVersion(char driverversion[][128]);
3.2.17. Get Joint Actuator Temperature
1/**
2* @brief Get Joint Actuator Temperature
3* @param [out] temperature Joint actuator temperature, unit: °C
4* @return Error code
5**/
6ARMErrorCode GetJointDriverTemperature(double* temperature);
3.3. SDK Function Introduction for the Tool Section
3.3.1. Instantiate the utility class
1/**
2* @brief Instantiates the utility class
3**/
4RobotTool();
3.3.2. Close utility class
1/**
2* @brief Destroys the tool class object
3**/
4~RobotTool();
3.3.3. Establish communication with the robot controller
1/**
2 * @brief Establishes communication with the robot controller; default IP is 192.168.58.1
3 **/
4ARMErrorCode RPC(const char *ip, int port);
3.3.4. Disconnect communication with the robot controller
1/**
2 * @brief Closes the communication with the robot controller.
3 * @return Error code
4 */
5ARMErrorCode CloseRPC();
3.3.5. Obtain the communication status between the SDK and the robot
1/**
2 * @brief Gets the communication status between the SDK and the robot.
3 * @param [out] state 0 - Initializing; 1 - Connected; 2 - Disconnected.
4 * @return Error code.
5 */
6ARMErrorCode GetSDKComState(uint8_t& state);
3.3.6. Configure Robot
1/**
2* @brief Sets the robot configuration for the FAIRINO-ARTPlugin upgrade.
3* @param [in] mode 0 - Single-arm, 7-axis configuration; 1 - Dual-arm, 14-axis configuration; 2 - Dual-arm plus waist, 16-axis configuration.
4* @return Error code.
5**/
6ARMErrorCode RobotFrConfig(int mode);
3.3.7. Log Export
1/**
2* @brief Export logs
3* @return Error code
4**/
5ARMErrorCode RobotPackLog();
3.3.8. Data Recording
1/**
2* @brief Data recording
3* @param [in] state 1 - Start recording; 0 - Stop recording and export
4* @return Error code
5**/
6ARMErrorCode RobotRecordData(int state);
3.3.9. SDK Server Deployment
1/**
2* @brief SDK server-side deployment
3* @param [in] filepath Full path of the update package
4* @return Error code
5**/
6ARMErrorCode UpdateSDKServer(std::string filepath);
3.3.10. Retrieve SDK version information
1/**
2 * @brief Gets the SDK version information.
3 * @param [out] version The SDK version number.
4 * @return Error code.
5 **/
6ARMErrorCode GetSDKVersion(std::string& version);
3.3.11. SDK Server Deployment
1/**
2* @brief SDK server-side deployment
3* @param [in] filepath Full path of the update package
4* @return Error code
5**/
6ARMErrorCode UpdateSDKServer(std::string filepath);
3.3.12. Retrieve robot software version information
1/**
2* @brief Retrieves the robot software version information
3* @param [out] pluginVersion Plugin version
4* @param [out] sdkServerVersion SDK server version
5* @return Error code
6**/
7ARMErrorCode GetSoftwareVersion(std::string& pluginVersion, std::string& sdkServerVersion);
3.3.13. Restart Robot Operating System
1/**
2 * @brief Reboot the robot operating system
3 * @return Error code
4 **/
5ARMErrorCode robotSystemReboot();
3.3.14. Shut down Robot Operating System
1/**
2* @brief Shut down the robot operating system
3* @return Error code
4**/
5ARMErrorCode robotSystemShutDown();