[ros-users] [Discourse.ros.org] [ROS Projects] Project Wayfarer

Chris Albertson ros.discourse at gmail.com
Fri Jan 12 08:46:16 UTC 2018

Yes.  What you are building is called a "base controller".   Typically
everything done at a lower level than "twist" is done outside of ROS.
 ROS is really not very good with real time.

I had the same goal. wring this controller once and reusing it.   My other
platform has four wheels and each has it's own encoders and each wheel is
control independently.

Here is how I did it...

My Base Controller runs on an ARM Cortex-4 micro controller.  These are
like Arduino but 40X more powerful at 1/2 the cost.  They run a ROS node
using ROS Serial and connect to the larger Linux based system with a serial

The base controller, waits for "twist" messages.  For each message it
computes the speed of every motor and stores this as "target speed".   It
is not hard only a little trigonometry is needed and we only get at most 20
twist  messages per second

Also running the same Cortex-M are one PID servo control loop for each
motor that neds to be controlled.  The PID loop looks at the target speed,
compared this to the measured speed and then does what PID controllers do,
adjusts the motor voltage to reduce the error.  I have one loop per wheel.

Finally the last part.  An interrupt service routine was called each time
an encoder sends a pulse.  Atevery plus it updates the measured position of
the wheel.   This can be as fast as 11,000 times per second

In short, the measured speed is kept up to date by an interruption
handler.  The target speed to kept updated by the twist message handler.
Then the PID controller runs 20 times per second and looks at the
difference between measured the target speeds and sets the motor voltage up
or down so as to make target equal measured.

You are forced to use a small micro controller if yu are dealing with wheel
encoders.  Any computer running linux would never handle the interrupt rate.

One final thing.   Recently found out that ARM has a feature where it can
handle quadrature encoders in hardware.  I don't need to us an interrupt
handler.   I'll change this some day. It will save a ton of CPU time  I
could simply read the well position from a hardware register.

The same Cortex-M also sends periodic odomerty messages.  Also it does
"housekeeping" things like battery voltage

[Visit Topic](https://discourse.ros.org/t/project-wayfarer/3659/10) or reply to this email to respond.

More information about the ros-users mailing list