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 Name | Topic Type (Custom Message) | Role |
---|---|---|
/uwb_data | uwb_sensor_msgs::msg::UwbDataWithTimestamp | Subscriber |
Message Structure
The message type uwb_sensor_msgs::msg::UwbDataWithTimestamp
contains the following fields:
- x_position: Represents the X-axis coordinate of the tag relative to the anchor, in centimeters (cm).
- y_position: Represents the Y-axis coordinate of the tag relative to the anchor, in centimeters (cm).
- distance: Represents the 2D Euclidean distance between the tag and the anchor, in centimeters (cm).
- phase: Represents 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