Skip to content

UWB Follow Service Interface


Subscribe to UWB Raw Data Interface

Introduction

1745576918795-5c838ca9-84ae-46f1-ae4d-ec10d80ab9a0.png

This interface is used to subscribe to ROS2 /uwb_data topic to obtain the feedback coordinate data of the UWB bracelet.

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

1737444819359-eeadd800-314f-4b08-a553-75960a7e4c41.png

Message Structure

uwb_sensor_msgs::msg::UwbDataWithTimestamp include the following fields:

  • x_position : Indicates the x-axis coordinate of tag compared with anchor/cm.

  • y_position : Indicates the y-axis coordinate of tag compared to anchor/cm.

  • Distance : Indicates the two-dimensional European distance/cm between tag and anchor.

  • Phase : Indicates the angle information/degree of tag compared to anchor.

Callback Sample 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);
    }
}
Test Method
  • The terminal uses the following command to print UWB topic:/uwb_data data in
bash
ros2 topic echo /uwb_data
  • The terminal uses the following command to analyze the publishing frequency of UWB data in real time:
bash
ros2 topic hz /uwb_data
Precautions

If the print data displays error or is empty, the main reason is that the custom message body is not the ROS2 standard library, so source is required before printing.

bash
source install/setup.bash