Chief Delphi

Chief Delphi (http://www.chiefdelphi.com/forums/index.php)
-   Java (http://www.chiefdelphi.com/forums/forumdisplay.php?f=184)
-   -   Programming Mecanum (http://www.chiefdelphi.com/forums/showthread.php?t=125812)

PANTHERPROJECT 04-02-2014 14:43

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!

notmattlythgoe 04-02-2014 14:58

Re: Programming Mecanum
 
Have you tried just using the X, Y, and Z axis instead of the Magnitude and Direction?

PANTHERPROJECT 04-02-2014 15:00

Re: Programming Mecanum
 
I have but it didn't help.

Ether 04-02-2014 15:15

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.



Joe Derrick 04-02-2014 18:19

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!

nyaculak 04-02-2014 22:09

Re: Programming Mecanum
 
Quote:

Originally Posted by PANTHERPROJECT (Post 1337560)

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.

PANTHERPROJECT 09-02-2014 17:40

Re: Programming Mecanum
 
Quote:

Originally Posted by Ether (Post 1337584)

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

PANTHERPROJECT 09-02-2014 17:42

Re: Programming Mecanum
 
Quote:

Originally Posted by nyaculak (Post 1337776)
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.

Ether 09-02-2014 18:30

Re: Programming Mecanum
 
Quote:

Originally Posted by PANTHERPROJECT (Post 1340214)
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

PANTHERPROJECT 09-02-2014 21:28

Re: Programming Mecanum
 
Quote:

Originally Posted by Ether (Post 1340227)
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.

notmattlythgoe 10-02-2014 07:47

Re: Programming Mecanum
 
Quote:

Originally Posted by PANTHERPROJECT (Post 1340341)
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.


BradAMiller 10-02-2014 21:35

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.


All times are GMT -5. The time now is 09:33.

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