![]() |
Wait() issue
We're having trouble with out robot losing control every time Wait() is used. We need to delay part of our code from executing for 1/10th or 1/100th second. That part works (we can't notice the delay), but in other parts of the code (where we need 1.5 second delay) we completely lose control for that period of time. Someone mentioned that we could use the Timer() class for this, but we weren't sure how accurate it is, having to Start and Stop it in a very short period of time. Here's part of out code that causes the most issues:
Code:
if ((LeftBumper)&&(RightBumper)) //xBox controller |
Re: Wait() issue
Quote:
You need to either a) use a state machine, or b) put your wait code in a separate thread where it can run concurrently. Here's a generic explanation of state machine. |
Re: Wait() issue
Quote:
Hand-coded state machines are a bit tedious. If you have more than a couple places you need them, the command-based robot approach works better. Robot builder will generate the basic code for your robot after you describe the subsystems and commands. Here's an example of what a hand-coded state machine looks like. Code:
// declare the timeout variables at the top of your Robot.cppIn case you can't recognize your code in that example, here's your code with a couple comments added to match the comments in my example: Code:
if ((LeftBumper)&&(RightBumper)) { // xBox controller |
| All times are GMT -5. The time now is 18:21. |
Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi