View Single Post
  #1   Spotlight this post!  
Unread 16-02-2013, 10:23
normaldude8825 normaldude8825 is offline
Registered User
FRC #1872
 
Join Date: Jan 2012
Location: Puerto Rico
Posts: 8
normaldude8825 is an unknown quantity at this point
Help with Mecanum Code

Greeting, I am this year's programmer for the team I am part of and I am having some problems with the mecanum code. Could someone please help me out with the code or tell me the axis and button mapping for the Logitech Attack 3? The team wishes to use to Logitech Attack 3 joysticks to control the robot's movement. The first one to control the robot to move forward, back and sideways and the second joystick to make the robot rotate. The problem so far is the the joysticks move the robot in an undesired manner. By this I mean that the first joystick only controls if moved sideways and it causes the robot to rotate and the other joystick makes the robot try to move sideways activating only two motors with the X axis and rotate with moving the joystick forward only. Here is the mecanum code:
SpeedController frontLeftMotor =new Jaguar(1),
rearLeftMotor = new Jaguar (2),
frontRightMotor = new Jaguar (3),
rearRightMotor = new Jaguar (4);

RobotDrive drive=new RobotDrive(frontLeftMotor, rearLeftMotor, frontRightMotor, rearRightMotor);
Joystick leftStick=new Joystick(1);
Joystick rightStick=new Joystick(2);
drive.mecanumDrive_Cartesian(leftStick.getMagnitud e(), leftStick.getDirectionDegrees(), rightStick.getX(),0);

The only code I have gotten to work is with a Xbox 360 controller, but the team doesn't want to use an Xbox controller and I have seen in the forums that it is not highly recommended. Just in case here is the code for that:

RobotDrive chassis= new RobotDrive(1,2,3,4);
Joystick xboxController= new Joystick(1);
chassis.mecanumDrive_Cartesian(xboxController.getR awAxis(1), xboxController.getRawAxis(4), xboxController.getRawAxis(2), 0);
Reply With Quote