View Single Post
  #3   Spotlight this post!  
Unread 04-01-2011, 18:34
Cody Trey's Avatar
Cody Trey Cody Trey is offline
Programing = hard + fun
FRC #2582 (Panther Bots)
Team Role: Programmer
 
Join Date: Jan 2011
Rookie Year: 2009
Location: US
Posts: 31
Cody Trey is an unknown quantity at this point
Send a message via Yahoo to Cody Trey
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*'
__________________
Love, Peace, and Robot Grease
Reply With Quote