Skip to content

Device Status Service Interface Functionality

FunctionC++ROS
Get common status
Get basic status
Get control mode
Get current scene (gait)
Get docking status
Get joint state information

Get Common Status

C++ Interface

Function: rcClientInterfaceGetCommonStatus

cpp
/**
 * @brief Retrieve the general status information of the controlled robot (main interface for robot status feedback).
 * 
 * This function is used to obtain the general status information of the robot.
 * 
 * @param com_state A pointer to a structure that stores the robot's status information.
 * @return bool Returns `true` if the retrieval is successful; otherwise returns `false`.
 */
bool rcClientInterfaceGetCommonStatus(common::ROBOT_COMMON_STATUS *com_state);

Structure Definition

cpp
typedef struct ROBOT_COMMON_STATUS_{
    int network; //Current network status of the robot
    BODY_POSTURE_STATE belie_or_stand; //Robot's posture: standing or lying
    bool emergency; //Whether the robot is in emergency state
    bool avoidance; //Auto-obstacle avoidance state
    long int heartbeat; //Heartbeat
    float cur_speed; //Current speed
    float cur_height; //Current height
    MC_QUATERNIONS position; //Position in world coordinate frame: xyz and yaw
    float max_height; //Maximum height
    float max_speed; //Maximum speed
    SCENE_SWITCH_STATE cur_scene_switch_state; //Whether the scene switch is successful
    SCENE_TYPE cur_scene; //Current scene
    DRIVER_ENABLE_STATE driver_enable_state;
    BODY_ODOMETRY odometry; //Odometry information
    float tip_position_wrt_hip[LEG_NUMBER*3];//Foot position relative to hip frame
    float vf_planned_tip_position_wrt_base[LEG_NUMBER * 3];
    float touch_detection[LEG_NUMBER];//Foot contact detection: 0 or 1, future: probabilistic
    float target_body_orientation[3]; //raw pitch yaw

    //Error codes
    int error_code;
    bool has_error;
    unsigned int error_wheel[CODE_WHEEL_NUM];
    unsigned int warn_wheel[CODE_WHEEL_NUM];
    unsigned int note_wheel[CODE_WHEEL_NUM];
    unsigned int joint_error_wheel[JOINT_CODE_WHEEL_NUM];
    unsigned int joint_warn_wheel[JOINT_CODE_WHEEL_NUM];
    unsigned int joint_note_wheel[JOINT_CODE_WHEEL_NUM];
    ROBOT_CHARGE_STATUS charge_status;
    bool salute_state;
    NAV_OR_JOY_MODE joy_mode;
    EQA_STATE eqa_state;

    bool guardian_switch; //Status of obstacle stop function
    bool visual_foothold_switch; //Status of visual foothold function
    GUARDIAN_VELOCITY_DECAY_RATIO guardian_velocity_decay_ratio; //Obstacle decay ratio in forward/left/right

    LIE_DOWN_ADJUST_ lie_down_adjust; //Whether foot adjustment is happening before lying down  
    float speed_bar_on_controller; //Current selected speed on controller
    CALIBRATE_POSE_STATE calibrate_pos_state;
    int self_test_code;
    bool encoder_calibrate_state;

    bool nav_pos_state;//Navigation positioning status
    bool nav_init_pos;//Whether navigation positioning is initialized
    TERRAIN_SEG_DETECTION_RESULTS terrain_seg_result;
    bool uwb_state;
    STAIRS_HEIGH_STATE stairs_state;
    bool weight_load_switch;
    float cur_weight_load;
    bool exceeding_weight_load;
}ROBOT_COMMON_STATUS;

Usage Example

cpp
common::ROBOT_COMMON_STATUS com_state;
bool success = rcClientInterfaceGetCommonStatus(&com_state);
if (success) {
    std::cout << "Common Status Retrieved Successfully." << std::endl;
    // Output or process com_state data
} else {
    std::cout << "Failed to Retrieve Common Status." << std::endl;
}

Notes

  • com_state must be a valid pointer to a common::ROBOT_COMMON_STATUS structure.
  • Ensure the connection between client and server is successfully initialized before calling this function.

Get Basic Status

C++ Interface

Refer to Section 1.1: rcClientInterfaceGetCommonStatus

Usage Example

cpp
common::ROBOT_COMMON_STATUS com_state;
bool success = rcClientInterfaceGetCommonStatus(&com_state);
if (success) {
    std::cout << "Common Status Retrieved Successfully." << std::endl;
    auto statue = com_state.belie_or_stand
    // Output or process com_state data
} else {
    std::cout << "Failed to Retrieve Common Status." << std::endl;
}

Status Code Definition

cpp
typedef enum BODY_POSTURE_STATE_{
    NULL_POSTURE = 0,
    STARTMOVING = 1,
    MOVING = 2,
    LIEDOWN = 3,
    STANDUP = 4,
    CHARGING=5  //On charging dock; could be charging or already fully charged
}BODY_POSTURE_STATE;

ROS2 Interface

This interface is used to publish the robot's basic posture state.

Topic NameTopic TypeRole
/robot_statestd_msgs::msg::UInt32Publisher

Message Structure

The std_msgs::msg::UInt32 message contains a single data field with the following meanings:

  • 0: Lying down
  • 1: Standing up
  • 2: Standing
  • 7: Null (undefined)

Sample Message

cpp
std_msgs::msg::UInt32 state_msg;
state_msg.data = 2; // standup

Testing Method

bash
ros2 topic echo /robot_state

Get Control Mode

This function is used to retrieve the current control mode of the robot, indicating whether it is in navigation mode or manual (teleoperation) mode.

C++ Interface

Refer to [Device Status Service Interface] – [Get Common Status Information] for usage.

cpp
common::ROBOT_COMMON_STATUS com_state;
bool success = rcClientInterfaceGetCommonStatus(&com_state);
auto state = com_state.joy_mode

Control Mode Enumeration

cpp
typedef enum NAV_OR_JOY_MODE_{
    nall_control = 0,
    nav_control = 1,
    joy_control = 2
}NAV_OR_JOY_MODE;

ROS2 Interface

This interface publishes the robot's current control mode.

Topic NameTopic TypeRole
/control_modestd_msgs::msg::UInt8Publisher

Message Structure

The std_msgs::msg::UInt8 message contains a data field that indicates the control mode:

  • 0: Manual (joystick) control
  • 1: Autonomous (navigation) mode

Sample Message

cpp
std_msgs::msg::UInt8 control_mode_msg;
control_mode_msg.data = 1; // Indicates Autonomous (Navigation) mode

Testing Method

bash
ros2 topic echo /control_mode

Get Current Scene (Gait) of the Robot

C++ Interface

Refer to [Device Status Service Interface] – [Get Common Status Information].

cpp
common::ROBOT_COMMON_STATUS com_state;
bool success = rcClientInterfaceGetCommonStatus(&com_state);
auto state = com_state.cur_scene

Scene Type Enumeration

cpp
typedef enum SCENE_TYPE_ {
    NULL_SCENE        = 0,  // None
    LIE_DOWN          = 1,  // Lying down
    WALKING           = 2,  // Walking
    STAIRS            = 3,  // Climbing stairs
    CHARGE            = 4,  // Charging
    PERCEIVE_STAIRS   = 5,  // Stairs perception
    SNOW              = 6,  // Snow terrain
    SLIPPY            = 7,  // Slippery slope
    STONE             = 8   // Gravel road
} SCENE_TYPE;

ROS2 Interfaces

Legacy Scene Topic

Topic NameTopic TypeRole
/scenestd_msgs::msg::UInt8Publisher

Message Structure:

  • data field represents the robot's current gait/scene.
  • Code definitions:
    • 0: None
    • 1: Lying down
    • 2: Walking
    • 3: Climbing stairs
    • 4: Charging

Sample Message:

cpp
std_msgs::msg::UInt8 scene_msg;
scene_msg.data = 2; // Walking

Testing Command:

bash
ros2 topic echo /scene

Updated Gait Topic

Topic NameTopic TypeRole
/gaitstd_msgs::msg::UInt8Publisher

Message Structure:

  • data field represents the robot's current gait.
  • Gait code definitions:
    • 0: Normal gait
    • 1: Stairs gait
    • 2: Slope gait

Sample Message:

plain
std_msgs::msg::UInt8 gait_msg;
gait_msg.data = 2; // Slope gait

Testing Command:

plain
ros2 topic echo /gait

Retrieving Docking (Charging Station) Status

C++ Interface

Refer to: [Device Status Service Interfaces] → [Retrieve Common Status Information]

Usage Example:

cpp
common::ROBOT_COMMON_STATUS com_state;
bool success = rcClientInterfaceGetCommonStatus(&com_state);
auto state = com_state.charge_status.charge_switch_state

State Code Definition:

cpp
typedef enum CHARGE_SWITCH_STATE_{
    NULL_CHARGE_SWITCH = 0,
    EXIT_SUCCEEDED = 1,  
    EXITING_TILE = 2, 
    EXIT_FAILED=3, 
    ENTER_SUCCEEDED = 4,
    ENTERING_TILE = 5,
    ENTER_FAILED=6   //Process or display the charge docking state
}CHARGE_SWITCH_STATE;

Retrieving Joint Status Information

C++ Interface

Function:rcClientInterfaceGetJointsStatus

cpp
/**
 * @brief Retrieve the robot's joint status information.
 * 
 * This function is used to obtain the status information of the robot's joints.
 * 
 * @param state A pointer to the structure where the joint status information will be stored.
 * @return bool Returns `true` if the retrieval is successful, otherwise returns `false`.
 */
bool rcClientInterfaceGetJointsStatus(common::ROBOT_JOINTS_STATUS *state);

**Usage Example: **

cpp
common::ROBOT_JOINTS_STATUS state;
bool success = rcClientInterfaceGetJointsStatus(&state);
if (success) {
    std::cout << "Joints Status Retrieved Successfully." << std::endl;
    // Output or process the 'state' data
} else {
    std::cout << "Failed to Retrieve Joints Status." << std::endl;
}

Notes:

  • Ensure that the state pointer refers to a valid common::ROBOT_JOINTS_STATUS structure.