Go to Post Rule 1. Never take Dave's hint's seriously. Rule 2. Watergame. - AndyB [more]
Home
Go Back   Chief Delphi > Technical > Programming
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
Closed Thread
Thread Tools Rate Thread Display Modes
  #1   Spotlight this post!  
Unread 12-02-2015, 17:06
team-4480's Avatar
team-4480 team-4480 is offline
Debug? What's that?
FRC #4480
 
Join Date: Jan 2015
Rookie Year: 2013
Location: Minnesooota
Posts: 229
team-4480 will become famous soon enoughteam-4480 will become famous soon enough
Python: Robot Drive is not updating often enough in Auto mode?

Hi! We are trying to create some auto mode code but we keep getting a "WARNING: wpilib.motorsafety : Robot Drive.... Output not updating often enough". We are using a string of elif statements with the auto counter to avoid using for loops and while loops.
Code:
        if self.auto_loop_counter<=25:
            self.non_existant_motor.set(-.5)
            self.sol.set(True)
            self.auto_loop_counter+=1
        elif self.auto_loop_counter <= 100 and self.auto_loop_counter>25:
            self.robot_drive.drive(-0.5, 0) # Drive forwards at half speed
            self.auto_loop_counter += 1
            self.sol.set(False)
            self.non_existant_motor.set(0)
        else:
            self.robot_drive.drive(0, 0)
We have many more elifs then that but that is the basic framework of our code. Any help will be greatly appreciated!
  #2   Spotlight this post!  
Unread 12-02-2015, 17:14
Ty Tremblay's Avatar
Ty Tremblay Ty Tremblay is offline
Robotics Engineer
FRC #0319 (Big Bad Bob)
Team Role: Mentor
 
Join Date: Feb 2006
Rookie Year: 2004
Location: Alton NH
Posts: 842
Ty Tremblay has a reputation beyond reputeTy Tremblay has a reputation beyond reputeTy Tremblay has a reputation beyond reputeTy Tremblay has a reputation beyond reputeTy Tremblay has a reputation beyond reputeTy Tremblay has a reputation beyond reputeTy Tremblay has a reputation beyond reputeTy Tremblay has a reputation beyond reputeTy Tremblay has a reputation beyond reputeTy Tremblay has a reputation beyond reputeTy Tremblay has a reputation beyond repute
Re: Python: Robot Drive is not updating often enough in Auto mode?

Robot drive not updated often enough is an error you'll receive when your code isn't executing in a short enough amount of time. Don't quote me on it, but I think you'll receive the error if your code doesn't send a control message to the robot every 100ms.

Why are you trying to avoid for and while loops?
__________________

Last edited by Ty Tremblay : 12-02-2015 at 17:16.
  #3   Spotlight this post!  
Unread 12-02-2015, 17:32
Tom Bottiglieri Tom Bottiglieri is offline
Registered User
FRC #0254 (The Cheesy Poofs)
Team Role: Engineer
 
Join Date: Jan 2004
Rookie Year: 2003
Location: San Francisco, CA
Posts: 3,187
Tom Bottiglieri has a reputation beyond reputeTom Bottiglieri has a reputation beyond reputeTom Bottiglieri has a reputation beyond reputeTom Bottiglieri has a reputation beyond reputeTom Bottiglieri has a reputation beyond reputeTom Bottiglieri has a reputation beyond reputeTom Bottiglieri has a reputation beyond reputeTom Bottiglieri has a reputation beyond reputeTom Bottiglieri has a reputation beyond reputeTom Bottiglieri has a reputation beyond reputeTom Bottiglieri has a reputation beyond repute
Re: Python: Robot Drive is not updating often enough in Auto mode?

The code that prints this error is in motorsafety.py and looks like this
Code:
 def check(self):
        """Check if this motor has exceeded its timeout.
        This method is called periodically to determine if this motor has
        exceeded its timeout value. If it has, the stop method is called,
        and the motor is shut down until its value is updated again.
        """
        if not self.safetyEnabled or RobotState.isDisabled() or RobotState.isTest():
            return
        if self.safetyStopTime < Timer.getFPGATimestamp():
            logger.warn("%s... Output not updated often enough." %
                        self.getDescription())

            self.stopMotor()
It looks like SafePWM (the base class for Victor and Talon) inherits this class. So, basically, if you don't call .set() on your motor controller object periodically it will assume your code has run away from you and stop that particular motor. The default timeout is 0.1 seconds.

Your auto code is only calling robot_drive.drive in some parts of the if structure. Therefore, the set method on those speed controllers isn't being called, hence this message printing.

You can fix this by:
1) Disabling motor safety by calling setSafetyEnabled on the motor object
2) Calling set on each motor in each iteration. I suggest something like the following:

Code:
       non_e_motor_out = 0      
       drive_out = (0,0) 
       if self.auto_loop_counter<=25:
            non_e_motor_out  = -.5 #
            self.sol.set(True)
            self.auto_loop_counter+=1
        elif self.auto_loop_counter <= 100 and self.auto_loop_counter>25:
            drive_out = (-0.5, 0)  # Drive forwards at half speed
            self.auto_loop_counter += 1
            self.sol.set(False)
            self.non_existant_motor.set(0)
        self.robot_drive.drive(drive_out[0], drive_out[1])
        self.non_existant_motor.set(non_e_motor_out)
  #4   Spotlight this post!  
