We are trying to use the mecanum drive cartesian method provided by wpilib. We are having a problem with the axis in the controllers not working properly.
We are using an xbox controller with 2 joysticks instead of a flight stick with a rotational axis. We are using the x and y axis on the left stick for the x and y variables called in the method and the x axis on the right stick for the rotation.
What is supposed to happen:
The left stick controls forward/backward and strafe left/right.
The right stick controls rotation.
For example, when I push forward on the left stick the robot turns, and when I push left on the right stick it strafes.
When i push the left stick left/right the robot spins wheels but its not the right direction and doesnt move.
Has anyone successfully used the wpilib mecanum drive methods, and could you give us some tips?
We do not have a gyroscope set up currently and that variable is set as 0. Would that affect anything?
AFAIK, you should be able to use the cartesian methods without a gyro just fine. Internally the movement vector is just rotated by the gyro angle. Without a gyro, strafing will always be relative to the robot, so if you turn while strafing you will move in an arc.
We have fixed our robot, sort of.
We inverted one side of our robot and that fixed most of the problem.
The joysticks were opposite so we inverted those also.
now our robot works perfectly, except that our front is now our back and our back is our front. Other than that it is perfect. This is just a test chassis so direction isn’t a problem.
We got our Mecanum Drivetrain Code working in field coordinates in December; click for the code on github. This is based on cRIO, but shouldn’t need too much tweaking. This is built on the command based robot model.
Out of curiosity, why do you drive at 70% joystick readings in cartesian mode but full power in Polar mode?
Is there a purpose to Polar/Cartesian switch? Isn’t calling cartesian with gyro-angle==0 equivalent to to calling Polar? Perhaps it is meant to switch between field-centric and robot-centric?
Not sure the CommandBase class will work in this year’s lib so it may not just be load/go. Also, I think atan2 is on Math now, not MathUtils because we have proper java this year, so those are the obvious tweaks I see that will be necessary