I need help controlling a jaguar using the Y-axis of a joystick.:ahh: I am trying to complete code for last year’s robot in c++ to have a working base to program on this year. I have most of my code done, if you’d like to see it just ask and i’ll post, I can also post the error that wind river is giving me.
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 *m_rollerstick;
DriverStation *ds; // driver station
Joystick *m_leftstick;
Joystick *m_rightstick;
Jaguar *RollerMotor;
Solenoid *Sol1;
Jaguar *rollermotor;
public:
RobotDemo(void)
{
ds = DriverStation::GetInstance();
myRobot = new RobotDrive(1, 2); // create robot drive base
m_leftstick = new Joystick(1); // create the joysticks
m_rightstick = new Joystick (2);
m_rollerstick = new Joystick (3);
RollerMotor = new Jaguar (3); // create the Jaguar for the roller
Compressor *c = new Compressor(4, 2); //creates the compressor object
c->Start(); //starts compressor
Sol1 = new Solenoid(1); // creates solenoid obects
GetWatchdog().SetExpiration(100);
}
/**
* Drive left & right motors for 2 seconds then stop
*/
void Autonomous(void)
{
GetWatchdog().SetEnabled(false);
myRobot->Drive(0.5, 0.0); // drive forwards half speed
Wait(2000); // for 2 seconds
myRobot->Drive(0.0, 0.0); // stop robot
Wait(2000);
myRobot->Drive (-0.5, 0.0); //drive backwards half speed
Wait(2000);
myRobot->Drive (0.0, 0.0);
Wait (2000);
}
/**
* Runs the motors with tank steering.
*/
void OperatorControl(void)
{
GetWatchdog().SetEnabled(true);
while (IsOperatorControl())
{
GetWatchdog().Feed();
myRobot->TankDrive(m_leftstick, m_rightstick); //sets the left and right joysticks to control the left and right motors
RollerMotor.Set( m_rollerstick.GetY() ); //sets joystick 3 y-axis to controll the roller motor
if (m_rollerstick->GetRawButton(4)) //gets button 4 from joystick 3 to control the soleniod on port 1, note: it is port one in the code, but is labeled port 0 on the hardware
{Sol1->Set(true);}
}
}
};
START_ROBOT_CLASS(RobotDemo);
the red section of code gives the error:
error: request for member Set' in((RobotDemo*)this)->RobotDemo::RollerMotor’, which
is of non-class type `Jaguar*’
I just tried that, it seems that the error isn’t in how i had it set up, it doesn’t like something about the GetY and the Set, because its still returning the same errors. but it does separate the two errors into different lines which should make them easier to deal with.
errors:
GetY error:
error: request for member GetY' in((RobotDemo*)this)->RobotDemo::m_rollerstick’,
which is of non-class type Joystick*' Set error: error: request for memberSet’ in ((RobotDemo*)this)->RobotDemo::RollerMotor', which is of non-class typeJaguar*’