|
|
|
![]() |
|
|||||||
|
||||||||
![]() |
|
|
Thread Tools | Rate Thread | Display Modes |
|
|
|
#1
|
||||
|
||||
|
Re: Programming Mecanum?
Quote:
|
|
#2
|
|||||
|
|||||
|
Re: Programming Mecanum?
Quote:
Could you please explain how I'm supposed to use forward/backward/clockwise in the drive train programming? |
|
#3
|
||||
|
||||
|
Re: Programming Mecanum?
Quote:
Code:
front_left = forward + clockwise + right;
front_right = forward - clockwise - right;
rear_left = forward + clockwise - right;
rear_right = forward - clockwise + right;
// Finally, normalize the wheel speed commands
// so that no wheel speed command exceeds magnitude of 1:
max = abs(front_left);
if (abs(front_right)>max) max = abs(front_right);
if (abs(rear_left)>max) max = abs(rear_left);
if (abs(rear_right)>max) max = abs(rear_right);
if (max>1)
{front_left/=max; front_right/=max; rear_left/=max; rear_right/=max;}
// You're done. Send these four wheel commands to their respective wheels
If that's not what you were asking, please clarify your question and I'll try again. Last edited by Ether : 07-02-2011 at 11:35. |
|
#4
|
|||||
|
|||||
|
Re: Programming Mecanum?
Quote:
Code:
RobotDrive driveTrain = new RobotDrive(front_left, rear_left, front_right, rear_right); |
|
#5
|
||||
|
||||
|
Re: Programming Mecanum?
Without knowing how you have your motors wired I cannot tell you whether or not you need to invert them.
I can tell you this: If your motors are wired so that when you give them a +1 command they go in the "forward" direction, then no inverting is required. I recommend that you put the robot up on blocks and push the joystick(s) straight forward. If all four wheels spin in the "forward" direction, you're good to go. If not, then invert any motor that is spinning backwards. |
|
#6
|
|||
|
|||
|
Re: Programming Mecanum?
No, RobotDrive takes SpeedControllers in its constructor, not actual values. The example was giving you numbers to pass directly to your Jaguars. The sum total of the algorithm and motor control make your own robot drive method, you don't need the wpilibj version.
|
|
#7
|
|||
|
|||
|
Re: Programming Mecanum?
Sorry for the late reply.
So far this is what I currently have done and understand well. Code:
import edu.wpi.first.wpilibj.SimpleRobot;
import edu.wpi.first.wpilibj.Compressor;
import edu.wpi.first.wpilibj.GenericHID;
import edu.wpi.first.wpilibj.Gyro;
import edu.wpi.first.wpilibj.Victor;
import edu.wpi.first.wpilibj.Timer;
import edu.wpi.first.wpilibj.Jaguar;
import edu.wpi.first.wpilibj.RobotDrive;
import edu.wpi.first.wpilibj.Joystick;
//Program
public class RobotTemplate extends SimpleRobot {
//Drive Program
RobotDrive drive = new RobotDrive(1, 3, 2, 4);
//Joystick
private Joystick leftStick = new Joystick(1);
//private Joystick rightStick = new Joystick(2);
//Autonomous Program
public void autonomous() {
}
//Teleop
public void operatorControl() {
getWatchdog().setEnabled(true);
//WatchDog Enabled //Infinite Loop
while (isEnabled() && isOperatorControl()) {
getWatchdog().feed();
drive.mecanumDrive_Polar(leftStick.getDirectionDegrees(), leftStick.getMagnitude(), leftStick.getTwist());
Timer.delay(0.005);
}
}
}
Once I figure out how Cartisian works, I'll update the code. Now to figure out the gyro and encoder. |
|
#8
|
|||||
|
|||||
|
Re: Programming Mecanum?
Cartesian/Polar will only work if your wheels are similar to
\/ /\ or /\ \/ I'm not sure in which order though. Our team made the mistake of putting our mecanum wheels straight on all four sides so that's something we had to program around. @Esther: I managed to get the drive train programmed with your help. Thanks so much! ![]() *edit* my bad, I mean Ether. Last edited by Robby Unruh : 10-02-2011 at 09:09. |
|
#9
|
||||
|
||||
|
Re: Programming Mecanum?
Quote:
The wheels are supposed to be "straight", i.e. the plane of all 4 wheels should be parallel to each other. The rollers on each wheel are at a 45 degree angle to the plane of the wheel, and should form a visual pattern that looks like this when viewed from the top: Code:
\...../ ..... ..... ..... /.....\ ... or this when viewed from the bottom: Code:
/.....\ ..... ..... ..... \...../ |
|
#10
|
|||||
|
|||||
|
Re: Programming Mecanum?
Oh, alright. I guess I must've misunderstood some posts around here. Thanks for clearing that up.
|
![]() |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|