View Full Version : Is RobotDrive required ?
parsodark
06-02-2014, 22:34
Hi everyone,
I would like to know if the RobotDrive class is required. Basically, we have a mechanum drive system, and we control the motors with the Set member of the Talon class. It's working like a charm so far.
I would like to know if I'm not making any big mistakes here.
Thanks
Joe Ross
06-02-2014, 22:48
There is no requirement to use robot drive. It's there to make your life easier.
parsodark
07-02-2014, 01:23
Ok, thanks !
(and I must add it wasn't making my life easier)
Ok, thanks !
(and I must add it wasn't making my life easier)
How is your home-brew mecanum code different from what's in WPILib??
SoftwareBug2.0
08-02-2014, 00:18
How is your home-brew mecanum code different from what's in WPILib??
I can't speak for his code but a good start would be to make the mixing function be able to be called seperately from changing motor outputs.
parsodark
10-02-2014, 12:17
How is your home-brew mecanum code different from what's in WPILib??
Basically, its a tank drive, with both x axis controlling the sideway movement.
Both joysticks up : move forward
Both joysticks down : move backward
One up, one down : rotation
Both left/right : sideway movement
We used it in other competitions (Vex) and we found it to be way more intuitive
Here's the code itself (in a stripped down version):
frontLeft->Set(-stick.GetRawAxis(2)+stick.GetRawAxis(1));
backLeft->Set(-stick.GetRawAxis(2)-stick.GetRawAxis(1));
frontRight->Set(stick.GetRawAxis(4)+stick.GetRawAxis(3));
backRight->Set(stick.GetRawAxis(4)-stick.GetRawAxis(3));
Basically, its a tank drive, with both x axis controlling the sideway movement.
Both joysticks up : move forward
Both joysticks down : move backward
One up, one down : rotation
Both left/right : sideway movement
There's no reason you cannot use WPILib with the Operator Interface you described:
First do this:
Y = (Yleft + Yright)/2
Rotation = (Yleft - Yright)/2
X = (Xleft + Xright)/2
... then send those X, Y, and Rotation values to the corresponding inputs to the RobotDrive::MecanumDrive_Cartesian() method in the RobotDrive class:
/**
* Drive method for Mecanum wheeled robots.
*
* A method for driving with Mecanum wheeled robots. There are 4 wheels
* on the robot, arranged so that the front and back wheels are toed in 45 degrees.
* When looking at the wheels from the top, the roller axles should form an X across the robot.
*
* This is designed to be directly driven by joystick axes.
*
* @param x The speed that the robot should drive in the X direction. [-1.0..1.0]
* @param y The speed that the robot should drive in the Y direction.
* This input is inverted to match the forward == -1.0 that joysticks produce. [-1.0..1.0]
* @param rotation The rate of rotation for the robot that is completely independent of
* the translation. [-1.0..1.0]
* @param gyroAngle The current angle reading from the gyro. Use this to implement field-oriented controls.
*/
void RobotDrive::MecanumDrive_Cartesian(float x, float y, float rotation, float gyroAngle)
Here's the code itself (in a stripped down version):
frontLeft->Set(-stick.GetRawAxis(2)+stick.GetRawAxis(1));
backLeft->Set(-stick.GetRawAxis(2)-stick.GetRawAxis(1));
frontRight->Set(stick.GetRawAxis(4)+stick.GetRawAxis(3));
backRight->Set(stick.GetRawAxis(4)-stick.GetRawAxis(3));
The above code is not kinematically correct. You are not taking full advantage of the 3DoF capability of the mecanum wheels.
notmattlythgoe
10-02-2014, 13:05
Basically, its a tank drive, with both x axis controlling the sideway movement.
Both joysticks up : move forward
Both joysticks down : move backward
One up, one down : rotation
Both left/right : sideway movement
We used it in other competitions (Vex) and we found it to be way more intuitive
Here's the code itself (in a stripped down version):
frontLeft->Set(-stick.GetRawAxis(2)+stick.GetRawAxis(1));
backLeft->Set(-stick.GetRawAxis(2)-stick.GetRawAxis(1));
frontRight->Set(stick.GetRawAxis(4)+stick.GetRawAxis(3));
backRight->Set(stick.GetRawAxis(4)-stick.GetRawAxis(3));
That's interesting that your team finds it more intuitive that way. The 2 years that we had mechanum wheels on our robot we thought one stick was extremely intuitive and it was amazing how easy it was to step up to the robot and drive it for the first time. Ours was:
Forward - drive forward
Left - strafe left
Right - strafe right
Backwards - drive backwards
Twist - rotate
Do you not have a joystick that has a twist motion?
parsodark
10-02-2014, 16:27
@Ether
Y = (Yleft + Yright)/2
Rotation = (Yleft - Yright)/2
X = (Xleft + Xright)/2
With that, we lose what I like about our mechanum algorithm : control over everything.
Many times, I found myself having one joystick up and one left. It allows me to make the robot do some movements that are otherwise difficult. Also, I have been able to control the robot with a dead motor. I was still able to move it around easily, while I couldn't with the original WPILib MechanumDrive.
Last thing I like about it : Left Joystick controls left wheels, right joystick controls right wheels. No confusion about that.
Also, what do you mean by "3DoF" ?
@notmattlythgoe
We do have a 3-axis joystick, only we find it to be unaccurate
@Both of you (and everyone else)
I may be wrong, please correct me if it's the case
vBulletin® v3.6.4, Copyright ©2000-2017, Jelsoft Enterprises Ltd.