Go to Post By seeing other robot designs, teams can plan before hand on how to defend or defeat it. - Don Wright [more]
Home
Go Back   Chief Delphi > Technical > Programming > C/C++
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
 
 
Thread Tools Rate Thread Display Modes
Prev Previous Post   Next Post Next
  #3   Spotlight this post!  
Unread 06-03-2010, 17:12
Briyanna Briyanna is offline
Registered User
FRC #2895
 
Join Date: Mar 2010
Location: Queens, New York
Posts: 2
Briyanna is an unknown quantity at this point
Re: Compressor Code problems

Quote:
class BuiltinDefaultCode : public IterativeRobot
{
// Declare variable for the robot drive system
RobotDrive *m_robotDrive; // robot will use PWM 1-4 for drive motors

// Declare a variable to use to access the driver station object
DriverStation *m_ds; // driver station object
UINT32 m_priorPacketNumber; // keep track of the most recent packet number from the DS
UINT8 m_dsPacketsReceivedInCurrentSecond; // keep track of the ds packets received in the current second

//Declare variable for the compressor
private: Compressor *compressor;

// Declare variables for the two joysticks being used
Joystick *m_rightStick; // joystick 1 (arcade stick or right tank stick)
Joystick *m_leftStick; // joystick 2 (tank left stick)

static const int NUM_JOYSTICK_BUTTONS = 16;
bool m_rightStickButtonState[(NUM_JOYSTICK_BUTTONS+1)];
bool m_leftStickButtonState[(NUM_JOYSTICK_BUTTONS+1)];


// Declare variables for each of the eight solenoid outputs
static const int NUM_SOLENOIDS = 6;
Solenoid *m_solenoids[(NUM_SOLENOIDS+1)];


enum { // drive mode selection
UNINITIALIZED_DRIVE = 0,
ARCADE_DRIVE = 1,
TANK_DRIVE = 2
} m_driveMode;

// Local variables to count the number of periodic loops performed
UINT32 m_autoPeriodicLoops;
UINT32 m_disabledPeriodicLoops;
UINT32 m_telePeriodicLoops;

public:
/**
* Constructor for this "BuiltinDefaultCode" Class.
*
* The constructor creates all of the objects used for the different inputs and outputs of
* the robot. Essentially, the constructor defines the input/output mapping for the robot,
* providing named objects for each of the robot interfaces.
*/
BuiltinDefaultCode(void) {
printf("BuiltinDefaultCode Constructor Started\n");

// Create a robot using standard right/left robot drive on PWMS 1, 2, 3, and #4
m_robotDrive = new RobotDrive(1, 3, 2, 4);

// Acquire the Driver Station object
m_ds = DriverStation::GetInstance();
m_priorPacketNumber = 0;
m_dsPacketsReceivedInCurrentSecond = 0;

// Define joysticks being used at USB port #1 and USB port #2 on the Drivers Station
m_rightStick = new Joystick(1);
m_leftStick = new Joystick(2);

// Iterate over all the buttons on each joystick, setting state to false for each
UINT8 buttonNum = 1; // start counting buttons at button 1
for (buttonNum = 1; buttonNum <= NUM_JOYSTICK_BUTTONS; buttonNum++) {
m_rightStickButtonState[buttonNum] = false;
m_leftStickButtonState[buttonNum] = false;
}


// Declare variable to Activate the Compressor
Compressor *compressor=new Compressor(1,1);
compressor ->Start();


// Iterate over all the solenoids on the robot, constructing each in turn
UINT8 solenoidNum = 1; // start counting solenoids at solenoid 1
for (solenoidNum = 1; solenoidNum <= NUM_SOLENOIDS; solenoidNum++)
{
m_solenoids[solenoidNum] = new Solenoid(solenoidNum);

}



// Set drive mode to uninitialized
m_driveMode = UNINITIALIZED_DRIVE;

// Initialize counters to record the number of loops completed in autonomous and teleop modes
m_autoPeriodicLoops = 0;
m_disabledPeriodicLoops = 0;
m_telePeriodicLoops = 0;

printf("BuiltinDefaultCode Constructor Completed\n");
}

//*Compressor

if (Joystick(1).GetRawButton(10)) //if button 10 is pressed on joystick 1 compressor will turn on
{
int compressor= new Compressor(1, 1);

compressor.Set(true);

}
if (Joystick(1).GetRawButton(11)) //if button 11 is pressed on joystick 1 compressor will turn off
{
compressor.Set(false);
}

// Solenoid

if (Joystick(1).GetRawButton(4)) //If button 4 is pressed on joystick 1 solenoid 1 will extrend
{
Solenoid(1).Set(true);
Solenoid(2).Set(false);
}
if (Joystick(2).GetRawButton(4)) //If button 4 is pressed on joystick 2 solenoid 1 will retract
{
Solenoid(1).Set(false);
Solenoid(2).Set(true);
}
if (Joystick(1).GetRawButton(5)) //If button 5 is pressed on joystick 1 solenoid 2 will extend
{
Solenoid(3).Set(true);
Solenoid(4).Set(false);
}
if (Joystick(2).GetRawButton(5)) //If button 5 is pressed on joystick 2 solenoid 2 will retract
{
Solenoid(3).Set(false);
Solenoid(4).Set(true);
}
if (Joystick(1).GetRawButton(2)) //If button 2 is pressed on joystick 1 solenoid 3(kicker) will extend
{
Solenoid(5).Set(true);
Solenoid(6).Set(false);
}
if (Joystick(2).GetRawButton(2)) //If button 2 is pressed on joystick 2 solenoid 3(kicker) will retrct
{
Solenoid(5).Set(false);
Solenoid(6).Set(true);
}

// Winch motor

Jaguar winchmotor(5); // Introduce Jaguar

if (Joystick(1).GetTrigger()) //If button is pressed
{
winchmotor.Set(0.5); //motor moves foward
}

if (Joystick(2).GetTrigger()) //If button is pressed
{
winchmotor.Set(-0.5

);

// motor moves backwards
}
This is most of the code and the reason there is a compressor code before the one that we are having trouble with is because we weren't sure weather or not to take it out of leave it. Also our spike stay an orange color when the robot is fully one and we would like to know what that means and what we can do about it.
Reply With Quote
 


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
solenoid and compressor code johncap100 NI LabVIEW 11 28-02-2010 21:34
Compressor Code Robopanda6 Java 1 17-02-2010 13:31
Compressor Code causes No Robot Code Error sircedric4 C/C++ 25 03-02-2010 10:13
compressor problems Spiders Electrical 8 10-02-2008 19:27
Compressor Code gacp Programming 2 19-02-2005 16:18


All times are GMT -5. The time now is 15:05.

The Chief Delphi Forums are sponsored by Innovation First International, Inc.


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