i’m using this code and everytihng works on our robot but the compressor won’t start. here is my code any help would be appreciated. thanks in advanced
//***************************************************************************
//2009 Sayville High School Robotics Code
//Uses a 2 motor tank drive system with 2 sim motors wired to jaguars
//has a front roller using a cut in half fisherprice motor wired to a victor
//has a beater bar system power by 1 sim motor wired to a victor
//has a compressor which uses standard compressor class to run during match
//has 2 solenoid that on run together with a pully system used to dump balls
//drive joysticks are standard usb joysticks fron kit of parts
//third joystick is used to control frontroller,beatbars,and both solenoids
//*************************************************************************
//INPUTS
//
//left drive motor(jaguar) - pwm1
//right drive motor(jaguar) - pwm2
//beater bars(victor) - pwm3
//front roller(victor) - pwm4
//Compressor1 - spike relay(relay1),pressure switch (digitalinput1)
//Solenoid 1 -solenoid 1
//Solenoid 2 - solenoid 2
//Left Joystick - USB 1
//Right Joystick - USB 2
//*************************************************************************
//NOTES
//
//victor can only run as slow as 10%
//jaguars can run as slow as 3%
//drive function is (speed,turn)
//setleftmotorrightmotorspeed function is (leftmotor,rightmotor)
//instead of speeds being 0 to 255(binary) speed has been normalized to be -1.0 to 1.0
//************************************************************************#include “WPILib.h” // include the WPI robotics library
class RobotDemo : public SimpleRobot //class being used is simple robot
//Global Varaibles
{
RobotDrive myRobot; //Robot Drive defines the 2 drive motors
Joystick LeftJoystick; // Defines Leftjoystick
Joystick RightJoystick; // Defines RightJoystick
Joystick ThirdJoystick; // Defines Thirdjoystick
Compressor *Compressor1; // Defines compressor
Solenoid *Solenoid1,*Solenoid2; // Defines Both soleoinds
Victor *FrontRoller, *BeaterBars; // Defines FrontRoller and BeaterBarspublic:
RobotDemo(void): // inizalation code
myRobot(1, 2), // drive motors are in pwm 1 and 2
LeftJoystick(1), // leftjoystick in usb port 1
RightJoystick(2), // rightjoystick in usb port 2
ThirdJoystick(3) // thirdjoystick in usb port 3
{
GetWatchdog().SetExpiration(100);
Compressor1 = new Compressor(1, 1); // compressor spike is in realy 1 and pressure switch is in digital input 1
Compressor1->Start(); // compressor will run when not fill during autonomous and operator control mode
Solenoid1 = new Solenoid(1); // solenoid1 is in solenoid module port 1
Solenoid2 = new Solenoid(2); // solenoid2 is in solenoid module port 2
FrontRoller = new Victor(3); // front roller motor in pwm 3
BeaterBars = new Victor(4); // beater bar motor in pwm 4
}void Autonomous(void) //start of autonomous
{
GetWatchdog().SetEnabled(false); //watchdog is disabled durning autonomous
myRobot.SetLeftRightMotorSpeeds(1.0, 1.0);
Wait(2.0);
myRobot.SetLeftRightMotorSpeeds(-1.0, 1.0);
Wait(2.0);
myRobot.SetLeftRightMotorSpeeds(1.0,0.0);
Wait(2.0);
myRobot.SetLeftRightMotorSpeeds(0.0,0.0);
}void OperatorControl(void) //start operator control
{
GetWatchdog().SetEnabled(true); // watchdog is enabled during operator control mode
while (IsOperatorControl())
{
GetWatchdog().Feed();
myRobot.TankDrive(LeftJoystick,RightJoystick); //2 Motor Tank Drive
{
{
if (ThirdJoystick.GetRawButton (1)==1 ) //if leftjoystick button 1(trigger) is click
{
Solenoid1->Set(true); // then solenoid1 will be out
Solenoid2->Set(true); // and solenoid2 will be out
}
else // if button 1(trigger) is not pressed
{
Solenoid1->Set(false); // solenoid1 will be in
Solenoid2->Set(false); // and solenoid2 will be in
}
}
{
if (ThirdJoystick.GetRawButton (3)==1 ) {
BeaterBars->Set(0.0); }
else
{
BeaterBars->Set(1.0); }
}
{
if (ThirdJoystick.GetRawButton (5)==1 ) {
FrontRoller->Set(0.0); }
else
{
FrontRoller->Set(1.0); }
}
}
}
}
};START_ROBOT_CLASS(RobotDemo); // start robot class and starup library(run program)