publishing robot odometry from arduino mega

asked 2021-06-10 19:01:38 -0500

Celebrimbor gravatar image

updated 2022-04-30 13:23:44 -0500

lucasw gravatar image

I'm currently workin on a robot project using ROS noetic navigation stack, and for this project i'm using arduino mega to drive the motors and to read the encoder data, and a Raspberry pi 3 B+ to run ROS.

For this project, i'm currently at the step where i need to publish the odometry for the navigation stack. I did some reasearch on the internet about how to publish the odometry data from arduino, and for like 90% of people, they calculate the robot speed or the encoder ticks in the arduino, and they pusblish it to ROS, and then they use a c++ or python code to calculate the odometry data then publish it to the odom topic.

my question is as follows: Is it possible to publish my robot odometry direcly from my arduino mega? and if yes, is there any code that is available so i can learn how to do that? or should i use the same method mentioned above to publish my robot odometry?

thanks in advance.

edit retag flag offensive close merge delete

Comments

The question is: Why? For publishing I take it you use ros serial? I don't use it to publish odom+tf because 1) it does need a lot memory I don't have on the AVR 2) odometry calculation requires floating point which the AVR needs to emulate. (yes, one can do that probably with fixed point but not convenient)

Humpelstilzchen gravatar image Humpelstilzchen  ( 2021-06-11 00:48:15 -0500 )edit

Mr. Humpelstilzchen i believe this means that i should publish my odometry using a C++ or python ROS node, nad not use the Arduino Mega

Celebrimbor gravatar image Celebrimbor  ( 2021-06-12 08:20:03 -0500 )edit

I recommend to use both. Measure the Odometry with the Mega, send it to your Linux computer and publish from there.

Humpelstilzchen gravatar image Humpelstilzchen  ( 2021-06-12 09:43:38 -0500 )edit

Mr. Humpelstilzchen you are saying that i should compute the odometry in my mega, then not to publish it to the odomtery topic but instead i publish it to the linux pc and from there i publish it to the odometry topic

Celebrimbor gravatar image Celebrimbor  ( 2021-06-12 17:37:26 -0500 )edit

I would only measure the encoder ticks on the Atmega and run the speed control loop on it.

Humpelstilzchen gravatar image Humpelstilzchen  ( 2021-06-13 01:39:08 -0500 )edit

Hey celebrimbor, i am also stucked in similar kind of situation. Looking for an alternative solution for publishing odom and tf values other then cpp code. Did you find any way to do so ?

Shyam_Majethiya gravatar image Shyam_Majethiya  ( 2021-07-22 12:59:17 -0500 )edit

Hey Shyam_Majethiya, i used the method that i mentioned earlier, i used the arduino megha to calculate the speed of the robot for each time preiode which was 100ms, then i published the speed to a ros topic (i used vector3stamped message type), after that i calculated the actual odometry using a python script and finally i published the odomtery to the odom and tf topic

i hope this was helpful and im very sorry for the late reply

Celebrimbor gravatar image Celebrimbor  ( 2021-07-29 14:07:55 -0500 )edit