Ask Your Question

Revision history [back]

You can find a basic implementation of sending motion commands to a Arduino with motor shield here: https://github.com/skohlbr/simple_2wd_robot. The approach taken uses joystick commands for linear and angular velocities (both axes scaling from -1 to 1) here, computes a left and right motor command (still on the "ROS side") and then sends commands for both motors to the Arduino using the DiffDriveCommand message over to the Arduino via rosserial. This command is then applied here in the Arduino side code.

The problem with very basic setups that only use simple motor drivers and no encoders is that you can only command open loop PWM to motors and you cannot control the motor (and hence wheel) velocity, so making the robot actually accurately follow velocities you might compute is not trivial (this is why the above mentioned example uses just joystick commands between min and max "effort"). You can of course experimentally determine how fast the robot goes for different PWM values, but will change with ground and wheel types, payload and all sorts of other factors. That being said, actually calculating desired velocities is relatively simple and this PDF appears to provide a pretty good overview of how to do it.