Odometry from GPIO on the robot

asked 2021-06-05 12:32:30 -0500

Eldar gravatar image

Can you tell me some ready-made solution in order to convert readings from hall sensors connected via GPIO to odometry? If this is important, then I clarify that my robot has 2 tracks and each of them has an engine, each of which has 2 hall sensors with some displacement (so that you can find out the direction of movement)

edit retag flag offensive close merge delete

Comments

Not really a ROS problem, but are you sure this can be done? Reading Hall Sensors often require real time accurate reading of the sensor data which is why its often done on a separate microcontroller (arduino) and not on a Linux PC.

Humpelstilzchen gravatar image Humpelstilzchen  ( 2021-06-07 01:07:48 -0500 )edit

Why I should use a separate microcontroller like arduino? I have a powerful computer NVIDIA Xavier NX on my robot. So why it can not do accurate realtime reading of the sensor data? Is that because a Linux is not a real-time operating system? I'm really instresting about that.

Eldar gravatar image Eldar  ( 2021-06-07 13:32:47 -0500 )edit

This is not ROS related and documented a few times in the web, but I will try it in a few sentences. Lets say you have a motor like this one. With full speed at 170RPM a gear ratio of 1:30 and 360 ticks per turn gives you 170/6030360=30600 encoder ticks per second, or one every 32µs. (TODO: check math when awake again). Your ARM µC runs multiple threads and the scheduler decides when a thread gets CPU time, with a GHz CPU and Linux this might be a few 1000 times a second so you can get a task to read a GPIO every few ms and thats not guaranteed and still for from µs range. That was a really short answer that left out some details.

Humpelstilzchen gravatar image Humpelstilzchen  ( 2021-06-07 14:30:23 -0500 )edit

Note: The Xavier might have special hardware to read encoders, I don't know that. Thats a question for an nvidia board (or read the datasheet). But personally even if the Xavier does has special hardware I would use a separate µC, just because it is easier on the well documented AVRs and I can later easily swap the Xavier against a newer replacement)

Humpelstilzchen gravatar image Humpelstilzchen  ( 2021-06-07 14:37:27 -0500 )edit