Method of Programming Drive

So in my programming past, I have always used the method for programming the Drive motors like in the SimpleTemplate.out (below);


RobotDrive myRobot;
--
myRobot(1, 2)

But somewhere I saw some code that seemed to initialize the myRobot but then continued to initialize each motor individually. I believe it looked like this:


myRobot
{
     RearLeftMotor...
     RearRightMotor...
}

Now, when I run the SimpleTemplate.out method, I always get an error under the DS that says the Robot Drive is not running fast enough.

Thanks,
Davis

Do you mean when you don’t feed the watchdogs? If it is, then there’s either something holding up your main loop that will stop feeding the motors. Or it’s not running a motor that would cause the watchdog to disable your robot.

Can you show the code for your drive train?

I don’t remember the specific message the DS gives, but what is typically happening is you aren’t calling any of the myRobot.Drive routines OFTEN enough.

It doesn’t really matter how you initialize your drive system, but there are lots of methods for doing so. If you look at the robot drive header file (try control clicking “RobotDrive” in windriver), all of the functions labeled RobotDrive() are the different constructors you can use.
Here is how I’ve constructed my drive system, which isn’t the same as the normal template way:


Robot2012(void):
jaguarFrontLeft(DIGITAL_OUTPUT_CHANNEL, PWM_CHANNEL_4_JAGUAR_FRONT_LEFT),
jaguarFrontRight(DIGITAL_OUTPUT_CHANNEL, PWM_CHANNEL_3_JAGUAR_FRONT_RIGHT),
jaguarRearLeft(DIGITAL_OUTPUT_CHANNEL, PWM_CHANNEL_2_JAGUAR_REAR_LEFT),
jaguarRearRight(DIGITAL_OUTPUT_CHANNEL, PWM_CHANNEL_1_JAGUAR_REAR_RIGHT),
myRobot(&jaguarFrontLeft, &jaguarRearLeft, &jaguarFrontRight, &jaguarRearRight),
....
{
printf("Robot2012 Constructor Started
");
cameraInitialized = false;
// Acquire the Driver Station object
driverStation = DriverStation::GetInstance();
driverStationLCD = DriverStationLCD::GetInstance();
myRobot.SetInvertedMotor(myRobot.kRearLeftMotor, true);
myRobot.SetInvertedMotor(myRobot.kRearRightMotor, true);
myRobot.SetInvertedMotor(myRobot.kFrontLeftMotor, true);
myRobot.SetInvertedMotor(myRobot.kFrontRightMotor, true);

// Initialize counters to record the number of loops completed in autonomous and teleop modes
m_autoPeriodicLoops = 0;
m_disabledPeriodicLoops = 0;
m_telePeriodicLoops = 0;

printf("Robot2012 Constructor Completed
");
}

It is possible that some of the alternate constructors for RobotDrive such as mine don’t turn on the motor safety of the jaguars that were passed to them at construction; because in my method, I first create the jaguars, which by default don’t enable motor safety, then I pass them into the RobotDrive constructor by reference, at this point it depends on the robot drive code whether or not it enables the motor safety on the jags it is passed or if it abstains from modifying their safety settings, and this could be different for each constructor.

However, in order to fix this error message the correct way, you will want to modify your code so that there is always somebody controlling the motors. For example, if you use any wait statements in your code you would replace them with timed while loop statements or structured if else statements: (I prefer the latter, as timed while loops make me queezy :))


if (autonomousStateTimer.Get() > AUTONOMOUS_BACKUP_TIME)
{
autonomousStateTimer.Reset();
myRobot.TankDrive(0.0,0.0);
autonomousState = AUTONOMOUS_WAIT_FOR_TELEOP;
}
else if (autonomousStateTimer.Get() > 1.0)
{
myRobot.TankDrive(-.5,-.5);
}
else
{
myRobot.TankDrive(0.0,0.0);
}

In the above code, even if I know I set the throttle to 0,0 I set it again every time I run this code; each time, the watchdog timer for the RobotDrive is reset, which basically just tells the code that somebody is in control of this motor.

If you don’t ‘feed’ the watchdog periodically, the RobotDrive will assume that there is nobody in control of the robot and stop the wheels. The reason this is done is for safety; imagine your laptop gets hit by a meteor while the driver has the joysticks going forward full speed, the robot doesn’t know anything has happened and continues driving forward at full throttle; however the motor safety watchdog knows it needs to get new speeds set every .5sec, when the robot stops getting new joystick values, it will automatically stop after 0.5 seconds.