View Single Post
  #11   Spotlight this post!  
Unread 31-01-2011, 21:49
wdell wdell is offline
Registered User
AKA: William Dell
FRC #3999 (Shadetree Mechanics)
Team Role: Mentor
 
Join Date: Jan 2011
Rookie Year: 2010
Location: Killeen, Texas
Posts: 55
wdell has a spectacular aura aboutwdell has a spectacular aura about
Re: How do I upload code to the Robot with Java?

kk, in your declarations most of that doesn't need to be public. Try:

Code:
Joystick leftStick = new Joystick(1);
Joystick rightStick = new Joystick(2);
Jaguar jagFrontLeft = new Jaguar(1);
Jaguar jagFrontRight = new Jaguar(2);
Jaguar jagBackLeft = new Jaguar(3);
Jaguar jagBackRight = new Jaguar(4);
RobotDrive driveRobot = new RobotDrive(1, 3, 2, 4);
Gyro roboGyro = new Gyro(7);
double leftX =0;
double leftY =0;
double rotationRate =0;
double gyroAngle =0;
int i = 0;
Here's the first chunk of mine:

Code:
package edu.wpi.first.wpilibj.templates;

/**
 * @author   William Dell
 * @author   Team 647
 * @version  v7, January 29, 2011
 * @version  FRC Java version 2011.4
 */

import edu.wpi.first.wpilibj.SimpleRobot;

import edu.wpi.first.wpilibj.Joystick;
import edu.wpi.first.wpilibj.Timer;

import edu.wpi.first.wpilibj.Gyro;

import edu.wpi.first.wpilibj.Victor;
// import edu.wpi.first.wpilibj.Jaguar;  // for change to production bot
import edu.wpi.first.wpilibj.RobotDrive;

public class Main extends SimpleRobot {

    DStation station; // consolidated, simplified dash and driver station
    Joystick controllerOne = new Joystick(1);
    Timer timer = new Timer(); // one timer to rule them all....
    Gyro spinGyro = new Gyro(1);
    Kamera cam;  // consolidated web cam controller
    
    //------------Drive System-----------------//
    Victor leftFrontVictor = new Victor(1);
    Victor rightFrontVictor = new Victor(2);
    RobotDrive drive = new RobotDrive(leftFrontVictor, rightFrontVictor);

    /*  4 motor drive for production bot commented out here
    Jaguar leftFrontJaguar = new Jaguar(1);
    Jaguar leftRearJaguar = new Jaguar(2);
    Jaguar rightFrontJaguar = new Jaguar(3);
    Jaguar rightRearJaguar = new Jaguar(4);
    RobotDrive drive = new RobotDrive(leftFrontJaguar, leftRearJaguar,
    rightFrontJaguar, rightRearJaguar);
     */
    AutoDrive autodrive; // simple autonomous routines

    /**
     * This method is called once when the robot boots up.
     */
    public void robotInit() {
AND I just found your problem. You're declaring your robot drive wrong. You have
Code:
RobotDrive driveRobot = new RobotDrive(1, 3, 2, 4);
when you should have
Code:
RobotDrive driveRobot = new RobotDrive(jagFrontLeft,jagBackLeft,jagFrontRight,jagBackRight);
What was happening is it would hit the Jaguar declaration and assign the PWM port to the jag. Then you're RobotDrive declaration would try to assign the PWM ports directly instead of going through the jaguars.
Reply With Quote