Go to Post "Take a man to a FIRST contest and he's entertained for three days. Teach a man to build a FIRST robot, and he's out of your hair for six weeks a year..." - kmcclary [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 04-02-2014, 14:43
PANTHERPROJECT's Avatar
PANTHERPROJECT PANTHERPROJECT is offline
Registered User
FRC #2064 (The Panther Project)
Team Role: Webmaster
 
Join Date: Dec 2013
Rookie Year: 2007
Location: Southbury, Middlebury
Posts: 14
PANTHERPROJECT will become famous soon enoughPANTHERPROJECT will become famous soon enough
Programming Mecanum

Hi! I'm having trouble programming the mecanum wheels. I can make the robot move sideways and rotate but I cannot make it move forward and backward and I'm not sure why. I included the important parts of my code below.

Code:
Joystick joy1 = new Joystick(1);

RobotDrive drivetrain = new RobotDrive(1, 3, 2, 4);//Front Left - 1, Rear Left - 2, Front Right - 3, Rear Right - 4

double magnitude = joy1.getMagnitude();
double direction = joy1.getDirectionDegrees();
double rotation = joy1.getZ(); 

drivetrain.mecanumDrive_Polar(magnitude, direction, rotation);
I know for certain that it isn't an issue with the wiring. I tried using two joysticks instead of one but that didn't work either. I've pretty much run out of ideas at this point and hope someone can help. Thank you!

Last edited by PANTHERPROJECT : 04-02-2014 at 14:47.
Reply With Quote
  #2   Spotlight this post!  
Unread 04-02-2014, 14:58
notmattlythgoe's Avatar
notmattlythgoe notmattlythgoe is offline
Flywheel Police
AKA: Matthew Lythgoe
FRC #2363 (Triple Helix)
Team Role: Mentor
 
Join Date: Feb 2010
Rookie Year: 2009
Location: Newport News, VA
Posts: 1,715
notmattlythgoe has a reputation beyond reputenotmattlythgoe has a reputation beyond reputenotmattlythgoe has a reputation beyond reputenotmattlythgoe has a reputation beyond reputenotmattlythgoe has a reputation beyond reputenotmattlythgoe has a reputation beyond reputenotmattlythgoe has a reputation beyond reputenotmattlythgoe has a reputation beyond reputenotmattlythgoe has a reputation beyond reputenotmattlythgoe has a reputation beyond reputenotmattlythgoe has a reputation beyond repute
Re: Programming Mecanum

Have you tried just using the X, Y, and Z axis instead of the Magnitude and Direction?
Reply With Quote
  #3   Spotlight this post!  
Unread 04-02-2014, 15:00
PANTHERPROJECT's Avatar
PANTHERPROJECT PANTHERPROJECT is offline
Registered User
FRC #2064 (The Panther Project)
Team Role: Webmaster
 
Join Date: Dec 2013
Rookie Year: 2007
Location: Southbury, Middlebury
Posts: 14
PANTHERPROJECT will become famous soon enoughPANTHERPROJECT will become famous soon enough
Re: Programming Mecanum

I have but it didn't help.
Reply With Quote
  #4   Spotlight this post!  
Unread 04-02-2014, 15:15
Ether's Avatar
Ether Ether is offline
systems engineer (retired)
no team
 
Join Date: Nov 2009
Rookie Year: 1969
Location: US
Posts: 8,042
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


Put the bot up on blocks (wheels off the ground) and give it a pure forward command. Tell us what each of the four wheels do.


Reply With Quote
  #5   Spotlight this post!  
Unread 04-02-2014, 18:19
Joe Derrick's Avatar
Joe Derrick Joe Derrick is offline
Mentor - Programming
FRC #0319
 
Join Date: Feb 2012
Rookie Year: 2011
Location: Prospect Mountain High School
Posts: 44
Joe Derrick is a glorious beacon of lightJoe Derrick is a glorious beacon of lightJoe Derrick is a glorious beacon of lightJoe Derrick is a glorious beacon of lightJoe Derrick is a glorious beacon of lightJoe Derrick is a glorious beacon of light
Re: Programming Mecanum

You could check to see if your drive motors need to be inverted. You could do this in code, or just swap red/black on one side of your robot.

Might not be the answer but another thing to try!
__________________
2010-2017 Mentor Team 319
2012 - Rockwell Automation Award Winner
2014 - Xerox Creativity in Engineering Winner, Archimedes Division
2015 - Rockwell Automation and Gracious Proffesionalism Winner, Tesla Division
2016 - North Shore and UNH District Event Winner, Carson Division
http://www.frc319.com
Reply With Quote
  #6   Spotlight this post!  
Unread 04-02-2014, 22:09
nyaculak nyaculak is offline
Registered User
FRC #0053 (Area 53)
Team Role: Programmer
 
Join Date: Oct 2011
Rookie Year: 2011
Location: Maryland
Posts: 28
nyaculak will become famous soon enough
Re: Programming Mecanum

Quote:
Originally Posted by PANTHERPROJECT View Post

Code:
Joystick joy1 = new Joystick(1);

RobotDrive drivetrain = new RobotDrive(1, 3, 2, 4);//Front Left - 1, Rear Left - 2, Front Right - 3, Rear Right - 4
I think you instantiated your RobotDrive instance with the motors in the wrong order. Correct me if I'm wrong, but the order should be frontLeft, rearLeft, frontRight, rearRight. Try changing the instatiation to

Code:
RobotDrive drivetrain = new RobotDrive(1, 2, 3, 4);
If that doesn't work, try as others have suggested and mount the robot up on blocks to isolate the wheels. This helps tremendously in debugging a faulty drive train.
__________________
2013 MUC DC 3rd Place, FRC DC Regional, FRC Chesapeake Regional
2012 FRC DC Regional, FRC Chesapeake Regional
ERHS Robotics Club
- FRC Team 53 "Area 53"
www.erhsroboticsclub.org

Last edited by nyaculak : 04-02-2014 at 22:10. Reason: Forgot to close code tag in the quote...like html all over again ;)
Reply With Quote
  #7   Spotlight this post!  
Unread 09-02-2014, 17:40
PANTHERPROJECT's Avatar
PANTHERPROJECT PANTHERPROJECT is offline
Registered User
FRC #2064 (The Panther Project)
Team Role: Webmaster
 
Join Date: Dec 2013
Rookie Year: 2007
Location: Southbury, Middlebury
Posts: 14
PANTHERPROJECT will become famous soon enoughPANTHERPROJECT will become famous soon enough
Re: Programming Mecanum

Quote:
Originally Posted by Ether View Post

Put the bot up on blocks (wheels off the ground) and give it a pure forward command. Tell us what each of the four wheels do.


All the wheels spin inwards
Reply With Quote
  #8   Spotlight this post!  
Unread 09-02-2014, 17:42
PANTHERPROJECT's Avatar
PANTHERPROJECT PANTHERPROJECT is offline
Registered User
FRC #2064 (The Panther Project)
Team Role: Webmaster
 
Join Date: Dec 2013
Rookie Year: 2007
Location: Southbury, Middlebury
Posts: 14
PANTHERPROJECT will become famous soon enoughPANTHERPROJECT will become famous soon enough
Re: Programming Mecanum

Quote:
Originally Posted by nyaculak View Post
I think you instantiated your RobotDrive instance with the motors in the wrong order. Correct me if I'm wrong, but the order should be frontLeft, rearLeft, frontRight, rearRight. Try changing the instatiation to

Code:
RobotDrive drivetrain = new RobotDrive(1, 2, 3, 4);
If that doesn't work, try as others have suggested and mount the robot up on blocks to isolate the wheels. This helps tremendously in debugging a faulty drive train.
That is how I instantiated it originally. When I did that, the wheels moved forward, backward and rotated but did not move side to side.
Reply With Quote
  #9   Spotlight this post!  
Unread 09-02-2014, 18:30
Ether's Avatar
Ether Ether is offline
systems engineer (retired)
no team
 
