![]() |
New autonomous outline tutorial
Hi everyone,
Today I will be showing you how to implement an easy autonomous system based on callbacks/events. If anyone has done JavaScript using the jQuery library you will be quite familiar with the concept of a callback. A callback is a function (or method depending on the language) that executes after a set of code is done running. Here is a quick jQuery example... Code:
$(document).load(loadFunction);Code:
typedef bool (Event*)(void);The next step will be to define a function that will execute all of our function pointers called Event. Code:
// Function that takes a vector of EvenCode:
bool someEvent()Code:
int main(int argc, char** argv) |
Re: New autonomous outline tutorial
Maybe I'm completely missing the point, but why not just call the commands in a list, procedurally? Like, if you had functions drive_straight(float dist, float speed) and fire_ball(void) you could just do
Code:
void autonomous_1() I'm not saying there aren't reasons for storing commands in a list. In fact, I myself wrote a system which is by all metrics complex in LabVIEW to do a similar thing. However, I was trying to gain the ability to store the command vector in a text file, and load it on demand. Had I only wanted to write the commands in LabVIEW, I would have just called the command blocks in sequence (which I did successfully in our 2010 season, which suffered only from a very long on-field iteration time due to LV compile time issues). |
Re: New autonomous outline tutorial
Quote:
|
Re: New autonomous outline tutorial
I see. You are able to launch the next command before the previous command finishes.
That makes a lot of sense. However, when do you really need to do that? I spent a very long time trying to get my script system to allow asynchronous command execution and decided that it was too difficult of a tradeoff in code complexity. I found that there was no reasonable case in which it was impossible to write autonomous code with only one autonomous commanded action executing at a time, with the blocks I wanted to write. The tradeoff is always between simplicity in execution and flexibility in design. |
Re: New autonomous outline tutorial
Quote:
|
Re: New autonomous outline tutorial
Have you looked at the Command based programming model introduced in 2012?
|
Re: New autonomous outline tutorial
Quote:
|
Re: New autonomous outline tutorial
Quote:
http://firstforge.wpi.edu/sf/docman/...tation/doc1297 |
Re: New autonomous outline tutorial
Quote:
http://www.chiefdelphi.com/forums/sh...88&postcount=1 http://www.chiefdelphi.com/forums/sh...d.php?t=109719 http://www.chiefdelphi.com/forums/sh...1&postcount=25 |
| All times are GMT -5. The time now is 02:08. |
Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi