|
|
|
![]() |
|
|||||||
|
||||||||
|
|
Thread Tools | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
Should this code be working? - Beginner
URGENT:
Code:
package edu.wpi.first.wpilibj.templates;
import edu.wpi.first.wpilibj.Compressor;
import edu.wpi.first.wpilibj.Jaguar;
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.Timer;
import edu.wpi.first.wpilibj.Victor;
public class RobotTemplate extends SimpleRobot {
RobotDrive theRobot = new RobotDrive(2,1); //#
Joystick driveStick = new Joystick(1); //#
Compressor compressor1 = new Compressor(1,1); //#
Relay spike = new Relay (1,1); //#
Jaguar motorOne = new Jaguar(7); //#
Jaguar motorTwo = new Jaguar(8); //#
Victor victor1 = new Victor(3);
Victor victor2 = new Victor(4);
public void autonomous() { //checks code every 50 seconds
theRobot.setSafetyEnabled(false); //allows timer to function
theRobot.drive(-1, 0.0); //-1 means drive forward
Timer.delay(2.0); // allows robot to drive forward
theRobot.drive(1.0, 0.0); // sets drive speed to 0 (stops robot)
Timer.delay(2.0);
theRobot.drive(-2, 0.0);
theRobot.drive(0.0, 0.0);
compressor1.start();
//Timer.delay(5.0);
for (int x = 0; x < 5; x++) {
spike.set(Relay.Value.kForward);
Timer.delay(2.0);
spike.set(Relay.Value.kReverse);
Timer.delay(2.0);
}
}
public void operatorControl() {
theRobot.setSafetyEnabled(false); //allows for tele-op to work
theRobot.arcadeDrive(driveStick.getAxis(Joystick.AxisType.kY), -driveStick.getAxis(Joystick.AxisType.kX)); //functionality to drive robot
while (isOperatorControl()) {
compressor1.start();
theRobot.arcadeDrive(driveStick.getAxis(Joystick.AxisType.kY), -driveStick.getAxis(Joystick.AxisType.kX));
if (driveStick.getTrigger()){
victor1.set(1.0);
victor2.set(1.0);
// spike.set(Relay.Value.kForward);
// spike.set(Relay.Value.kReverse);
}
else {
victor1.set(0.0);
victor2.set(0.0);
}
if (driveStick.getRawButton(4)){
spike.set(Relay.Value.kReverse);
}
else{
spike.set(Relay.Value.kForward);
}
}
}
public void test() {
}
}
Compressor Relay/Spike Currently, the driving is working and the motors are working but the compressor/relay/spike aren't working. Can someone also explain this: Sometimes when I edit the compressor object and do something like (2,1) as parameters, it says output not updated often enough repeatedly. When I do 1,1 - the program starts with no errors and everything works except compressor and relay/spike. When I do 1,2 --> IT ALSO works except compressor/relay/spike.... I double checked with the electrical team and they say the port numbers should be 1,1 but I'm not sure. I tested with 2,1 - 1,1 - 1,2 and nothing worked. For some port numbers, it would say output not updated enough and some combinations it wouldn't. Does that mean it does connect to compressor or is a connection loose? I'm thinking of switching over to iterative because it might be a bit easier. Last edited by hasin5 : 06-01-2014 at 18:48. |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|