View Single Post
  #2   Spotlight this post!  
Unread 30-01-2012, 23:09
eddie12390's Avatar
eddie12390 eddie12390 is offline
Registered User
AKA: Eddie
FRC #3260 (SHARP)
Team Role: Programmer
 
Join Date: Jan 2011
Rookie Year: 2011
Location: Pittsburgh
Posts: 285
eddie12390 is a glorious beacon of lighteddie12390 is a glorious beacon of lighteddie12390 is a glorious beacon of lighteddie12390 is a glorious beacon of lighteddie12390 is a glorious beacon of light
Re: Problematic Java code

-You don't need to feed the watchdog.
-It seems that you should be using MecanumDrivePolar as opposed to cartesian as you are just giving it a 0 for the Gyro angle.
-The magnitude and direction degrees values of mecanumDrive do not work the way that you are supplying them values. They take an actual value for magnitude and directionDegrees. You can just use mainPad.getMagnitude() and mainPad.getDirectionDegrees()

I'll look more in depth and tell you if I find any other issues.

The following are not so much problems but can be useful:
-Try to name your motors things that make sense. "motor1" may be something useful to you but to anyone else who looks at it is impossible to tell what this is without going to the robot and checking out the wiring. Things like FRONT_LEFT_JAG make more sense to everyone.

This code will be enough to get your robot moving from the one game pad in a typical mecanum drive type of way.

Code:
    
    RobotDrive driveObject;
    Joystick mainPad;
    Jaguar motor1;
    Jaguar motor2;
    Jaguar motor3;
    Jaguar motor4;
    
    public void robotInit() {
        mainPad = new Joystick(1);
        motor1 = new Jaguar(1);
        motor2 = new Jaguar(2);
        motor3 = new Jaguar(3);
        motor4 = new Jaguar(4);
        driveObject = new RobotDrive(motor1, motor2, motor4, motor3);
    }
    
    public void teleopPeriodic() {
        driveObject.mecanumDrive_Polar(mainPad.getMagnitude(), mainPad.getDirectionDegrees(), mainPad.getTwist());
    }
}
Please note that I have removed all unused methods and any commenting along with the class declaration and imports in order to shorten the amount of code posted. You can simply copy the teleopPeriodic that I have provided into your program and it should work just fine.

Last edited by eddie12390 : 30-01-2012 at 23:18.
Reply With Quote