ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question
0

[Turtlebot3] How to increase the publish frequency for the IMU topic

asked 2021-06-13 00:04:17 -0500

te26 gravatar image

I'm using a TurtleBot3 waffle pi, and it works on ROS2 foxy.

I try to get the acceleration of the turtlebot3, which is contained in the /imu topic, at a higher frequency (about 200Hz). By default, the publish frequency for the /imu topic is around 20Hz (This can be confirmed by running the command "ros2 topic hz /imu").

Is there any way to increase the publish frequency for the /imu topic?

Thanks.

edit retag flag offensive close merge delete

2 Answers

Sort by » oldest newest most voted
0

answered 2021-06-14 10:53:55 -0500

shonigmann gravatar image

Yes, but you'll have to dig into the weeds of the firmware a bit. Trying to give you an answer has been a journey...

IMU update period is seems to be defined here, but if you look at the source of the update function, you'll actually find that INTERVAL_MS_TO_UPDATE_CONTROL_ITEM goes unused.

So I think you actually need to change either:

  • the _imu.begin() calls in turtlebot3_sensor.cpp to _imu.begin(200) to set the sensor update rate to 200Hz, or
  • change IMU.h to set the default update frequency to 200Hz - oh wait, its already 200 by default... (frustration increases)

That's about as much help as I can offer, without knowing what firmware you are currently running...

Looking at the datasheet for the Turtlebot IMU, you should be able to achieve sampling rates of up to 8000Hz, so if you are asking for 200Hz and only getting 20, I think the OpenCR itself may be a bottleneck or there may be an underlying issue in the firmware (in that case, consider opening an issue.

I'll leave it to you to dig a bit further and see what sort of update rate you can squeeze out.

edit flag offensive delete link more

Comments

Thanks for your help.

I modified the opencr firmware and was able to upload to turtlebot3 with arduino IDE successfully. However, when I run bringup, I get the following error. I also get this error if I upload the firmware without modifying it.

[turtlebot3_ros-3] terminate called after throwing an instance of 'rclcpp::exceptions::RCLError'
[turtlebot3_ros-3]   what():  could not create publisher: rcl node's context is invalid, at /tmp/binarydeb/ros-foxy-rcl-1.1.11/src/rcl/node.c:441
[ERROR] [turtlebot3_ros-3]: process has died [pid 2402, exit code -6, cmd '/home/ubuntu/turtlebot3_ws/install/turtlebot3_node/lib/turtlebot3_node/turtlebot3_ros -i /dev/ttyACM0 --ros-args --params-file /home/ubuntu/turtlebot3_ws/install/turtlebot3_bringup/share/turtlebot3_bringup/param/waffle_pi.yaml'].

My environments: - ubuntu20.04 - Arduino IDE 1.8.15 - opencr1.4.18 - dynamixel2arduino 0.4.7

te26 gravatar image te26  ( 2021-06-24 08:02:25 -0500 )edit
1

It seemed difficult to solve this problem, so I used another accelerometer instead. Now, I'm using a mpu6050 connected via i2c to the raspberry pi, and I have an enough sampling frequency.

te26 gravatar image te26  ( 2021-06-24 08:02:46 -0500 )edit

I'm glad you found a solution that worked for you. I believe I have seen the ROS2 bringup error you got; if I recall correctly, in my case it occurred when a) I was using incompatible firmware (e.g. ROS1 firmware with ROS2 running on the Pi), or b) was specifying the wrong USB port (e.g. /dev/ttyACM0 instead of ACM1 or whatever the OpenCR was actually connected to)

shonigmann gravatar image shonigmann  ( 2021-06-24 11:17:18 -0500 )edit
-1

answered 2021-06-13 12:20:33 -0500

vishal_bakshi gravatar image

you can increase the queue_size = (your choosen number)

edit flag offensive delete link more

Question Tools

1 follower

Stats

Asked: 2021-06-12 22:39:38 -0500

Seen: 958 times

Last updated: Jun 14 '21