Join Date: Nov 2009
Rookie Year: 1969
Location: US
Posts: 8,042
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 PANTHERPROJECT View Post
All the wheels spin inwards
That's why it won't go forward of course.

What do the wheels do when you give a pure reverse command?

A pure strafe right command?

etc

Last edited by Ether : 09-02-2014 at 18:37.
Reply With Quote
  #10   Spotlight this post!  
Unread 09-02-2014, 21:28
PANTHERPROJECT's Avatar
PANTHERPROJECT PANTHERPROJECT is offline
Registered User
FRC #2064 (The Panther Project)
Team Role: Webmaster
 
Join Date: Dec 2013
Rookie Year: 2007
Location: Southbury, Middlebury
Posts: 14
PANTHERPROJECT will become famous soon enoughPANTHERPROJECT will become famous soon enough
Re: Programming Mecanum

Quote:
Originally Posted by Ether View Post
That's why it won't go forward of course.

What do the wheels do when you give a pure reverse command?

A pure strafe right command?

etc
When given the pure reverse command, I believe they all spin outward but the wheels work fine while shifting to the right, left and rotating so if I were to invert the motors it wouldn't help much.
Reply With Quote
  #11   Spotlight this post!  
Unread 10-02-2014, 07:47
notmattlythgoe's Avatar
notmattlythgoe notmattlythgoe is offline
Flywheel Police
AKA: Matthew Lythgoe
FRC #2363 (Triple Helix)
Team Role: Mentor
 
Join Date: Feb 2010
Rookie Year: 2009
Location: Newport News, VA
Posts: 1,715
notmattlythgoe has a reputation beyond reputenotmattlythgoe has a reputation beyond reputenotmattlythgoe has a reputation beyond reputenotmattlythgoe has a reputation beyond reputenotmattlythgoe has a reputation beyond reputenotmattlythgoe has a reputation beyond reputenotmattlythgoe has a reputation beyond reputenotmattlythgoe has a reputation beyond reputenotmattlythgoe has a reputation beyond reputenotmattlythgoe has a reputation beyond reputenotmattlythgoe has a reputation beyond repute
Re: Programming Mecanum

Quote:
Originally Posted by PANTHERPROJECT View Post
When given the pure reverse command, I believe they all spin outward but the wheels work fine while shifting to the right, left and rotating so if I were to invert the motors it wouldn't help much.
I'm pretty sure nyaculak is correct that you have the motors going into the RobotDrive object incorrectly. It should be frontLeft, rearLeft, frontRight, rearRight.

Code:
RobotDrive(int frontLeftMotor, int rearLeftMotor, int frontRightMotor, int rearRightMotor) 
          Constructor for RobotDrive with 4 motors specified with channel numbers.
Reply With Quote
  #12   Spotlight this post!  
Unread 10-02-2014, 21:35
BradAMiller BradAMiller is offline
Registered User
AKA: Brad
#0190 ( Gompei and the Herd)
Team Role: Mentor
 
Join Date: Mar 2004
Location: Worcester, MA
Posts: 588
BradAMiller has a brilliant futureBradAMiller has a brilliant futureBradAMiller has a brilliant futureBradAMiller has a brilliant futureBradAMiller has a brilliant futureBradAMiller has a brilliant futureBradAMiller has a brilliant futureBradAMiller has a brilliant futureBradAMiller has a brilliant futureBradAMiller has a brilliant futureBradAMiller has a brilliant future
Re: Programming Mecanum

Code for doing Mecanum with joysticks looks like this:

Code:
myRobotDrive.mecanumDrive_Cartesian(joy1.getX(), joy1.getY(), joy1.getTwist());
Optionally you can put the angle from a gyro in as the optional 4th parameter.

One possible problem is that some of the motors may need to be inverted depending on how they are configured. To determine that, put the robot on blocks and drive it with the joysticks and see what it is doing. You can call the

Code:
setInvertedMotor()
method on the side that is going in the wrong direction.
__________________
Brad Miller
Robotics Resource Center
Worcester Polytechnic Institute
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 09:34.

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