View Single Post
  #4   Spotlight this post!  
Unread 02-02-2011, 18:50
Tds123's Avatar
Tds123 Tds123 is offline
There is no I in team =]
AKA: Timothy Shub
FRC #1396 (Pyrobots)
Team Role: Programmer
 
Join Date: Oct 2007
Rookie Year: 2007
Location: Tottenville High School
Posts: 27
Tds123 is an unknown quantity at this point
Send a message via AIM to Tds123
Re: Compressor programming please help

ok this is my whole code..


#include "WPILib.h"
#include "Vision/AxisCamera.h"
#include "Vision/HSLImage.h"
#include "DriverStationLCD.h"
//#include "AxisCamera.h"
//#include "FrcError.h"
#include "Vision/PCVideoServer.h"
#include "Compressor.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
{
RobotDrive myRobot; // robot drive system
Joystick leftjoy;
Joystick rightjoy;
Joystick armjoy;
Jaguar arm;
Relay piston;
Relay compressor;
DigitalInput compressor_switch;
DigitalInput limitswitch_foward;
DigitalInput limitswitch_reverse;
Servo x_axis;
Servo y_axis;
public:
RobotDemo(void):
myRobot(1, 2),
leftjoy(1),
rightjoy(2),
armjoy(3),
arm(3),
piston(4),
compressor(5),
compressor_switch(1),
limitswitch_foward(2),
limitswitch_reverse(3),
x_axis(10),
y_axis(9)
{
GetWatchdog().SetExpiration(1.00);
}
/*
*
* Drive left & right motors for 3 seconds then stop
*/
void Autonomous(void)
{
/*PCVideoServer * pyrocam = new PCVideoServer();
pyrocam->Start();*/
//AxisCamera &camera = AxisCamera::GetInstance(); // Creates an instance of the camera
// camera.
//AxisCamera &camera = AxisCamera::getInstance();
/*
x_axis.SetAngle(90);
y_axis.SetAngle(90);*/
GetWatchdog().SetEnabled(false);
}
/**
* Runs the motors with arcade steering.
*/
void OperatorControl(void)
{
GetWatchdog().SetEnabled(true);
while (IsOperatorControl())
{
GetWatchdog().Feed();
DriverStationLCD * lcd = DriverStationLCD::GetInstance();
// drive with arcade style (use right stick)
int clawclosebutton = 2;
float speedModifier = 1.00;
float armModifier = 0.75;
char m_motor[22];
char m_compressor[22];
char m_lim_switch[22];
char m_piston[22];
//LMV = Left Motor Value; RMV = Right Motor Value
sprintf(m_motor, "LMV: %f; RMV: %f;", leftjoy.GetY() * speedModifier, rightjoy.GetY() * speedModifier);
lcd->Printf(DriverStationLCD::kUser_Line1, 1, m_motor);
myRobot.TankDrive(leftjoy.GetY() * speedModifier, rightjoy.GetY() * speedModifier);
//myRobot.SetLeftRightMotorSpeeds(leftjoy.GetY() * speedModifier, rightjoy.GetY() * speedModifier);
//Compressor Operation
/* if(compressor_switch.Get() == 1) {
compressor.Set(Relay::kOff);
sprintf(m_compressor, "Comressors is Off;");
lcd->Printf(DriverStationLCD::kUser_Line2, 1, m_compressor);
lcd->UpdateLCD();
} else {
compressor.Set(Relay::kOn);
sprintf(m_compressor, "Comressors is On.");
lcd->Printf(DriverStationLCD::kUser_Line2, 1, m_compressor);
lcd->UpdateLCD();
}
*/
//if (rightjoy.GetRawButton(compressoronbutton) == 1) {
/* if(leftjoy.GetTrigger() == 1) {
//compressor.Set(Relay:
compressor.Set(Relay::kOff);
compressor.SetDirection(Relay::kForwardOnly);
sprintf(m_compressor, "Comressors is On.");
lcd->Printf(DriverStationLCD::kUser_Line2, 1, m_compressor);
} else {
compressor.Set(Relay::kOn);
sprintf(m_compressor, "Comressors is Off.");
lcd->Printf(DriverStationLCD::kUser_Line2, 1, m_compressor);
}
*/
compressor.Set(Relay::kOn);
//Arm operation
//Do not forget to include sensors,
//The following program is temporary.
/*if ((limitswitch_foward.Get() ==1) && (armjoy.GetY() > 0)) {
sprintf(m_lim_switch, "Front Switch Triggered.");
lcd->Printf(DriverStationLCD::kUser_Line3, 1, m_lim_switch);
arm.Set(0.0);
} else if ((limitswitch_reverse.Get() ==1) && (armjoy.GetY()< 0)) {
sprintf(m_lim_switch, "Rear Switch Triggered.");
lcd->Printf(DriverStationLCD::kUser_Line3, 1, m_lim_switch);
arm.Set(0.0);
} else{*/
sprintf(m_lim_switch, "Arm Y-Axis: %f", armjoy.GetY());
lcd->Printf(DriverStationLCD::kUser_Line3, 1, m_lim_switch);
arm.Set(armjoy.GetY() * armModifier);
//}
//Piston operation
if (armjoy.GetTrigger() == 1) {
sprintf(m_piston, "Arm: Clamped");
lcd->Printf(DriverStationLCD::kUser_Line4, 1, m_piston);
piston.SetDirection(Relay::kForwardOnly);
piston.Set(Relay::kOn);
} else if (armjoy.GetRawButton(clawclosebutton) == 1) {
sprintf(m_piston, "Arm: Opened");
lcd->Printf(DriverStationLCD::kUser_Line4, 1, m_piston);
piston.SetDirection(Relay::kReverseOnly);
piston.Set(Relay::kOn);
} else {
sprintf(m_piston, "Arm: Off");
lcd->Printf(DriverStationLCD::kUser_Line4, 1, m_piston);
piston.Set(Relay::kOff);
}
lcd->UpdateLCD();
/* HSLImage image; // Creates an image
AxisCamera &camera = AxisCamera::GetInstance(); // Creates an instance of the camera
camera.WriteResolution(AxisCameraParams::kResoluti on_160x120);
camera.WriteBrightness(0);
camera.GetImage(image.GetImaqImage()); // Gets the image from the camera
Wait(5.00); // wait for a motor update time {
*/
}
}
};
START_ROBOT_CLASS(RobotDemo);


Its not turning on the compressor for some reason by it self =/ any problems you can see in my code?
__________________
ThE sCaLeS oF bAlAnCe (Team 1396)
Reply With Quote