Skip to content

UWB Following Service Interface

UWB Raw Data Subscription Interface

Description

画板

This interface is used to subscribe to the /uwb_data topic in ROS2 in order to receive coordinate data feedback from the UWB wristband.

Topic NameTopic Type (Custom Message)Role
/uwb_datauwb_sensor_msgs::msg::UwbDataWithTimestampSubscriber

画板

Message Structure

The message type uwb_sensor_msgs::msg::UwbDataWithTimestamp contains the following fields:

Field NameDescription
x_positionRepresents the X-axis coordinate of the tag relative to the anchor, in centimeters (cm).
y_positionRepresents the Y-axis coordinate of the tag relative to the anchor, in centimeters (cm).
distanceRepresents the 2D Euclidean distance between the tag and the anchor, in centimeters (cm).
phaseRepresents the angle (phase) of the tag relative to the anchor, in degrees (°).

Callback Example Message

cpp
void uwb_callback( 
    const uwb_sensor_msgs::msg::UwbDataWithTimestamp::SharedPtr msg) {
    if(msg->distance ==0 && msg->phase ==0 )
    {
        uwb_updated_ = false;
    }else
    {
        msg->distance = (msg->distance)*0.01;

        RCLCPP_INFO(this->get_logger(),
        "Received UWB data: dis: '%f m', phase: '%f deg'",
        msg->distance, msg->phase);
    }
}

Testing Method

  • To print UWB topic /uwb_data in real time, use the following command in the terminal:
bash
ros2 topic echo /uwb_data
  • To analyze the publishing frequency of the UWB data in real time, use:
bash
ros2 topic hz /uwb_data

Precautions

If the output shows error messages or remains empty, it is most likely due to the custom message type not being part of the standard ROS 2 library. Before running the above commands, make sure to source the workspace:

bash
source install/setup.bash