View Single Post
  #4   Spotlight this post!  
Unread 01-02-2012, 11:53
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: New to FRC programming... How does this look?

This may just be one of the things that I do and find useful, but creating constants for port numbers can be extremely useful for someone who has not read your code and is not using your robot.

Things like
Code:
private static final int DRIVE_LEFT_FRONT = 1;
Jaguar frontLeftDrive = new Jaguar(DRIVE_LEFT_FRONT);
will be a lot easier for others to understand. (And when you want to make a change you can just find your constants and type in a new number)

Also, to find the x axis/y axis value just type joystick.getX() or joystick.getY(). You also do not need to set the value of the joystick to a double before supplying it to the drive() method.

Code:
    public static String log(String aMessage){
        System.out.println(aMessage);
        return aMessage;
    }
The above would probably just be better off as a void where you don't have to bother with the return type. You'll just be telling yourself something that you already know.

Last edited by eddie12390 : 01-02-2012 at 11:56.
Reply With Quote