Code Not Working

Hi,

The following code does not work on the new RoboRio. The original code WORKS on the old cRIO. All I did was update how Robot Drive Works as per the WPI Screen Steps Live Website. Information as to what does not work is as follows:

  1. The program builds correctly.
  2. The computer connects to the Robo Rio.
  3. The joystick is detected.
  4. When the joystick is moved, nothing happens.

Here is my code:


package org.usfirst.frc.team4687.robot;


import edu.wpi.first.wpilibj.SampleRobot;
import edu.wpi.first.wpilibj.RobotDrive;
import edu.wpi.first.wpilibj.Joystick;
import edu.wpi.first.wpilibj.*;



public class Robot extends SampleRobot 
{
	//Definitions
	Jaguar j1 = new Jaguar(1);
	Jaguar j2 = new Jaguar(2);
	Jaguar j3 = new Jaguar(3);
	Jaguar j4 = new Jaguar(4);
	Jaguar j5 = new Jaguar(5);
	Jaguar j6 = new Jaguar(6);
	Jaguar j7 = new Jaguar(7);
	Jaguar j8 = new Jaguar(8);
	RobotDrive driveA = new RobotDrive(j1,j2,j3,j4);
	RobotDrive driveB = new RobotDrive(j5,j6,j7,j8);
    
	Joystick drivestick = new Joystick(1);
	
    public void autonomous() 
    {
        
    }
    
    public void operatorControl() 
    {
    	//INSTANTIATION STATEMENTS
    	double joyX, joyY, joyZ;
    	
        if(isOperatorControl() && isEnabled())
        {
        	//Define the dead zone for driving
        	if(drivestick.getX() < 0.1 && drivestick.getX() > -0.1) joyX=0;
        	else joyX = drivestick.getX();
        	
        	if(drivestick.getY() < 0.1 && drivestick.getY() > -0.1) joyY=0;
        	else joyY = drivestick.getY();
        	
        	if(drivestick.getZ() < 0.1 && drivestick.getZ() > -0.1) joyZ=0;
        	else joyZ = drivestick.getZ();
        	
        	//Drive
        	driveA.mecanumDrive_Cartesian(joyX, joyY, joyZ, 0);
        	driveB.mecanumDrive_Cartesian(joyX, joyY, joyZ, 0);
        }
    }
    
    public void test() 
    {
    	
    }
    
    @Override
    public void disabled() 
    {
    
    }
    
}

Everything is hooked up correctly on the power distribution board and the other electronics issues. Does anyone see what is wrong?

Thanks all.

PS: Is there any way to run System.out.println() statements as there was in Netbeans? Can I just type System.out.println() and it will print to the eclipse console each time it is called?

Starting this year the “first” joystick is index 0, not 1. So you might need to move the joystick to slot ‘1’ from slot ‘0’ in the DS. Or just change the constructor param to ‘0’ from ‘1’.

println ouput should land in the riolog window.

Look for “Riolog” at…
http://wpilib.screenstepslive.com/s/4485/m/13809/l/284333-using-riolog-to-view-console-output

I tried switching the joystick to new Joystick(0); and nothing happened again. Anything else that looks off?

I am very confused why you have two RobotDrive instances, but I would recommend checking the lights on the Jaguars to verify they are receiving commands.

EDIT: I re-read it and found the error. operatorControl() is only called once. You should replace “if” with “while” to make it run constantly until telop is finished. Also add a Timer.delay(0.05) at the end to free up the cpu.

Thanks Joey, that was it. I must have written it wrong when copying the code over.