# Tank Steering Algorithm in ROS

Hi to all,

I'm trying to write a ROS node for my mobile robot which is based on a skid-steering system. I have two motors, one per each side, and each motor can be controlled by using A C/C++ function:

int motor_cmd(MOTOR_channel, VALUE);

where motor_channel is used to choose the motor to control and VALUE is an integer with a range (-100, 0, +100). Values 0, +100 make the motor spin forward while 0, -100 make the robot spin backward.

I would like to use a bluetooth joypad and write a teleop node to control the robot. The problem is that I'm not able to figure out how to implement the skid steering motion.

What kind of relation should I write to use the X-Y values which come from the joypad as parameter for my motor_cmd() function?

I mean, if for example I use the joypad to go forward, then X=0, Y=MAX_VALUE and then the function should be: motor_cmd(1, 100); motor_cmd(2, 100); Or if I turn on the spot and so X = MAX_value, Y = - MAX_value, then: motor_cmd(1, 100); motor_cmd(2, -100);

How can I implement this algorithm? Can you help me, please?

Thank you!

Originally posted by Marcus Barnet on ROS Answers with karma: 287 on 2016-02-16

Post score: 1

One very simple implementation of what you're interested in is available here:

• updateCommand takes in a speed and angular rate in the range [-1.0,1.0] (which can be directly mapped to joystick axes) and generates left and right wheel int8_t commands in the range [-127,127]. You'd basically just have to substitute the "127" for a "100" as far as I can see.
• A message containing the left and right wheel command is sent to an Arduino via rosserial_arduino. This is then used to apply PWM to the motors on the Arduino side via this code in the command callback.

Originally posted by Stefan Kohlbrecher with karma: 24361 on 2016-02-16

This answer was ACCEPTED on the original site

Post score: 1