Hi all,
We have run into trouble with our pneumatics programming. We have everything set up correctly (we think) and all of the values our correctly set for the compressor and the solenoids. However, when we press the button assigned to set the solenoids to (TRUE) and then to (FALSE) the actuator doesn’t move. Does anyone see the problem in the following code?
#include “WPILib.h”
#include “sockLib.h”
#include “inetLib.h”
#include “hostLib.h”
/**
- This is a demo program showing the use of the RobotBase class.
- The SimpleRobot class is the base of a robot application that will automatically call your
- Autonomous and OperatorControl methods at the right time as controlled by the switches on
- the driver station or the field controls.
*/
class RobotDemo : public SimpleRobot
{
// CANJaguar leftFrontJag; // CAN attached Jag
// CANJaguar leftRearJag; // CAN attached Jag
// CANJaguar rightFrontJag; // CAN attached Jag
// CANJaguar rightRearJag; // CAN attached Jag
// RobotDrive myRobot;
Joystick stick; // only joystick
Solenoid sol1;
Solenoid sol2;
Compressor compress;
public:
RobotDemo(void):
// leftFrontJag(2),
// leftRearJag(4),
// rightFrontJag(6),
// rightRearJag(8),
// myRobot(leftFrontJag, leftRearJag, rightFrontJag, rightRearJag),
stick(1), // as they are declared above.
sol1(8,1),
sol2(8,2),
compress(5,2)
{
// myRobot.SetExpiration(0.1);
}
/**
* Drive left & right motors for 2 seconds then stop
*/
void Autonomous(void)
{
// myRobot.SetSafetyEnabled(false);
// myRobot.Drive(0.5, 0.0); // drive forwards half speed
// Wait(2.0); // for 2 seconds
// myRobot.Drive(0.0, 0.0); // stop robot
}
/**
* Runs the motors with arcade steering.
*/
void OperatorControl(void)
{
bool buttonPressed[17];
int indexVar;
// myRobot.SetSafetyEnabled(false);
compress.Start();
while (true)
{
}
while (IsOperatorControl() && !IsDisabled())
{
// myRobot.ArcadeDrive(stick); // drive with arcade style (use right stick)
for (indexVar=1; indexVar<2; indexVar++) {
buttonPressed[indexVar] = stick.GetRawButton(indexVar);
if (buttonPressed[indexVar]) {
switch (indexVar) {
case 1:
sol1.Set(TRUE);
sol2.Set(FALSE);
Wait(2.0);
sol2.Set(TRUE);
sol1.Set(FALSE);
break;/*
case 2:
sol2.Set(TRUE);
Wait(1.0);
sol2.Set(FALSE);
break;
case 3:
sol3.Set(TRUE);
Wait(1.0);
sol3.Set(FALSE);
break;
case 4:
sol4.Set(TRUE);
Wait(1.0);
sol4.Set(FALSE);
break;
case 5:
sol5.Set(TRUE);
Wait(1.0);
sol5.Set(FALSE);
break;
case 6:
sol6.Set(TRUE);
Wait(1.0);
sol6.Set(FALSE);
break;
case 7:
sol9.Set(TRUE);
Wait(1.0);
sol9.Set(FALSE);
break;
case 8:
sol10.Set(TRUE);
Wait(1.0);
sol10.Set(FALSE);
break;
case 9:
sol11.Set(TRUE);
Wait(1.0);
sol11.Set(FALSE);
break;
case 10:
sol12.Set(TRUE);
Wait(1.0);
sol12.Set(FALSE);
break;
case 11:
sol13.Set(TRUE);
Wait(1.0);
sol13.Set(FALSE);
break;
case 12:
sol14.Set(TRUE);
Wait(1.0);
sol14.Set(FALSE);
break;
case 13:
break;
case 14:
break;
case 15:
break;
case 16:
break;*/
default:
break;
}
} else {
// sol1.Set(FALSE);
// sol2.Set(FALSE);
// sol3.Set(FALSE);
// sol4.Set(FALSE);
// sol5.Set(FALSE);
// sol6.Set(FALSE);
// sol7.Set(FALSE);
// sol8.Set(FALSE);
// sol9.Set(FALSE);
// sol10.Set(FALSE);
// sol11.Set(FALSE);
// sol12.Set(FALSE);
// sol13.Set(FALSE);
// sol14.Set(FALSE);
// sol15.Set(FALSE);
// sol16.Set(FALSE);
}
}
Wait(0.005); // wait for a motor update time
}
compress.Stop();
}
};
START_ROBOT_CLASS(RobotDemo);