Closed Pansamic closed 8 months ago
Your XRCE Client and XRCE Agent are working properly because the agent is publishing to DDS, as you can see in the log [** <<DDS>> **]
.
This is likely related to a:
ros2 topic info /your_topic -v
?1. QoS matching problem
The output of ros2 topic info /imu/data -v
(using Micro-XRCE-DDS):
❯ ros2 topic info /imu/data -v
Type: sensor_msgs/Imu
Publisher count: 1
Node name: nav_mecanum_driver
Node namespace: /
Topic type: sensor_msgs/Imu
Endpoint type: PUBLISHER
GID: 01.0f.88.f0.36.21.c5.a0.04.00.00.00.00.00.01.03.00.00.00.00.00.00.00.00
QoS profile:
Reliability: RELIABLE
History (Depth): UNKNOWN
Durability: VOLATILE
Lifespan: Infinite
Deadline: Infinite
Liveliness: AUTOMATIC
Liveliness lease duration: Infinite
Subscription count: 0
Output of ros2 topic info /imu/data -v
(using Micro-ROS static library). This is the version that its message can be received by my ros2 nodes and can be echoed so it's my reference.
❯ ros2 topic info /imu/data -v
Type: sensor_msgs/msg/Imu
Publisher count: 1
Node name: nav_mecanum_driver
Node namespace: /
Topic type: sensor_msgs/msg/Imu
Endpoint type: PUBLISHER
GID: 01.0f.88.f0.36.21.c5.a0.03.00.00.00.00.00.0c.03.00.00.00.00.00.00.00.00
QoS profile:
Reliability: RELIABLE
History (Depth): UNKNOWN
Durability: VOLATILE
Lifespan: Infinite
Deadline: Infinite
Liveliness: AUTOMATIC
Liveliness lease duration: Infinite
Subscription count: 0
As you can see, Topic type
is not the same. QoS is the same.
2. Serialization problem
I've noticed something about rosidl_typesupport_microxrcedds
but I haven't use that. Is it essential? If so, how to use it?
I find so much repos to find the dataType of Micro-XRCE-DDS of ROS2 message, like PX4-Autopilot
, ros2xrcedds
, rmw_xrcedds
but I failed.
The type name shall be fixed in order to have a proper DDS/ROS2 communication
thanks, it works.
Problem
ros2 topic echo /imu/data
shows nothing, butros2 topic list
shows correct topic/imu/data
.Detail
/opt/ros/humble/share/xxxx_msgs/
folders.rt/imu/data
for dds topic name andsensor_msgs::dds_::Imu_
for dds data type.export ROS_DOMAIN_ID=3
so Domain ID matches.ros2 node list
shows client participant name as expected.ros2 topic list
shows client topic name as expected.use micro-ros agent,
ros2 run micro_ros_agent micro_ros_agent serial --dev /dev/ttyACM0 -v5
main code looks like:
Details of
uxrce_client_init()
, etc.uxrCustomTransport transport; uxrSession session; uxrStreamId reliable_out;
uxrObjectId participant_id; uint16_t participant_req; uxrObjectId datawriter_id; uint16_t datawriter_req;
ucdrBuffer mb;
sensor_msgs_msg_Imu msg_imu = {0};
uint8_t output_reliable_stream_buffer[STREAM_BUFFER_SIZE]; uint8_t input_reliable_stream_buffer[STREAM_BUFFER_SIZE]; /**/ / DECLARATION / /**/
/**/ / DEFINITION / /**/ uint8_t uxrce_client_init() { // Transport uxr_set_custom_transport_callbacks( &transport, true, my_custom_transport_open, my_custom_transport_close, my_custom_transport_write, my_custom_transport_read); if (!uxr_init_custom_transport(&transport, NULL)) { printf("Error at create transport.\n"); return 1; } // Session
}
uint8_t create_publisher(const char topic_name, const char data_type) { static uint16_t publisher_index = 0;
}
uint8_t msg_publish(const void * pmsg) { uint32_t topic_size = sensor_msgs_msg_Imu_size_of_topic(pmsg, 0); uxr_prepare_output_stream(&session, reliable_out, datawriter_id, &mb, topic_size); sensor_msgs_msg_Imu_serialize_topic(&mb, pmsg);
}
uint8_t create_publisher_imu() { memcpy(msg_imu.header.frame_id,"base_link",9); msg_imu.orientation_covariance[0] = -1.0; msg_imu.orientation_covariance[4] = -1.0; msg_imu.orientation_covariance[8] = -1.0; return create_publisher("rt/imu/data", "sensormsgs::dds::Imu_"); }