15. CNDE

15.1. Configure Robot CNDE Status Feedback

1/**
2* @brief Configure robot CNDE status feedback
3* @param [in] states List of configurable states
4* @param [in] period Status feedback period
5* @return Error code
6*/
7errno_t SetRobotRealtimeStateConfig(std::vector<RobotState> states, int period);

15.2. Add a Robot State to CNDE Status Configuration

1/**
2* @brief Add a robot state to CNDE status configuration
3* @param [in] state Configurable state
4* @return Error code
5*/
6errno_t AddRobotRealtimeState(RobotState state);

15.3. Delete a Robot State from CNDE Status Configuration

1/**
2* @brief Delete a robot state from CNDE status configuration
3* @param [in] state Configurable state
4* @return Error code
5*/
6errno_t DeleteRobotRealtimeState(RobotState state);

15.4. Set CNDE Status Feedback Period

1/**
2* @brief Set CNDE status feedback period
3* @param [in] period Configurable status feedback period 4-1000ms
4* @return Error code
5*/
6errno_t SetRobotRealtimeStatePeriod(int period);

15.5. Get Current CNDE Status Feedback All State Set and Period

1/**
2* @brief Get current CNDE status feedback all state set and period
3* @param [out] states List of configurable states
4* @param [out] period Configurable status feedback period
5* @return Error code
6*/
7errno_t GetRobotRealtimeStateConfig(std::vector<RobotState>& states, int& period);

