Go to Post Win, Lose or Tie, but do it in a way that FIRSTers will be talking about for years to come! - Bill Moore [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 Rating: Thread Rating: 2 votes, 5.00 average. Display Modes
  #1   Spotlight this post!  
Unread 02-03-2015, 11:49 AM
Alan Anderson's Avatar
Alan Anderson Alan Anderson is offline
Software Architect
FRC #0045 (TechnoKats)
Team Role: Mentor
 
Join Date: Feb 2004
Rookie Year: 2004
Location: Kokomo, Indiana
Posts: 9,112
Alan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond repute
Re: roboRIO Command Based Problems

Quote:
Originally Posted by King Nerd III View Post
Long story short the lesson here is when in doubt reformat until it works!
I doubt that is good advice. Unless there is something physically wrong with the system, reimaging a roboRIO a bunch of times can't do anything that reimaging it once will do. The class of problems that can be solved with a single reimage step is very small, and they are very rare.

Instead of going for the reimaging/reformatting voodoo, you should troubleshoot your original problem using the tools suggested here by the people trying to help you.
Reply With Quote
  #2   Spotlight this post!  
Unread 02-03-2015, 11:52 AM
King Nerd III's Avatar
King Nerd III King Nerd III is offline
Chief Programmer/Head of Autonomous
AKA: Isaac
FRC #1410 (The Kraken)
Team Role: Programmer
 
Join Date: Jan 2014
Rookie Year: 2014
Location: Denver, CO
Posts: 113
King Nerd III is an unknown quantity at this point
Re: roboRIO Command Based Problems

Quote:
Originally Posted by Alan Anderson View Post
I doubt that is good advice. Unless there is something physically wrong with the system, reimaging a roboRIO a bunch of times can't do anything that reimaging it once will do. The class of problems that can be solved with a single reimage step is very small, and they are very rare.

Instead of going for the reimaging/reformatting voodoo, you should troubleshoot your original problem using the tools suggested here by the people trying to help you.
It's usually all that works for us. The troubleshooting will help with minor things, but when the robot is turned off mid format? Nothing else would help. Heck, the troubleshooting tools wouldn't even detect the roboRIO.
Reply With Quote
  #3   Spotlight this post!  
Unread 02-03-2015, 12:27 PM
solopilot solopilot is offline
Mentor
FRC #0293
 
Join Date: Jan 2009
Rookie Year: 2008
Location: PA, USA
Posts: 36
solopilot is a name known to allsolopilot is a name known to allsolopilot is a name known to allsolopilot is a name known to allsolopilot is a name known to allsolopilot is a name known to all
Re: roboRIO Command Based Problems

Could it be that you are taking too long in a command's execute() function?
Reply With Quote
  #4   Spotlight this post!  
Unread 02-03-2015, 12:53 PM
King Nerd III's Avatar
King Nerd III King Nerd III is offline
Chief Programmer/Head of Autonomous
AKA: Isaac
FRC #1410 (The Kraken)
Team Role: Programmer
 
Join Date: Jan 2014
Rookie Year: 2014
Location: Denver, CO
Posts: 113
King Nerd III is an unknown quantity at this point
Re: roboRIO Command Based Problems

Quote:
Originally Posted by solopilot View Post
Could it be that you are taking too long in a command's execute() function?
We do occasionally and randomly get an error that says something about MotorSafetyHelper.h not updating fast enough on line 117, but there are two problems. One is that MotorSafetyHelper.h has no line 117, and we start running it. Any ideas?
Reply With Quote
  #5   Spotlight this post!  
Unread 02-03-2015, 01:47 PM
Ben Wolsieffer Ben Wolsieffer is offline
Dartmouth 2020
AKA: lopsided98
FRC #2084 (Robots by the C)
Team Role: Alumni
 
Join Date: Jan 2011
Rookie Year: 2011
Location: Manchester, MA (Hanover, NH)
Posts: 520
Ben Wolsieffer has much to be proud ofBen Wolsieffer has much to be proud ofBen Wolsieffer has much to be proud ofBen Wolsieffer has much to be proud ofBen Wolsieffer has much to be proud ofBen Wolsieffer has much to be proud ofBen Wolsieffer has much to be proud ofBen Wolsieffer has much to be proud of
Re: roboRIO Command Based Problems

Quote:
Originally Posted by King Nerd III View Post
We do occasionally and randomly get an error that says something about MotorSafetyHelper.h not updating fast enough on line 117, but there are two problems. One is that MotorSafetyHelper.h has no line 117, and we start running it. Any ideas?
You are getting the MotorSafetyHelper error because you are not updating the motor outputs fast enough so the watchdog timer is expiring. If any execute method blocks for a long time, it will prevent all commands from running, therefore causing a watchdog timeout.
__________________



2016 North Shore District - Semifinalists and Excellence in Engineering Award
2015 Northeastern University District - Semifinalists and Creativity Award
2014 Granite State District - Semifinalists and Innovation in Control Award
2012 Boston Regional - Finalists
Reply With Quote
  #6   Spotlight this post!  
Unread 02-03-2015, 01:48 PM
King Nerd III's Avatar
King Nerd III King Nerd III is offline
Chief Programmer/Head of Autonomous
AKA: Isaac
FRC #1410 (The Kraken)
Team Role: Programmer
 
Join Date: Jan 2014
Rookie Year: 2014
Location: Denver, CO
Posts: 113
King Nerd III is an unknown quantity at this point
Re: roboRIO Command Based Problems

Quote:
Originally Posted by lopsided98 View Post
You are getting the MotorSafetyHelper error because you are not updating the motor outputs fast enough so the watchdog timer is expiring. If any execute method blocks for a long time, it will prevent all commands from running, therefore causing a watchdog timeout.
That's what we thought, but it doesn't happen every single time, which confused me. How would we fix that?
Reply With Quote
  #7   Spotlight this post!  
Unread 02-03-2015, 02:15 PM
Alan Anderson's Avatar
Alan Anderson Alan Anderson is offline
Software Architect
FRC #0045 (TechnoKats)
Team Role: Mentor
 
Join Date: Feb 2004
Rookie Year: 2004
Location: Kokomo, Indiana
Posts: 9,112
Alan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond repute
Re: roboRIO Command Based Problems

Quote:
Originally Posted by King Nerd III View Post
How would we fix that?
That depends on what is making it take too long. We can guess at possible causes, but unless you show us your code we can't give confident help.

Post your code, as Kyle suggested in his first response.
Reply With Quote
  #8   Spotlight this post!  
Unread 02-03-2015, 02:29 PM
King Nerd III's Avatar
King Nerd III King Nerd III is offline
Chief Programmer/Head of Autonomous
AKA: Isaac
FRC #1410 (The Kraken)
Team Role: Programmer
 
Join Date: Jan 2014
Rookie Year: 2014
Location: Denver, CO
Posts: 113
King Nerd III is an unknown quantity at this point
Re: roboRIO Command Based Problems

Quote:
Originally Posted by Alan Anderson View Post
That depends on what is making it take too long. We can guess at possible causes, but unless you show us your code we can't give confident help.

Post your code, as Kyle suggested in his first response.
I added the DriveBase subsystem, and the drive command to the post. Tell me what you think.
Attached Files
File Type: h DriveBase.h (652 Bytes, 7 views)
File Type: cpp DriveBase.cpp (1.7 KB, 13 views)
File Type: cpp TeleOpTankDrive.cpp (680 Bytes, 11 views)
File Type: h TeleOpTankDrive.h (274 Bytes, 6 views)
File Type: cpp OI.cpp (3.1 KB, 8 views)

Last edited by King Nerd III : 02-03-2015 at 02:36 PM. Reason: added OI for oi->GetStickAxis
Reply With Quote
  #9   Spotlight this post!  
Unread 02-04-2015, 12:51 AM
kylelanman's Avatar
kylelanman kylelanman is offline
Programming Mentor
AKA: Kyle
FRC #2481 (Roboteers)
Team Role: Mentor
 
Join Date: Feb 2008
Rookie Year: 2007
Location: Tremont Il
Posts: 185
kylelanman is a name known to allkylelanman is a name known to allkylelanman is a name known to allkylelanman is a name known to allkylelanman is a name known to allkylelanman is a name known to all
Re: roboRIO Command Based Problems

Code:
 48void DriveBase::AutoDriveTurn(float speed, float angle){
 49         while(drive_gyro->GetAngle() >= angle){
 50                 fl_motor->Set(speed);
 51                 fr_motor->Set(speed);
 52                 bl_motor->Set(speed);
 53                 br_motor->Set(speed);
 54         }
 55 }
This function is going to cause you problems. This is called a "tight loop" and will consume all of your CPU power while blocking your main thread. Because there is no delay the CPU is going to execute the loop as fast as it possibly can. It will likely take the CPU to 100% and then start dropping control packets from the driver station. On top of that while you are in the loop none of your other commands or code in the main thread will be running.

The better way to do this that won't cause you problems is to use a command.

Code:
 32 class AutoDriveTurnCommand() {
 33 private:
 34     double mSpeed;
 35     double mAngle;
 36 public:
 37     AutoDriveTurnCommand(double speed, double angle) {
 38         mSpeed = speed;
 39         mAngle = angle;
 40     }
 41     void Initialize() {
 42         Robot::drivebase->DriveTank(speed, speed);
 43     }
 44     void Execute() {}
 45     bool IsFinished() {
 46         return Robot::drivebase->GetGyroAngle() < mAngle;
 47     }
 48     void End() {
 49         Robot::drivebase->DriveTank(0, 0);
 50     }
 51     void Interrupted() {
 52         End();
 53     }
 54 };
For this to work you will need to define a function in DriveBase called GetGyroAngle that returns the angle of the gyro.
__________________
"May the coms be with you"

Is this a "programming error" or a "programmer error"?

Reply With Quote
  #10   Spotlight this post!  
Unread 02-04-2015, 12:57 AM
King Nerd III's Avatar
King Nerd III King Nerd III is offline
Chief Programmer/Head of Autonomous
AKA: Isaac
FRC #1410 (The Kraken)
Team Role: Programmer
 
Join Date: Jan 2014
Rookie Year: 2014
Location: Denver, CO
Posts: 113
King Nerd III is an unknown quantity at this point
Re: roboRIO Command Based Problems

Quote:
Originally Posted by kylelanman View Post
Code:
 48void DriveBase::AutoDriveTurn(float speed, float angle){
 49         while(drive_gyro->GetAngle() >= angle){
 50                 fl_motor->Set(speed);
 51                 fr_motor->Set(speed);
 52                 bl_motor->Set(speed);
 53                 br_motor->Set(speed);
 54         }
 55 }
This function is going to cause you problems. This is called a "tight loop" and will consume all of your CPU power while blocking your main thread. Because there is no delay the CPU is going to execute the loop as fast as it possibly can. It will likely take the CPU to 100% and then start dropping control packets from the driver station. On top of that while you are in the loop none of your other commands or code in the main thread will be running.

The better way to do this that won't cause you problems is to use a command.

Code:
 32 class AutoDriveTurnCommand() {
 33 private:
 34     double mSpeed;
 35     double mAngle;
 36 public:
 37     AutoDriveTurnCommand(double speed, double angle) {
 38         mSpeed = speed;
 39         mAngle = angle;
 40     }
 41     void Initialize() {
 42         Robot::drivebase->DriveTank(speed, speed);
 43     }
 44     void Execute() {}
 45     bool IsFinished() {
 46         return Robot::drivebase->GetGyroAngle() < mAngle;
 47     }
 48     void End() {
 49         Robot::drivebase->DriveTank(0, 0);
 50     }
 51     void Interrupted() {
 52         End();
 53     }
 54 };
For this to work you will need to define a function in DriveBase called GetGyroAngle that returns the angle of the gyro.
Thanks for the tip, but that couldn't be what's causing the error with not updating fast enough. That method isn't even called in the code yet, plus ita autonomous and we only get the error in teleop. Thanks for the tip, though! I'll probably use that!
Reply With Quote
  #11   Spotlight this post!  
Unread 12-10-2015, 03:22 PM
King Nerd III's Avatar
King Nerd III King Nerd III is offline
Chief Programmer/Head of Autonomous
AKA: Isaac
FRC #1410 (The Kraken)
Team Role: Programmer
 
Join Date: Jan 2014
Rookie Year: 2014
Location: Denver, CO
Posts: 113
King Nerd III is an unknown quantity at this point
Re: roboRIO Command Based Problems

I know this is an old thread, and I'm replying to myself, but yesterday we figured out the problem. In the Robot.cpp we were calling auto_command->End(); in the TeleOpInit Phase, but we had not given a specific command to auto_command, so when TeleOp was enabled it couldn't end the command and just died... At least that's how I believe we fixed it. Commenting out the auto_command->End() got rid of this problem, so we believe that's what it was.
Hope this helps!
Isaac
__________________
Isaac
Chief of Programming and Head of Autonomous Control
FRC Team 1410
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 10:51 AM.

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