cyberbotics / webots_ros2

Webots ROS 2 packages
Apache License 2.0
389 stars 141 forks source link

how to change the topic publish frequency of imu or other sensor? #919

Open lkx8421 opened 2 months ago

lkx8421 commented 2 months ago

When I use webots to publish imu topic, the urdf infomation such as this image and in my code i set TIME_STEP = 5 use WbFieldRef field = wb_supervisor_node_get_field(time_node, "basicTimeStep"); wb_supervisor_field_set_sf_float(field, TIME_STEP); but the topic frequecy is always like image image i dont know how to change it in 5ms to publish

lukicdarkoo commented 2 months ago

The publish rate also depends on the simulation speed. Webots tries to maintain RTF at 1.0 but it is not guaranteed as some simulation steps take longer to calculate.

In ROS, the standard approach is to use ROS clock (Webots already publishes it) in your nodes, see: https://wiki.ros.org/Clock