15.6. CNDE Status Feedback Usage Code Example

 1int PrintRobotPosVelTorque()
 2{
 3    ROBOT_STATE_PKG pkg = {};
 4    FRRobot robot;
 5    int rtn = 0;
 6    robot.LoggerInit();
 7    robot.SetLoggerLevel(1);
 8    std::vector<RobotState> states = { RobotState::JointCurPos, RobotState::TargetJointPos,
 9    RobotState::ToolCurPos, RobotState::TargetTCPPos,
10    RobotState::FlangeCurPos, RobotState::ActualTCPForce,
11    RobotState::ActualJointVel, RobotState::TargetJointVel,
12    RobotState::ActualJointAcc, RobotState::TargetJointAcc,
13    RobotState::TargetTCPCmpSpeed, RobotState::ActualTCPCmpSpeed,
14    RobotState::TargetTCPSpeed, RobotState::ActualTCPSpeed,
15    RobotState::ActualJointTorque, RobotState::JointDriverTorque, RobotState::TargetJointTorque,
16    RobotState::TargetJointCurrent, RobotState::ActualJointCurrent };
17    rtn = robot.SetRobotRealtimeStateConfig(states, 8);
18    rtn = robot.RPC("192.168.58.2");
19    if (rtn != 0)
20    {
21        printf("robot RPC failed\n");
22        return 0;
23    }
24    robot.SetReConnectParam(true, 30000, 500);
25    std::vector<RobotState> getConfigState = {};
26    int getPeriod = 0;
27    rtn = robot.GetRobotRealtimeStateConfig(getConfigState, getPeriod);
28    printf("GetRobotRealtimeStateConfig rtn is %d; period is %d\n", rtn, getPeriod);
29    for (int k = 0; k < getConfigState.size(); k++)
30    {
31        printf("getConfigState include %d\n", getConfigState[k]);
32    }
33    while (true)
34    {
35        robot.GetRobotRealTimeState(&pkg);
36        printf("joint actual pos is %f %f %f %f %f %f\n", pkg.jt_cur_pos[0], pkg.jt_cur_pos[1], pkg.jt_cur_pos[2], pkg.jt_cur_pos[3], pkg.jt_cur_pos[4], pkg.jt_cur_pos[5]);
37        printf("joint target pos is %f %f %f %f %f %f\n", pkg.targetJointPos[0], pkg.targetJointPos[1], pkg.targetJointPos[2], pkg.targetJointPos[3], pkg.targetJointPos[4], pkg.targetJointPos[5]);
38        printf("tool actual pos is %f %f %f %f %f %f\n", pkg.tl_cur_pos[0], pkg.tl_cur_pos[1], pkg.tl_cur_pos[2], pkg.tl_cur_pos[3], pkg.tl_cur_pos[4], pkg.tl_cur_pos[5]);
39        printf("tool target pos is %f %f %f %f %f %f\n", pkg.targetTCPPos[0], pkg.targetTCPPos[1], pkg.targetTCPPos[2], pkg.targetTCPPos[3], pkg.targetTCPPos[4], pkg.targetTCPPos[5]);
40        printf("joint actual velocity is %f %f %f %f %f %f\n", pkg.actual_qd[0], pkg.actual_qd[1], pkg.actual_qd[2], pkg.actual_qd[3], pkg.actual_qd[4], pkg.actual_qd[5]);
41        printf("joint target velocity is %f %f %f %f %f %f\n", pkg.targetJointVel[0], pkg.targetJointVel[1], pkg.targetJointVel[2], pkg.targetJointVel[3], pkg.targetJointVel[4], pkg.targetJointVel[5]);
42        printf("joint actual acc is %f %f %f %f %f %f\n", pkg.actual_qdd[0], pkg.actual_qdd[1], pkg.actual_qdd[2], pkg.actual_qdd[3], pkg.actual_qdd[4], pkg.actual_qdd[5]);
43        printf("joint target acc is %f %f %f %f %f %f\n", pkg.targetJointAcc[0], pkg.targetJointAcc[1], pkg.targetJointAcc[2], pkg.targetJointAcc[3], pkg.targetJointAcc[4], pkg.targetJointAcc[5]);
44        printf("tcp actual cmp speed is %f %f\n", pkg.actual_TCP_CmpSpeed[0], pkg.actual_TCP_CmpSpeed[1]);
45        printf("tcp target cmp speed is %f %f\n", pkg.target_TCP_CmpSpeed[0], pkg.target_TCP_CmpSpeed[1]);
46        printf("tcp actual velocity is %f %f %f %f %f %f\n", pkg.actual_TCP_Speed[0], pkg.actual_TCP_Speed[1], pkg.actual_TCP_Speed[2], pkg.actual_TCP_Speed[3], pkg.actual_TCP_Speed[4], pkg.actual_TCP_Speed[5]);
47        printf("tcp target velocity is %f %f %f %f %f %f\n", pkg.target_TCP_Speed[0], pkg.target_TCP_Speed[1], pkg.target_TCP_Speed[2], pkg.target_TCP_Speed[3], pkg.target_TCP_Speed[4], pkg.target_TCP_Speed[5]);
48        printf("joint actual torque is %f %f %f %f %f %f\n", pkg.jt_cur_tor[0], pkg.jt_cur_tor[1], pkg.jt_cur_tor[2], pkg.jt_cur_tor[3], pkg.jt_cur_tor[4], pkg.jt_cur_tor[5]);
49        printf("joint driver torque is %f %f %f %f %f %f\n", pkg.jointDriverTorque[0], pkg.jointDriverTorque[1], pkg.jointDriverTorque[2], pkg.jointDriverTorque[3], pkg.jointDriverTorque[4], pkg.jointDriverTorque[5]);
50        printf("joint target torque is %f %f %f %f %f %f\n", pkg.jt_tgt_tor[0], pkg.jt_tgt_tor[1], pkg.jt_tgt_tor[2], pkg.jt_tgt_tor[3], pkg.jt_tgt_tor[4], pkg.jt_tgt_tor[5]);
51        printf("joint actual current is %f %f %f %f %f %f\n", pkg.actualJointCurrent[0], pkg.actualJointCurrent[1], pkg.actualJointCurrent[2], pkg.actualJointCurrent[3], pkg.actualJointCurrent[4], pkg.actualJointCurrent[5]);
52        printf("joint target current is %f %f %f %f %f %f\n", pkg.targetJointCurrent[0], pkg.targetJointCurrent[1], pkg.targetJointCurrent[2], pkg.targetJointCurrent[3], pkg.targetJointCurrent[4], pkg.targetJointCurrent[5]);
53        printf("flange actual pos is %f %f %f %f %f %f\n", pkg.flange_cur_pos[0], pkg.flange_cur_pos[1], pkg.flange_cur_pos[2], pkg.flange_cur_pos[3], pkg.flange_cur_pos[4], pkg.flange_cur_pos[5]);
54        printf("tcp actual force is %f %f %f %f %f %f\n\n", pkg.actualTCPForce[0], pkg.actualTCPForce[1], pkg.actualTCPForce[2], pkg.actualTCPForce[3], pkg.actualTCPForce[4], pkg.actualTCPForce[5]);
55        robot.Sleep(300);
56    }
57    robot.Sleep(1000);
58    robot.CloseRPC();
59    robot.Sleep(1000);
60    return 0;
61}