# X and Z axis change when gyro reaches 90 degrees

We are using Mechanum wheels and are trying to use a Gyro to make things easier for the driver. The base code had to be changed by swapping the throttle(axis 3) and y axis. The unit drives great until we turn on the gyro and rotate right or left beyond 90 degrees. We are using labview and used sample library code. At which point the robot starts moving sideways in the direction that you were rotating.

Can you go into more detail about how it behaved before you swapped axis 3 and the y axis? It may be easier if you use the Cartesian one instead of the Polar mecanum. I would strongly advise you not flip the inputs, especially if you’re trying to use field centric. I’m guessing you had to swap axis because one needs to be inverted. This is pretty easy to test on Cartesian. Start with just y, if it doesn’t go forward invert it. If it goes in a weird direction, you probably need to flip the motor connectors to the speed controller. To make sure when you apply only y all the motors turn in the same direction.

Next add in the x, if it doesn’t strafe in the right direction invert it. Then finally add in your rotation and do the same.

This should give you robot centric control. Then add the gyro as the forth input, and you should have a field centric control.

Lineskier,
Our team has figured out that when we use the Y axis on our controller it acts as axis 3. And when we use the axis 3 it acts as though its the Y axis. We tested this so the labels are wrong in the program. We are using cartesian and plugging the correct axis into the Cartesian mecnum with a numerical gyro number between -360°and 360°. We have our program set up so we can “turn off” the gyro and put a zero in for the angle at the press of a button. when the angle is at zero our robot works fine, but when we put our gyro angle in and try to rotate it at 90° it starts to strafe. This shouldn’t be possible because spin is input to the equation after the gyro changes the X and Y axis.
Any help would be appreciated.

Are you using an xbox controller by any chance? I seem to remember the x on the right joystick is axis 3.

If this is the case I would expect that you would be feeding something like this into the mecanum:

Left JS_Y (js1.y) -> mecanum y
Left JS_X (js1.x) -> mecanum x
Right JS_X (js1.axis3) -> mecanum rot
Gyro getAngle -> mecanum angle

I just did some some further research and realized this is probably not the case. Can you provide the mappings you are using for x, y, and rot. Also what type of js set up you’re using…

I suspect your motors aren’t in the places the software thinks they are. Try putting the robot up on blocks so it won’t go anywhere, removing all the circuit breakers for the drive motors, and putting in only one breaker at a time. Attempt to drive forward and reverse and make sure the wheel does what you expect. Then try to rotate left and right and make sure the wheel does what you expect. Remove that breaker and put in another one and repeat until you have verified all four motors.

Testing the strafe function one wheel at a time is a little less straightforward, but you should be able to figure out whether it’s correct.

I’ll mention this for completeness: I have seen robots do very weird things when a motor’s wires are accidentally connected to two different speed controllers. That might be something worth checking.

We are using the Logitech Extreme 3D Pro it has the X and Y axis and a Z when you twist.

The motors are responding correctly until we turn it 90° on the blocks with the gyro on the x axis and z switch making the z do strafing and the x spin till we put it back to 0° with the gyro off nothing happens.
We put the correct axis to the right inputs on the Cartesian drive and the angle from the gyro in correctly as well.

If the only issue is that the robot stops behaving correctly after you rotate it then we had a similar problem. All you have to do is reset the gyro and it should be fixed. In order for the reset to be automatic (easier for the driver) we just said: any time the robot rotates, reset the gyro.

When both of you say make it easier on the driver, what do you mean?

In your case, if every time you’re rotating, you’re resetting the gyro, then you’re not letting the gyro do what it’s meant to. They gyro is meant to switch the mecanum drive from being robot centric to field centric (i.e. driver pushes away the robot drives away, regardless of it’s orientation). If you do not like this behavior, just put a 0 into the gyro input on the mecanum, and you’ll have a robot centric mecanum. You do not need a gyro on your robot to use the mecanum drive.

The issue for us was that anytime that the robot was rotated more than 90* the control was messed up. All directions on the joystick made the robot go forward or nothing moved at all. The way we are using the gyro is not for field -oriented control but for improved strafing capabilities. With the gyro the robot strafes directly right and left, correcting itself automatically, instead of at an angle.