Go to Post If you have not had a positive experience in FIRST, please don't bring those that have down. - Jeff K. [more]
Home
Go Back   Chief Delphi > Technical > Programming > C/C++
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
Reply
Thread Tools Rate Thread Display Modes
  #1   Spotlight this post!  
Unread 03-04-2012, 11:35
DavisC DavisC is offline
Registered User
FRC #0539 (Titans)
Team Role: College Student
 
Join Date: Jul 2011
Rookie Year: 2010
Location: Virginia
Posts: 200
DavisC is just really niceDavisC is just really niceDavisC is just really niceDavisC is just really nice
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);
Code:
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:
Code:
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
__________________
FRC Team 539
Student Member: 2010 Breakaway - 2014 Aerial Assist
Mentor: 2015 Recycle Rush - present
Reply With Quote
  #2   Spotlight this post!  
Unread 03-04-2012, 11:44
thephpdev's Avatar
thephpdev thephpdev is offline
Registered User
AKA: Josh Larson
FRC #2502 (Talon Robotics)
Team Role: Programmer
 
Join Date: Mar 2012
Rookie Year: 2012
Location: Eden Prairie, MN
Posts: 16
thephpdev is an unknown quantity at this point
Re: Method of Programming Drive

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?
Reply With Quote
  #3   Spotlight this post!  
Unread 03-04-2012, 13:00
DjScribbles DjScribbles is offline
Programming Mentor
AKA: Joe S
FRC #2474 (Team Excel)
Team Role: Mentor
 
Join Date: Oct 2011
Rookie Year: 2012
Location: Niles MI
Posts: 284
DjScribbles is a splendid one to beholdDjScribbles is a splendid one to beholdDjScribbles is a splendid one to beholdDjScribbles is a splendid one to beholdDjScribbles is a splendid one to beholdDjScribbles is a splendid one to beholdDjScribbles is a splendid one to beholdDjScribbles is a splendid one to behold
Re: Method of Programming Drive

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:
Code:
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\n");
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\n");
}

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 )

Code:
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.

Last edited by DjScribbles : 03-04-2012 at 13:19.
Reply With Quote
Reply


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -5. The time now is 03:01.

The Chief Delphi Forums are sponsored by Innovation First International, Inc.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi