Go to Post Note to self: Before turning 30, remember to remove the birthdate year from Delphi. - Jessica Boucher [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

 
Reply
Thread Tools Rate Thread Display Modes
  #1   Spotlight this post!  
Unread 06-03-2010, 16:15
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
Compressor Code problems

Team 2895
So our team is some what new to the programming thing and we have been having problems with our code. We finally got the compressor declared but when we did that the code came up with another error saying: In member function `virtual void BuiltinDefaultCode::TeleopPeriodic()': 'class Compressor' has no member named 'Set' request for member `Set' in `((BuiltinDefaultCode*)this)->BuiltinDefaultCode::compressor', which is of non-class type `Compressor*'. Now we cant seem to get this error to go away can anyone help us?

Quote:
//*Compressor

if (Joystick(1).GetRawButton(10)) //if button 10 is pressed on joystick 1 compressor will turn on
{
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);

}
Reply With Quote
  #2   Spotlight this post!  
Unread 06-03-2010, 16:40
byteit101's Avatar
byteit101 byteit101 is offline
WPILib maintainer (WPI)
AKA: Patrick Plenefisch
no team (The Cat Attack (Formerly))
Team Role: Programmer
 
Join Date: Jan 2009
Rookie Year: 2009
Location: Worcester
Posts: 699
byteit101 is a glorious beacon of lightbyteit101 is a glorious beacon of lightbyteit101 is a glorious beacon of lightbyteit101 is a glorious beacon of lightbyteit101 is a glorious beacon of lightbyteit101 is a glorious beacon of light
Re: Compressor Code problems

Quote:
Originally Posted by Briyanna View Post
Team 2895
So our team is some what new to the programming thing and we have been having problems with our code. We finally got the compressor declared but when we did that the code came up with another error saying: In member function `virtual void BuiltinDefaultCode::TeleopPeriodic()': 'class Compressor' has no member named 'Set' request for member `Set' in `((BuiltinDefaultCode*)this)->BuiltinDefaultCode::compressor', which is of non-class type `Compressor*'. Now we cant seem to get this error to go away can anyone help us?
1. Declare the compressor at the top. otherwise, the compressor will be constructed and destructed every loop, so the compressor will only be running for the brief time in the function.

2. use a pointer (Compressor *) or not (Compressor). If you want to use the pointer, you need to init it with the = new Compressor(1, 1); line, if not, in the init location. If you are using a pointer, you access Set with a -> (and if you are not, a .) you should never have the mixed . and ->
__________________
Bubble Wrap: programmers rewards
Watchdog.Kill();
printf("Watchdog is Dead, Celebrate!");
How to make a self aware robot: while (∞) cout<<(sqrt(-∞)/-0);
Previously FRC 451 (The Cat Attack)
Now part of the class of 2016 at WPI & helping on WPILib
Reply With Quote
  #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
  #4   Spotlight this post!  
Unread 06-03-2010, 17:30
byteit101's Avatar
byteit101 byteit101 is offline
WPILib maintainer (WPI)
AKA: Patrick Plenefisch
no team (The Cat Attack (Formerly))
Team Role: Programmer
 
Join Date: Jan 2009
Rookie Year: 2009
Location: Worcester
Posts: 699
byteit101 is a glorious beacon of lightbyteit101 is a glorious beacon of lightbyteit101 is a glorious beacon of lightbyteit101 is a glorious beacon of lightbyteit101 is a glorious beacon of lightbyteit101 is a glorious beacon of light
Re: Compressor Code problems

you only need to change this bit of code:
Code:
//*Compressor

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

compressor->Set(true);//Change this to a ->

}
if (Joystick(1).GetRawButton(11)) //if button 11 is pressed on joystick 1 compressor will turn off
{
compressor->Set(false);//Change this to a ->
}
__________________
Bubble Wrap: programmers rewards
Watchdog.Kill();
printf("Watchdog is Dead, Celebrate!");
How to make a self aware robot: while (∞) cout<<(sqrt(-∞)/-0);
Previously FRC 451 (The Cat Attack)
Now part of the class of 2016 at WPI & helping on WPILib
Reply With Quote
  #5   Spotlight this post!  
Unread 06-03-2010, 19:29
mikets's Avatar
mikets mikets is offline
Software Engineer
FRC #0492 (Titan Robotics)
Team Role: Mentor
 
Join Date: Jan 2010
Rookie Year: 2008
Location: Bellevue, WA
Posts: 667
mikets is a glorious beacon of lightmikets is a glorious beacon of lightmikets is a glorious beacon of lightmikets is a glorious beacon of lightmikets is a glorious beacon of lightmikets is a glorious beacon of light
Re: Compressor Code problems

As far know, there is no "Set" method in the Compressor object even in the base classes it inherited from. In any case, if the compressor is wired correctly with a pressure switch, you shouldn't have to do much about the compressor object. Just instantiate it, start it and forget about it. When the compressor object is instantiated, a compressor task is started automatically, this task will check if the compressor has been enabled by Start(). If so, it will monitor the pressure switch and automatically turn the relay on and off if necessary to maintain the pressure. In other words, you can just do the following with the compressor object in the constructor of your robot and nothing else. Don't use a joystick button to turn the compressor on and off. It is automatic. You don't even have to destroy the compressor in the destructor because the robot code will never end anyway, but it would be a cleaner habit of coding.
Code:
class BuiltinDefaultCode : public IterativeRobot
{
private:
    Compressor *m_compressor;

...

public:
    BuiltinDefaultCode()
    {
        ...
        m_compressor = new Compressor(1, 1);
        m_compressor->Start();
        ...
    }
    ~BuiltinDefaultCode()
    {
        ....
        m_compressor->Stop();
        delete m_compressor;
        ....
    }
}
__________________
Reply With Quote
Reply


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 18:08.

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