Unread 12-02-2015, 21:07
team-4480's Avatar
team-4480 team-4480 is offline
Debug? What's that?
FRC #4480
 
Join Date: Jan 2015
Rookie Year: 2013
Location: Minnesooota
Posts: 229
team-4480 will become famous soon enoughteam-4480 will become famous soon enough
Re: Python: Robot Drive is not updating often enough in Auto mode?

Thanks to both of you and I will try out that code as soon as I can!
  #5   Spotlight this post!  
Unread 12-02-2015, 22:12
TimTheGreat's Avatar
TimTheGreat TimTheGreat is offline
ArchdukeTim
FRC #1418 (Vae Victis)
Team Role: Programmer
 
Join Date: Jan 2013
Rookie Year: 2011
Location: Falls Church
Posts: 238
TimTheGreat has a spectacular aura aboutTimTheGreat has a spectacular aura aboutTimTheGreat has a spectacular aura about
Re: Python: Robot Drive is not updating often enough in Auto mode?

Quote:
Originally Posted by team-4480 View Post
Thanks to both of you and I will try out that code as soon as I can!
Hopefully you run your code through the simulator... right?
__________________
There are two ways of constructing a software design: One way is to make it so simple that there are obviously no deficiencies, and the other way is to make it so complicated that there are no obvious deficiencies. The first method is far more difficult.



2012 - Gracious Professionalism - Greater DC
2014 - Regional Finalist - Virginia | Industrial Design - Virginia | Regional Finalist - Greater DC
2015 - Innovation in Control - Greater DC
2016 - District Event Winner - VAHAY | Innovation in Control - VAHAY | District Event Winner - MDBET | Industrial Design - MDBET | District Champion - CHCMP | Innovation in Control - CHCMP
  #6   Spotlight this post!  
Unread 12-02-2015, 23:09
virtuald's Avatar
virtuald virtuald is offline
RobotPy Guy
AKA: Dustin Spicuzza
FRC #1418 (), FRC #1973, FRC #4796, FRC #6367 ()
Team Role: Mentor
 
Join Date: Dec 2008
Rookie Year: 2003
Location: Boston, MA
Posts: 1,086
virtuald has a brilliant futurevirtuald has a brilliant futurevirtuald has a brilliant futurevirtuald has a brilliant futurevirtuald has a brilliant futurevirtuald has a brilliant futurevirtuald has a brilliant futurevirtuald has a brilliant futurevirtuald has a brilliant futurevirtuald has a brilliant futurevirtuald has a brilliant future
Re: Python: Robot Drive is not updating often enough in Auto mode?

Definitely make sure you run your autonomous through the simulator, it'll show things like that and you can fix them there before putting it on the robot.

Additionally, don't forget that there's a really simple autonomous framework you can use in python. Check it out: http://robotpy-wpilib-utilities.read...ful_autonomous
__________________
Maintainer of RobotPy - Python for FRC
Creator of pyfrc (Robot Simulator + utilities for Python) and pynetworktables/pynetworktables2js (NetworkTables for Python & Javascript)

2017 Season: Teams #1973, #4796, #6369
Team #1418 (remote mentor): Newton Quarterfinalists, 2016 Chesapeake District Champion, 2x Innovation in Control award, 2x district event winner
Team #1418: 2015 DC Regional Innovation In Control Award, #2 seed; 2014 VA Industrial Design Award; 2014 Finalists in DC & VA
Team #2423: 2012 & 2013 Boston Regional Innovation in Control Award


Resources: FIRSTWiki (relaunched!) | My Software Stuff
  #7   Spotlight this post!  
Unread 13-02-2015, 00:12
virtuald's Avatar
virtuald virtuald is offline
RobotPy Guy
AKA: Dustin Spicuzza
FRC #1418 (), FRC #1973, FRC #4796, FRC #6367 ()
Team Role: Mentor
 
Join Date: Dec 2008
Rookie Year: 2003
Location: Boston, MA
Posts: 1,086
virtuald has a brilliant futurevirtuald has a brilliant futurevirtuald has a brilliant futurevirtuald has a brilliant futurevirtuald has a brilliant futurevirtuald has a brilliant futurevirtuald has a brilliant futurevirtuald has a brilliant futurevirtuald has a brilliant futurevirtuald has a brilliant futurevirtuald has a brilliant future
Re: Python: Robot Drive is not updating often enough in Auto mode?

Also, I just uploaded a sample of the autonomous framework, if you want to play with it. Very simple to use, and a great way to manage simple state machines for autonomous mode.

https://github.com/robotpy/robotpy-w...master/samples
__________________
Maintainer of RobotPy - Python for FRC
Creator of pyfrc (Robot Simulator + utilities for Python) and pynetworktables/pynetworktables2js (NetworkTables for Python & Javascript)

2017 Season: Teams #1973, #4796, #6369
Team #1418 (remote mentor): Newton Quarterfinalists, 2016 Chesapeake District Champion, 2x Innovation in Control award, 2x district event winner
Team #1418: 2015 DC Regional Innovation In Control Award, #2 seed; 2014 VA Industrial Design Award; 2014 Finalists in DC & VA
Team #2423: 2012 & 2013 Boston Regional Innovation in Control Award


Resources: FIRSTWiki (relaunched!) | My Software Stuff
Closed Thread


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 21:07.

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