UWB Follow Service Interface
Subscribe to UWB Raw Data Interface
Introduction
This interface is used to subscribe to ROS2 /uwb_data topic to obtain the feedback coordinate data of the UWB bracelet.
Topic Name | Topic Type (Custom Message) | Role |
---|---|---|
/uwb_data | uwb_sensor_msgs::msg::UwbDataWithTimestamp | Subscriber |
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