Hello, I am trying to pass a speed controller (victor) as an BYREF argument in a function and set its value, however, the motor wont turn on and I get no errors. Here is what it looks like:
void SpecialControl(SpeedController &Motor); /* prototype */
class Robot : public SimpleRobot
{
Victor InitialMotor;
public:
Robot(void): // these must be initialized in the same order
InitialMotor(1)
{
GetWatchdog().SetExpiration(0.1);
}
void OperatorControl(void)
{
GetWatchdog().SetEnabled(true);
SpecialControl(InitialMotor);
}
};
void SpecialControl(SpeedController &Motor)
{
Motor.Set(1);
}
Thanks in advance.
Give this a shot:
void SpecialControl(SpeedController *Motor); /* prototype */
class Robot : public SimpleRobot
{
Victor *InitialMotor;
public:
Robot(void)
{
InitialMotor = new Victor(1);
GetWatchdog().SetExpiration(0.1);
}
void OperatorControl(void)
{
GetWatchdog().SetEnabled(true);
SpecialControl(InitialMotor);
}
};
void SpecialControl(SpeedController *Motor)
{
Motor->Set(1);
}
I have tried that, and it gives me these errors:
error: cannot convert Victor' to
SpeedController*’ for argument 1' to
void SpecialControl(SpeedController*)’
Thanks in advance.
Look carefully at this line, and make sure you didn’t leave out anything.
Victor *InitialMotor;
Ah, finally, that compiles… I will see if it runs on the robot tomorrow. Thanks so much…