Go to Post This will likely fall on deaf eyes but - - JaneYoung [more]
Home
Go Back   Chief Delphi > Technical > Programming > Java
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
Reply
Thread Tools Rate Thread Display Modes
  #1   Spotlight this post!  
Unread 29-01-2011, 15:00
iNiLz iNiLz is offline
Mentor
no team (None)
Team Role: Mentor
 
Join Date: Feb 2010
Rookie Year: 2000
Location: NY
Posts: 5
iNiLz is an unknown quantity at this point
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?
Reply With Quote
  #2   Spotlight this post!  
Unread 29-01-2011, 15:08
Ether's Avatar
Ether Ether is offline
systems engineer (retired)
no team
 
Join Date: Nov 2009
Rookie Year: 1969
Location: US
Posts: 8,088
Ether has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond repute
Re: Programming Mecanum?

Quote:
Originally Posted by iNiLz View Post
I checked out the library but I can't seem to understand.
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.


Reply With Quote
  #3   Spotlight this post!  
Unread 29-01-2011, 15:50
FirebearBenD's Avatar
FirebearBenD FirebearBenD is offline
Registered User
FRC #2846
 
Join Date: Jan 2011
Rookie Year: 2009
Location: Roseville, MN
Posts: 4
FirebearBenD is an unknown quantity at this point
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.
Reply With Quote
  #4   Spotlight this post!  
Unread 01-02-2011, 00:13
Patrick Chiang Patrick Chiang is offline
Programming
FRC #3070 (Team Pronto)
Team Role: Mentor
 
Join Date: Feb 2009
Rookie Year: 2009
Location: Seattle
Posts: 162
Patrick Chiang is a name known to allPatrick Chiang is a name known to allPatrick Chiang is a name known to allPatrick Chiang is a name known to allPatrick Chiang is a name known to allPatrick Chiang is a name known to all
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);
^ We did it like this because our driver specifically asked for these controls. He has driven tank drive for two years, and I guess old habits are hard to change.

You SHOULD do this:
Code:
magnitude = leftStick.getMagnitude();
direction = leftStick.getDirectionDegrees();
rotation = rightStick.getX();
driveRobot.mecanumDrive_Polar(magnitude, direction, rotation);
^ This is what we call the FPS drive system (aka. xbox controller style). Left joystick controls w,a,s,d (forward, back, left, right) and diagonal movements. Right joystick controls rotation.
Reply With Quote
  #5   Spotlight this post!  
Unread 03-02-2011, 16:01
General25 General25 is offline
Registered User
FRC #3352
 
Join Date: May 2010
Location: Belevidere, IL
Posts: 2
General25 is an unknown quantity at this point
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
Reply With Quote
  #6   Spotlight this post!  
Unread 03-02-2011, 20:53
Robby Unruh's Avatar
Robby Unruh Robby Unruh is offline
*insert random dial-up tone here*
FRC #3266 (Robots R Us)
Team Role: Coach
 
