# Mecanum Spin

Hey, I’m currently trying to figure out how to change the magnitude of the holonomic drive system. I tried the obvious approach (Changing the first float) however, with out current code, nothing seemed to change at all. Could someone look it over and tell me what they think? We basically want the spin of the robot to be dependent on the value returned by the joystick throttle:

``````//Stop Button
if(!joyStick->GetRawButton(3))
{
//Turn left
if(joyStick->GetRawButton(4))
joanRobo->HolonomicDrive(joyStick->GetThrottle(), 0.0, -180.0);

//Turn right
else if (joyStick->GetRawButton(5))
joanRobo->HolonomicDrive(joyStick->GetThrottle(), 0.0, 180.0);

//Regular holonomic movement
else
joanRobo->HolonomicDrive(joyStick->GetMagnitude(), joyStick->GetDirectionDegrees(), 0.0);
}
else
//Stop all movement
joanRobo->HolonomicDrive(0.0, 0.0, 0.0);
``````

I am not sure which part of your code you said not working. Mecanum drive requires 3 joystick axes. According to your code, you are using one joystick. If that’s the case, make sure your joystick has 3 axes. Since you are using the GetMagnitude(), it is computing the magnitude by doing sqrt(xx + yy), and the direction is computed by atan2(x, -y). So you should make sure that the Y axis of your joystick is controlling the forward/backward movement, the X axis is controlling your sideway movement. Then for the turn, make sure you are using the correct joystick axis for it. At first, we were reading the twist axis for the turn, but it was wrong. This is because our Microsoft Side Winder joystick maps twist to the Z-axis, not twist or throttle. So make sure you reads the correct axis.

Well we’re using the standard kop joystick, and our controller is indeed moving the robot properly, what we attempted doing is have it spin using to of the top buttons, and regulate the speed of the spin using the throttle on the joystick.

If you want to regulate the spin by the throttle, you should probably doing something like this:

``````
if (joyStick->GetRawButton(4))
joanRobo->HolonomicDrive(0.0, 0.0, -joyStick->GetThrottle());
//Turn right
else if (joyStick->GetRawButton(5))
joanRobo->HolonomicDrive(0.0, 0.0, joyStick->GetThrottle());
//Regular holonomic movement
else
joanRobo->HolonomicDrive(joyStick->GetMagnitude(), joyStick->GetDirectionDegrees(), 0.0);

``````