|
|
|
![]() |
|
|||||||
|
||||||||
![]() |
| Thread Tools | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
Timing Autonomous with While Loops?
In the 2015 timed autonomous tutorial, found here: https://decibel.ni.com/content/docs/DOC-26295 NI uses wait loops to instruct the drive motors. My mentor who worked with me during build season is no longer coming to meetings, but he instructed me to NEVER use these because they're CPU hogs. The thought is giving me anxiety.
Is this the correct way? Is there an alternative? |
|
#2
|
|||||
|
|||||
|
Re: Timing Autonomous with While Loops?
They can be CPU hogs if used incorrectly.
The Wait call inside each one throttles the loop down and avoids sucking the life out of the CPU. So never use a While loop without a Wait. So that example works as long as you make sure to use Waits. There are several alternative styles that avoid the use of loops altogether, but Waits are still required to get your timing down. Here is one alternative using a Flat Sequence Structure: http://www.team358.org/files/program...php#Autonomous |
|
#3
|
|||
|
|||
|
Re: Timing Autonomous with While Loops?
Quote:
|
|
#4
|
|||||
|
|||||
|
Re: Timing Autonomous with While Loops?
Loops are used/required a couple of places, such as Robot Main and Periodic Tasks.vi
User programs loop to keep working and checking for driver packets, changes of robot state (Disabled/Enabled/Teleop/Autonomous), etc. If you have to check constantly to see if a limit switch is reached then a loop can be used (just always throttle it with a Wait). If the operation is commonly used both for Teleop and for Autonomous, then a loop in Periodic Tasks might be a better location for it. Last edited by Mark McLeod : 03-06-2015 at 02:23 PM. |
|
#5
|
||||
|
||||
|
Re: Timing Autonomous with While Loops?
Quote:
|
|
#6
|
|||
|
|||
|
Re: Timing Autonomous with While Loops?
How would you go about putting the limit switch to the motor controller. I'm not exactly sure what you mean
|
|
#7
|
|||
|
|||
|
Re: Timing Autonomous with While Loops?
Quote:
I think...our limit switches are in DIO 6 and 7 on out bot. So instead plug it in to the motor controller? I think it would be on a breakout board like this for the Talon SRX: http://www.chiefdelphi.com/media/img...ee71979d_l.jpg |
|
#8
|
||||
|
||||
|
Re: Timing Autonomous with While Loops?
For the talon srx and jaguar you are able to use a limit switch and put embedded code to stop the motor when the limit switch is pressed. If you do not possess these motor controllers. You probably want to use a condition in your while loop to state that if the limit switch is pressed to stop the loop.
Last edited by Kevin Phan : 03-06-2015 at 02:44 PM. |
|
#9
|
||||
|
||||
|
Re: Timing Autonomous with While Loops?
Quote:
http://www.crosstheroadelectronics.c...7s%20Guide.pdf Jaguar Getting Started Guide; see pages 7 9 10 13 14 22 http://team358.org/files/electrical/MDL-BDC24_GSG.pdf |
![]() |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|