|
|
|
![]() |
|
|||||||
|
||||||||
![]() |
|
|
Thread Tools | Rate Thread | Display Modes |
|
|
|
#1
|
|||
|
|||
|
Programming Mecanum?
Our team decided to use mecanum wheels this year and we've used java last year. I'm a bit familiar with java but I can't seem to find a way to approach programming mecanum. I checked out the library but I can't seem to understand. Does anyone have a simple or pseudo program for mecanum they can share?
|
|
#2
|
||||
|
||||
|
Re: Programming Mecanum?
Could you articulate in a bit more detail what you don't understand about the library support for mecanum? You'll get better-targeted answers if you do that.
|
|
#3
|
||||
|
||||
|
Re: Programming Mecanum?
Under public class RobotMain extends IterativeRobot,
RobotDrive m_drive; Under public void RobotInit m_drive = new RobotDrive(m_frontLeft, m_rearLeft, m_frontRight, m_rearRight); // those reference the motors declared in another section of the code Under public void TeleoperatedPeriodic m_drive.mecanumDrive_Cartesian(-1 * m_rstick.getX(),-1 * m_rstick.getY(), -1 * m_lstick.getX(), 0); //m_rstick and m_lstick are just joysticks That's the code we're using right now. Cartesian is much simpler than Polar, because then you don't have to deal with the annoying trigonometry with polar coordinates. m_rstick and m_lstick are just joysticks. So, based on what we get for input from our joysticks, we can control forward/backward, strafe left/right, and turn clock/counter-clockwise. The rest of the code has been done by the WPI. Sorry if this doesn't help. |
|
#4
|
|||
|
|||
|
Re: Programming Mecanum?
You COULD do this:
Code:
/* Simulated tank drive controls for mecanum wheels */ magnitude = (leftStick.getMagnitude() + rightStick.getMagnitude()) / 2; direction = (leftStick.getDirectionDegrees()+rightStick.getDirectionDegrees()) / 2; rotation = (leftStick.getY() + rightStick.getY()) / 2; driveRobot.mecanumDrive_Polar(magnitude, direction, rotation); You SHOULD do this: Code:
magnitude = leftStick.getMagnitude(); direction = leftStick.getDirectionDegrees(); rotation = rightStick.getX(); driveRobot.mecanumDrive_Polar(magnitude, direction, rotation); |
|
#5
|
|||
|
|||
|
Re: Programming Mecanum?
I have the same question, execpt for Labview. i can't figure how to put the motors in the Begin.vi and how to incoorpoate it into Telop. This is my first time changing our robot to mecanum
|
|
#6
|
|||||
|
|||||
|
Re: Programming Mecanum?
Our team is simply using arcade drive, since we've been having trouble with both the Polar and Cartesian driving. We have a toggle button that inverts the motors to strafe.
@General25: You'd probably get better answers in the Labview section, since this is Java. |
|
#8
|
|||||
|
|||||
|
Re: Programming Mecanum?
I've had a little problem programming the mecanum wheels myself. In my post before I said I had inverted the motors to strafe. Well, turns out that makes a nasty ugly strafe. Anyone have tips regarding how to actually program a strafe with arcade drive?
Thanks. here's our current code: Code:
if(joystickL.getTrigger() && state == 0) {
robotDrive.setInvertedMotor(frontLEFT, true);
robotDrive.setInvertedMotor(rearRIGHT, true);
// robotDrive.setInvertedMotor(frontRIGHT, false);
// robotDrive.setInvertedMotor(rearLEFT, false);
this.state = 1;
} else if(joystickL.getTrigger() && state == 1) {
robotDrive.setInvertedMotor(frontLEFT, false);
robotDrive.setInvertedMotor(rearRIGHT, false);
// robotDrive.setInvertedMotor(frontRIGHT, false);
// robotDrive.setInvertedMotor(rearLEFT, false);
this.state = 0;
}
|
|
#9
|
||||
|
||||
|
Re: Programming Mecanum?
Quote:
|
|
#10
|
|||||
|
|||||
|
Re: Programming Mecanum?
Quote:
Could you please explain how I'm supposed to use forward/backward/clockwise in the drive train programming? |
|
#11
|
||||
|
||||
|
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. |
![]() |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|