|
|
|
![]() |
|
|||||||
|
||||||||
![]() |
| Thread Tools | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
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:
|
|
#2
|
||||
|
||||
|
Re: Compressor Code problems
Quote:
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 -> |
|
#3
|
|||
|
|||
|
Re: Compressor Code problems
Quote:
|
|
#4
|
||||
|
||||
|
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 ->
}
|
|
#5
|
||||
|
||||
|
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;
....
}
}
|
![]() |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| solenoid and compressor code | johncap100 | NI LabVIEW | 11 | 02-28-2010 09:34 PM |
| Compressor Code | Robopanda6 | Java | 1 | 02-17-2010 01:31 PM |
| Compressor Code causes No Robot Code Error | sircedric4 | C/C++ | 25 | 02-03-2010 10:13 AM |
| compressor problems | Spiders | Electrical | 8 | 02-10-2008 07:27 PM |
| Compressor Code | gacp | Programming | 2 | 02-19-2005 04:18 PM |