Chief Delphi

Chief Delphi (http://www.chiefdelphi.com/forums/index.php)
-   Java (http://www.chiefdelphi.com/forums/forumdisplay.php?f=184)
-   -   Compressor is not working (http://www.chiefdelphi.com/forums/showthread.php?t=113947)

Mubtasim 19-02-2013 10:53

Compressor is not working
 
We are having a problem with the compressor :(
The spike relay is orange; selenoid is communicating but the compressor never starts??
heres the code:
package edu.wpi.first.wpilibj.templates;

import edu.wpi.first.wpilibj.Compressor;
import edu.wpi.first.wpilibj.Joystick;
import edu.wpi.first.wpilibj.Relay;
import edu.wpi.first.wpilibj.RobotDrive;
import edu.wpi.first.wpilibj.SimpleRobot;
import edu.wpi.first.wpilibj.Solenoid;
import edu.wpi.first.wpilibj.Victor;
import edu.wpi.first.wpilibj.Jaguar;



public class RobotTemplate extends SimpleRobot {
private RobotDrive robotDrive = new RobotDrive(10,9);
private Joystick Stick = new Joystick(1);
private Jaguar Shooter = new Jaguar(5);
private Jaguar Loader = new Jaguar(6);
private Compressor compressor = new Compressor(2,2);
private Solenoid pistonUp = new Solenoid(1);
private Solenoid pistonDown = new Solenoid(2);
//Relay spikeRelay;
//private Relay spikeRelay = new Relay(2);

// public void robotInit() {

//spikeRelay = new Relay(2);}

public RobotTemplate() {
getWatchdog().setExpiration(0.5);
//spikeRelay.set(Relay.Value.kOn);
compressor.start();
//compressor.setRelayValue(Relay.Value.kForward);
}

public void operatorControl() {
getWatchdog().setEnabled(true);
while (isEnabled() && isOperatorControl()) {

getWatchdog().feed();
// robotDrive.setSafetyEnabled(false);
robotDrive.arcadeDrive(-Stick.getX(), Stick.getY());
robotDrive.setInvertedMotor(RobotDrive.MotorType.k RearLeft, true);


//spikeRelay.set(Relay.Value.kForward);



if (Stick.getTrigger()) {
pistonUp.set(true);
} else if (Stick.getRawButton(3)) {
pistonDown.set(true);
} else {
pistonUp.set(false);
pistonDown.set(false);
}
}

if (Stick.getRawButton(2)){
Shooter.set(.75);
} else {
Shooter.set(0);
}
if (Stick.getRawButton(5)){
Loader.set(.75);
} else {
Loader.set(0);
}
}

}

Arhowk 19-02-2013 10:57

Re: Compressor is not working
 
whenever you say

= new ##(parameters) (such as new Jaguar(1))

keep it all in your robot init function, because it has to run after the cRIO is done compiling.

also,

public RobotTemplate() will never run. it has to be public void robotInit()

Mubtasim 19-02-2013 12:52

Re: Compressor is not working
 
Didn't solve the problem, here is the simpler version of the code that we are starting all over from the begining (without messing with relay in the program):


package edu.wpi.first.wpilibj.templates;


import edu.wpi.first.wpilibj.SimpleRobot;
import edu.wpi.first.wpilibj.Compressor;
import edu.wpi.first.wpilibj.Solenoid;
import edu.wpi.first.wpilibj.Joystick;

public class RobotTemplate extends SimpleRobot {
private Joystick Stick = new Joystick(1);
private Compressor compressor = new Compressor(2,2);
private Solenoid pistonUP = new Solenoid(1);
private Solenoid pistonDOWN = new Solenoid(2);

public RobotTemplate(){
getWatchdog().setExpiration(0.5);
compressor.start();
}


/**
* This function is called once each time the robot enters operator control.
*/
public void operatorControl() {
getWatchdog().setEnabled(true);
while(isEnabled() && isOperatorControl()){
getWatchdog().feed();
if(Stick.getTrigger()){
pistonUP.set(true);
}else if(Stick.getRawButton(3)){
pistonDOWN.set(true);
}else{
pistonUP.set(false);
pistonDOWN.set(false);
}


}



}

/**
* This function is called once each time the robot enters test mode.
*/
public void test() {

}
}



:(

Mubtasim 19-02-2013 13:54

Re: Compressor is not working
 
Everything works nice and finenow. There was some complication withhardware.
Thanks :)


All times are GMT -5. The time now is 10:07.

Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi