Mecanum Code weird bug need help

Using Windriver C++
4 wheel drive mecanum
Jaguars motor controllers (calibrated manually)
PWM
Logitech Extreme 3D Joystick

All electrical has been checked and while there is no such thing as an absolute appears to be wired accurately
We have reimaged the cRio to ensure we do not have garbage code randomly running

Using the mecanum base code provided by FIRST
Behavior we are seeing:

forward works as expected
reverse works as expected
strafe works as expected
Turning either direction (left or right) wheels do not spin in proper directions and fight each other

If anyone has time and is willing could you please help us find our error? I have attached all code and we would appreciate your help as this is interefering with our drive practice and we don’t want to upload broken code on our bot at competiton
Thank you…

code.txt (1.07 KB)


code.txt (1.07 KB)

I haven’t looked at the code, but could you describe how the wheels are mounted on the robot? do the rollers on the wheels make a diamond or an X on the ground?

i.e.

/
/ diamond

/
/\ X

I am their coach…rollers are in X pattern

Put it up on blocks and tell us which way the wheels are spinning.

It is possible the wheels are spinning the correct way, but you have the wheels mounted with the roller orientation incorrect.

For pure clockwise rotation, the left wheels should be spinning forward and the right wheels backward.

As viewed from above or below?

Viewed from above should be X

Viewed from below should be diamond.

Put vehicle up on blocks and command a turn and tell us what each of the 4 wheels is doing.

X from top and diamond from bottom is current setup. Testing now will post results in a few…minutes that is…

When joystick is twisted left:
‘front’ wheels spin backwards (both)
‘back’ wheels spin forward (both)

When joystick is twisted right:
‘front’ wheels spin forward (both)
‘back’ wheels spin backwards (both)

According to the programmer if he changes the code to make turning work properly then it will break strafing…?? Something is not sounding right to me on this…

That strongly suggests that the wheels themselves are installed wrong.

That’s not how they should be. To confirm the problem, try spinning the robot by hand with the power off. If it turns relatively easily, the wheels definitely need to be swapped.

Are the motors inverted in code or physically?
If lefts and rights were set as fronts and backs, and not inverted it would be consistent with what you describe.

According to our understanding the rollers should form an X when viewed from top and diamond from bottom

http://www.google.com/imgres?start=258&um=1&hl=en&sa=N&tbm=isch&tbnid=A0hrZMHyEdm5BM:&imgrefurl=http://140.138.40.170/OptimalWeb/articlesystem/article/compressedfile/(2010-08-22)%2520Platform%2520design%2520for%2520the%2520intelligent%2520robotic%2520wheelchair.aspx%3FArchID%3D1606&docid=0-XkJcQmMOnCDM&imgurl=http://140.138.40.170/OptimalWeb/articlesystem/article/compressedfile/(2010-08-22)%252520Platform%252520design%252520for%252520the%252520intelligent%252520robotic%252520wheelchair.files/image024.jpg&w=291&h=279&ei=I5dfT6_LN6fDsQKgr9WhCA&zoom=1&iact=hc&vpx=590&vpy=96&dur=1089&hovh=220&hovw=229&tx=120&ty=148&sig=101596276076487547616&page=12&tbnh=166&tbnw=180&ndsp=24&ved=1t:429,r:20,s:258&biw=1486&bih=723

Is this not correct? According to the instructions we recieved with the wheels this is correct…

Inverted physically.

I withdraw the ‘and not inverted’ part.
If Left are in front and Rights in the back (or vice versa):
stick forward all turn forward, ditto back
stick to the side and left and right counter rotate so you still strafe (if the front-rear of the two sides are also swapped relatively)
but if you try to turn in place fronts and backs go opposite

Sorry if that isn’t terribly clear, but I would check the order your controllers are in the constructor really match physical L-R/F-R

That is correct.

Assuming the wheels are installed correctly (X pattern viewing from the top), it could be a software issue. The way we software calibrated our mecanum drive train is as the following:

  • Make sure you put the PWM channels (or CAN IDs) in the correct sequence when instantiating RobotDrive(frontLeft, rearLeft, frontRight, rearRight).
  • Put the robot on some 2x4’s so the wheels can be freely turning without the robot running away.
  • In code, execute MecanumDrive_Cartesian(0.0, 0.5, 0.0) and make sure all the wheels are going forward.
  • If not, note the wheels that are turning backward and add the following line for each wheel that needs correction (need to change kFrontLeftMotor to the corresponding motors):
    SetInvertedMotor(kFrontLeftMotor, true);
  • Now, write the teleop code that uses the joystick(s) to drive the robot.
  • If tank drive, pushing the left joystick forward should turn the left wheels forward. If not add a minus in front of the joystickLeft.GetY().
  • Do the same for the tank drive right joystick.
  • If arcade drive, push the joystick forward should turn all four wheels forward. If they are reversed, put a minus in front of joystick.GetY().
  • For arcade drive, push the joystick to the right and the robot should turn right (left wheels forward and right wheels reverse). If not, put a minus in front of the joystick.GetX().
    *]Similarly, for strafe, correct the corresponding joystick sign if it is not going the direction you want.

how exactly would we write that if wanted to invert the motors for 1 and 3

Let’s say if motor 1 is the front left motor and motor 3 is the rear left motor.


SetInvertedMotor(kFrontLeftMotor, true);
SetInvertedMotor(kRearLeftMotor, true);

Trying this now…

ah, figured it out. it needs to be:

myRobot.SetInvertedMotor(myRobot.kFrontLeftMotor, true);
myRobot.SetInvertedMotor(myRobot.kRearLeftMotor, true);

thanks for the help, now it builds and I will see if it fixes the problem