Go to Post They have obviously figuered out something special. I want to learn from them. - dlavery [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 25-05-2014, 02:13
JackOfAllTrade5's Avatar
JackOfAllTrade5 JackOfAllTrade5 is offline
Captain
AKA: Austin
FRC #3673 (C.Y.B.O.R.G. SEAGULLS)
Team Role: Engineer
 
Join Date: Apr 2014
Rookie Year: 2013
Location: United States
Posts: 8
JackOfAllTrade5 is an unknown quantity at this point
Lightbulb Mecanum drive code

Hey guys our team just got mecanum wheels but I have no idea how to write the code for these... We use java and have two sets of joysticks we can use. One set has a z axis and the other doesn't so whatever is easier. Any help is appreciated! Thanks in advance.
Reply With Quote
  #2   Spotlight this post!  
Unread 25-05-2014, 10:58
NWChen's Avatar
NWChen NWChen is offline
Alum
no team
 
Join Date: Oct 2012
Rookie Year: 2012
Location: New York City
Posts: 205
NWChen is a splendid one to beholdNWChen is a splendid one to beholdNWChen is a splendid one to beholdNWChen is a splendid one to beholdNWChen is a splendid one to beholdNWChen is a splendid one to beholdNWChen is a splendid one to behold
Re: Mecanum drive code

WPILibJ currently supports two mecanum control methods. They are methods of RobotDrive (thanks to 2168 for the API mirror).

If you have a gyro on your robot, you can try field-centric (cartesian) control. This means that, regardless of orientation, your robot will move in the direction that your joystick points. For field-centric control, you can call the mecanumDrive_Cartesian method of RobotDrive:
Code:
RobotDrive drive;
Joystick joystick;
Gyro gyro;
...
//assign drive, joystick, and gyro to their respective ports
...
drive.mecanumDrive_Cartesian(joystick.getX(), joystick.getY(), joystick.getTwist(), gyro.getAngle());
Alternatively, if your robot has no gyro, you can use robot-centric (polar) control. This means that your robot will move in the direction that your joystick points, relative to itself. For robot-centric control, call the mecanumDrive_Polar method of RobotDrive:
Code:
drive.mecanumDrive_Polar(joystick.getMagnitude(), joystick.getDirectionDegrees(), joystick.getTwist());
I would recommend you look more at the above link to see what you can do for mecanum control. Note that both RobotDrive methods here rely upon having a joystick with a z-axis, where the z-axis controls the rotation/turning of the robot (and is used by the getTwist() method).
__________________
2012 - 2015 • Team 2601


Last edited by NWChen : 25-05-2014 at 11:01.
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 22:40.

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