Join Date: Feb 2010
Rookie Year: 2010
Location: Eaton, OH
Posts: 338
Robby Unruh will become famous soon enough
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.
__________________
[Robots R Us #3266]
2015: Georgia Southern Classic (Winners / Thanks 1319 & 1648!), Queen City
2014: Crossroads, Queen City
2013: Buckeye, Queen City, Crossroads
2012: Buckeye, Queen City

2011: Buckeye
2010: Buckeye
Reply With Quote
  #7   Spotlight this post!  
Unread 04-02-2011, 18:11
General25 General25 is offline
Registered User
FRC #3352
 
Join Date: May 2010
Location: Belevidere, IL
Posts: 2
General25 is an unknown quantity at this point
Re: Programming Mecanum?

@General25:
You'd probably get better answers in the Labview section, since this is Java.[/quote]

sorry, just searched for mecanum and programing
Reply With Quote
  #8   Spotlight this post!  
Unread 07-02-2011, 07:04
Robby Unruh's Avatar
Robby Unruh Robby Unruh is offline
*insert random dial-up tone here*
FRC #3266 (Robots R Us)
Team Role: Coach
 
Join Date: Feb 2010
Rookie Year: 2010
Location: Eaton, OH
Posts: 338
Robby Unruh will become famous soon enough
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;
}
__________________
[Robots R Us #3266]
2015: Georgia Southern Classic (Winners / Thanks 1319 & 1648!), Queen City
2014: Crossroads, Queen City
2013: Buckeye, Queen City, Crossroads
2012: Buckeye, Queen City

2011: Buckeye
2010: Buckeye
Reply With Quote
  #9   Spotlight this post!  
Unread 07-02-2011, 09:18
Ether's Avatar
Ether Ether is offline
systems engineer (retired)
no team
 
Join Date: Nov 2009
Rookie Year: 1969
Location: US
Posts: 8,088
Ether has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond repute
Re: Programming Mecanum?

Quote:
Originally Posted by Robby Unruh View Post
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?
Yes. There's an explanation here.



Reply With Quote
  #10   Spotlight this post!  
Unread 07-02-2011, 10:40
Robby Unruh's Avatar
Robby Unruh Robby Unruh is offline
*insert random dial-up tone here*
FRC #3266 (Robots R Us)
Team Role: Coach
 
Join Date: Feb 2010
Rookie Year: 2010
Location: Eaton, OH
Posts: 338
Robby Unruh will become famous soon enough
Re: Programming Mecanum?

Quote:
Originally Posted by Ether View Post
Yes. There's an explanation here.
Thanks for the link. I'm still a little confused here, though.
Could you please explain how I'm supposed to use forward/backward/clockwise in the drive train programming?
__________________
[Robots R Us #3266]
2015: Georgia Southern Classic (Winners / Thanks 1319 & 1648!), Queen City
2014: Crossroads, Queen City
2013: Buckeye, Queen City, Crossroads
2012: Buckeye, Queen City

2011: Buckeye
2010: Buckeye
Reply With Quote
  #11   Spotlight this post!  
Unread 07-02-2011, 11:32
Ether's Avatar
Ether Ether is offline
systems engineer (retired)
no team
 
Join Date: Nov 2009
Rookie Year: 1969
Location: US
Posts: 8,088
Ether has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond repute
Re: Programming Mecanum?

Quote:
Originally Posted by Robby Unruh View Post
Thanks for the link. I'm still a little confused here, though.
Could you please explain how I'm supposed to use forward/backward/clockwise in the drive train programming?
That is explained on the second page:

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
front_left, front_right, rear_left, rear_right are the commands to send to each mecanum wheel.

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.
Reply With Quote
  #12   Spotlight this post!  
Unread 08-02-2011, 08:10
Robby Unruh's Avatar
Robby Unruh Robby Unruh is offline
*insert random dial-up tone here*
FRC #3266 (Robots R Us)
Team Role: Coach
 
Join Date: Feb 2010
Rookie Year: 2010
Location: Eaton, OH
Posts: 338
Robby Unruh will become famous soon enough
Re: Programming Mecanum?

Quote:
Originally Posted by Ether View Post
That is explained on the second page:

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
front_left, front_right, rear_left, rear_right are the commands to send to each mecanum wheel.

If that's not what you were asking, please clarify your question and I'll try again.

Okay, thanks again. So I just send those wheels in the drive train like so:

Code:
RobotDrive driveTrain = new RobotDrive(front_left, rear_left, front_right, rear_right);
Then invert the motors like I've been doing, or...?
__________________
[Robots R Us #3266]
2015: Georgia Southern Classic (Winners / Thanks 1319 & 1648!), Queen City
2014: Crossroads, Queen City
2013: Buckeye, Queen City, Crossroads
2012: Buckeye, Queen City

2011: Buckeye
2010: Buckeye
Reply With Quote
  #13   Spotlight this post!  
Unread 08-02-2011, 08:24
Ether's Avatar
Ether Ether is offline
systems engineer (retired)
no team
 
Join Date: Nov 2009
Rookie Year: 1969
Location: US
Posts: 8,088
Ether has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond repute
Re: Programming Mecanum?

Quote:
Originally Posted by Robby Unruh View Post
Then invert the motors like I've been doing, or...?
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.


Reply With Quote
  #14   Spotlight this post!  
Unread 08-02-2011, 10:32
omalleyj omalleyj is offline
Registered User
AKA: Jim O'Malley
FRC #1279 (Cold Fusion)
Team Role: Mentor
 
Join Date: Jan 2008
Rookie Year: 2008
Location: New Jersey
Posts: 132
omalleyj is a splendid one to beholdomalleyj is a splendid one to beholdomalleyj is a splendid one to beholdomalleyj is a splendid one to beholdomalleyj is a splendid one to beholdomalleyj is a splendid one to beholdomalleyj is a splendid one to beholdomalleyj is a splendid one to behold
Re: Programming Mecanum?

Quote:
Originally Posted by Robby Unruh View Post
Okay, thanks again. So I just send those wheels in the drive train like so:

Code:
RobotDrive driveTrain = new RobotDrive(front_left, rear_left, front_right, rear_right);
Then invert the motors like I've been doing, or...?
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.
Reply With Quote
  #15   Spotlight this post!  
Unread 10-02-2011, 01:56
iNiLz iNiLz is offline
Mentor
no team (None)
Team Role: Mentor
 
Join Date: Feb 2010
Rookie Year: 2000
Location: NY
Posts: 5
iNiLz is an unknown quantity at this point
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);
    }

   }
}
I haven't tested it yet but will tomorrow.
Once I figure out how Cartisian works, I'll update the code.
Now to figure out the gyro and encoder.
Reply With Quote
Reply


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -5. The time now is 11:18.

The Chief Delphi Forums are sponsored by Innovation First International, Inc.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi