|
|
|
![]() |
|
|||||||
|
||||||||
![]() |
| Thread Tools | Rate Thread | Display Modes |
|
#1
|
||||
|
||||
|
I need help controlling a jaguar using the Y-axis of a joystick.
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.Thank you all in advanced! |
|
#2
|
||||
|
||||
|
Re: c++ motor control
Quote:
|
|
#3
|
||||
|
||||
|
Re: c++ motor control
My Code is:
#include "WPILib.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 *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*' |
|
#4
|
||||
|
||||
|
Re: c++ motor control
Quote:
Can you try this instead? float foo = m_rollerstick.GetY(); RollerMotor.Set(foo); //sets joystick 3 y-axis to controll the roller motor |
|
#5
|
||||
|
||||
|
Re: c++ motor control
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 member `Set' in `((RobotDemo*)this)->RobotDemo::RollerMotor', which is of non-class type `Jaguar*' |
|
#6
|
|||
|
|||
|
Re: c++ motor control
It's a simple mistake. You need to replace RollerMotor.Set with RollerMotor->Set because you're using a pointer. Probably just a typo.
edit: same thing for the joystick error |
|
#7
|
||||
|
||||
|
Re: c++ motor control
Oh, that's just because they're pointers.
Instead of m_rollerstick.GetY(), do m_rollerstick->GetY() Same with the jaguar. EDIT: Ninja! |
|
#8
|
||||
|
||||
|
Re: c++ motor control
YAY!! you guys are my heros! it worked, and i did the same motor.Set
![]() Last edited by Cody Trey : 04-01-2011 at 20:30. |
|
#9
|
||||
|
||||
|
Now tomorrow after final's I'll try to get it on the bot, i may be back with some more problems, but hopefully it will all go smoothly
![]() |
![]() |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Spike motor control | kansattica | NI LabVIEW | 5 | 30-01-2012 11:37 |
| encoder motor control | pauldemonkey | NI LabVIEW | 1 | 19-02-2010 13:10 |
| Motor Control Systems | Astronouth7303 | Programming | 3 | 05-04-2005 19:35 |
| Four motor control | judson | Programming | 1 | 14-02-2005 20:17 |
| Motor Control | archiver | 2000 | 1 | 23-06-2002 23:01 |