Remote Control Mecanum Drive
Last updated
Was this helpful?
Last updated
Was this helpful?
The following picture shows the forces exerted on the robot when the wheels spin forward and backward. Green arrows indicate forward spin on the wheels while red arrows indicate backward spin. The diagonal arrows represent the total force, but the horizontal and vertical arrows represent the diagonal force broken down into its horizontal and vertical pieces. (Think of it like a right triangle!)
The next picture shows how the forces might cancel each other out to produce a forward motion. Note that I have circled the force arrows that will add up and crossed out the force arrows that will cancel.
The next picture shows how the forces might cancel each other out to produce a backward motion.
We want to program our robot so that input from the y-axis of the left joystick makes the robot move forward/backward. To do this we will add the following items to our program:
The circled code above repeatedly sets the power of each motor to the value it reads from the y axis of the gamepad’s left joystick. Notice also that the telemetry is now sending a message to the DS about the value it reads from the joystick.
The gamepad object holds the current values of each input on the gamepad. Here is a map of joystick values:
TIME TO TEST!!!!
Grab a gamepad and an adaptor and plug it into your Driver Station (phone).
Go ahead and run your RemoteControlDrive program. Your robot should move back and forth in a straight line when you move the Y axis of the left joystick. If your robot does not do this, ask an instructor for help.
The next picture shows how the forces might cancel each other out to produce a right strafe. Note that a green arrow indicates that a wheel is spinning forward and red indicates backward spin.
The next picture shows how the forces might cancel each other out to produce a left strafe. Note that a green arrow indicates that a wheel is spinning forward and red indicates backward spin.
Adding the following to your code will allow you to make your robot strafe with the x axis of your left joystick.
TEST AGAIN! Now your robot should move to the left and right as you move the X axis of the right joystick. Furthermore, you should be able to mix forward and backward movements into this to get something more like diagonal motion. THE ROBOT SHOULD NOT BE SPINNING AT ALL.
To make our robot spin, we will introduce one more variable and add it to the mix for each motor:
Mecanum Wheel Quick Reference
If you are looking for a different approach to driving this way, you might appreciate the use of trigonometry to make your robot drivable with only one joystick. Basically, your robot will drive in the direction you point.
Replace the drive code above with what it below.