![]() |
Share you Autonomous
I am looking at working with are students this off-season to better off are autonomous skills. I was wondering if any teams would care to share there labview autonomous code so that we could learn from it.
Currently we only know of two ways of doing autonomous 1) Hard code 2) Playback recorded data are there any other methods people know off? |
Re: Share you Autonomous
Quote:
|
Re: Share you Autonomous
I looked at doing this but it seems like it would be hard to do 2 things at once. Is there a way around this
|
Re: Share you Autonomous
State Machine? Although that may count as "hard code" to you. We'll be posting this years code at some point. Our two-ball auto involved roughly 25 steps due to a variety of things (it's being reprogrammed to be simpler). Our one ball was four steps, but also involved communicating with an additional statemachine (which also runs during Tele) for opperation.
|
Re: Share you Autonomous
We have done state machine in the past and it works well. Are biggest problem right now is that we hard code it so it is not very easy to change on the fly. I am wanting to find a way to rapidly produce autonomous and change it easily
|
Re: Share you Autonomous
1 Attachment(s)
Here's FRC3548 autonomous and teleop program (w/o Camera) in Labview.
The autonomous program is very brute force using simple timers to actuate motor speed and throwing arm commands but it works, we shot 9 out of 11, 10 pointer's at MSC! |
Re: Share you Autonomous
We're working on recoding the robot using behaviors (and will hopefully do this from the start next year). This should make it easier for us.Basically, we are coding a VI to control our intake and another to control the catapult. We'll then use these in a state machine or autonomous to control the robot. Similar things for the drive system. Basically, these are the equivalent of C++ function calls for controlling the subsystems. This would help you in building it faster.
As for changing it easily, what exactly do you mean? I can think of a few things we do, but I don't know what you have in mind. |
Re: Share you Autonomous
Scripted autonomous is fairly... interesting.
4213 'used' it this year, but left it as the same script. We searched the cRIO root directory for the first '.auton' file, and then execute through that via state machines. Our basic structure is a bunch of <subsystem> <state> or <wait> <subsystem>. To wait for multiple subsystems, wait multiple times. Script looks like this: Code:
drivetrain 0.5 0 0 1 //0.5 Y, 0 X, 0 W, 1 secondI'll see if I can find the source code. I think it got diked/subverted/buried. We use state machines... a lot. I highly recommend you learn how to use and implement a state machine if you don't already. It makes coding so much easier. |
Re: Share you Autonomous
What language are you using?
For the command based system, writing reusable commands that take in real world parameters and using them in a command group can give you a quick way to write new autonomous routines in the fly. Below is an example: Code:
addSequential(new DriveStraightCommand(0.85, 60));If you have tested these commands out extensively you should know the robot will do exactly that the first time you run it. |
Re: Share you Autonomous
To switch between auto modes, we have a dropdown menu on the dashboard. Some specific aspects of it are on other controls, like move forward time, which is on a slider.
The drop down menu selection is sent to a state machine. For the programming of it, I package all complex functions (like a timer function, shooter sequence, and swerve drive) into sub-vi's, which makes new auto modes pretty easy to produce, though I guess it still counts as hard coded. |
Re: Share you Autonomous
One other method for doing autonomous is using machine learning-ish concepts. One thing we have thought about doing is having scouts in the stands recording if our robot makes shots and then using that information to find positions on the field that are viable to shoot from (using accelerometer and gyro). We then could import that information after each match and the robot could recalculate an autonomous path. I have written some code to do this and it worked quite nicely; however, we didn't get a chance to use it at comps.
|
Re: Share you Autonomous
Quote:
Quote:
Our autonomous modes were DAGs that would not only do different things but intentionally leave the robot in different states for the driver depending on what happened during autonomous. |
Re: Share you Autonomous
Quote:
Here is an example of non linear steps. Code:
addSequential(new DriveStraightCommand(0.85, 60));Code:
DriveStraightCommand driveCommand = new DriveStraightCommand(0.85, 120); |
Re: Share you Autonomous
Please check out this paper written by apalrd on beescript.
http://www.chiefdelphi.com/media/papers/2497 We implemented this a few years ago, and love the flexibility of beescript. Our two ball script looks like this: Code:
#Two Ball AutonomousWe will be making public our github project in the next few weeks, after they clean up the commits from championship. |
Re: Share you Autonomous
I really like this idea. The only problem i see with it is you can only do one command at a time. have you found a way to get around this problem?
|
Re: Share you Autonomous
2 Attachment(s)
We used a record and replay system for autonomous this year. Attached are the complete projects for the custom dashboard and robot.
There is a tab on the dashboard for starting and stopping the recording process. It uses the SmartDashboard to communicate between the dashboard and robot. |
Re: Share you Autonomous
Quote:
I forgot to mention the best part is that the script file is just a text file that resides on the cRio. The cRio has a built in ftp server, so you can change these sequences, and re-run without connecting to labview, compiling, etc. The whole process to change the script and ftp to the cRio can be done in about a min. We have done this while queuing for a match. It takes less time to change the auto code, and download, than it takes to charge the pneumatic system. We also have a dashboard selection that chooses between 7 automodes. |
Re: Share you Autonomous
Quote:
Code:
#Load the shooting mechanismInstead you can write your command to tell a different process the same thing, letting the script continue. It then can meet back up with the WAIT_ON_LOAD command to make sure its ready to shoot. In this way, both the driving and the camera code are running in parallel with the code to load the shooter. Essentially you can write your commands to set off a parallel part of the code and continue. If all of the main robot actions are handled in a separate process, this becomes much easier to do (and it carries over to teleop). |
Re: Share you Autonomous
any reason you choose to save it on the crio and not just read it from a laptop?
|
Re: Share you Autonomous
Yes, I don't know how to get the cRio to read a file over the FMS to the driver station. Maybe there is something there already, but I have never tried it.
|
Re: Share you Autonomous
You can implement your own UDP/TCP connection to communicate between the dashboard and the cRIO. We have done this in labview when we needed extra vision processing computing power. Also, the smart dashboard may have similar capabilities.
|
Re: Share you Autonomous
Quote:
|
Re: Share you Autonomous
Quote:
What I was trying to ask is if you could do something like: Code:
if goal is hot: |
Re: Share you Autonomous
Quote:
TwoBallTwoHotGoalCommand Code:
HotGoalFinder finder = new HotGoalFinder();Code:
public class DecisionCommand extends Command {Code:
public interface IProvidesDecision { |
Re: Share you Autonomous
1 Attachment(s)
This isn't our main autonomous (our main autonomous uses vision tracking to detect the hot goal and shoot at it; don't have access to the team's programming computer atm and left my flash drive in it) but it's a 2-ball autonomous VI that wasn't used in the final code. It's pretty basic as it was written in a blank VI and so I didn't get to use global variables or subVIs. See if it helps.
|
Re: Share you Autonomous
Quote:
in twoBallHot.script Code:
SHIFT onCode:
DRIVE_STRAIGHT 75 0Code:
DRIVE_STRAIGHT 75 0 |
Re: Share you Autonomous
Our one ball hot check script was this:
Code:
#One Ball, with Hot Checking |
Re: Share you Autonomous
Quote:
|
Re: Share you Autonomous
Quote:
Here's something you could do if you wanted to be avoid duplicating the end of command conditions in the subsequent if: Code:
class Continuable extends Command{ |
Re: Share you Autonomous
Quote:
|
Re: Share you Autonomous
We used to hardcode our autonomous routine in C++, but we found that compilation and deploy times added too much overhead and made it hard to quickly change routines on the fly.
To address this issue, we tried a scripted approach this year to autonomous. The first iteration of our "scripting" approach was a simple list of commands that the C++ codebase interpreted step-by-step: Code:
# sample one ball autoCode:
parallel(load(), turn(30.0))We looked at a lot of possibilities, and we decided on Lua, a scripting language popularly used in video games where processing has to finish in 20-30 millisecond time steps. As a plus, an open-source ANSI-C interpreter was available. We put together a quick prototype, exposing C++ functionality to Lua using its aliasing feature. However, we quickly realized that an issue inherent to using Lua (or any other general-purpose scripting language, for that matter) was that we lost the step-by-step and parallelization functionalities. At the same time, we didn't want to have to pause execution of the main robot loop to run our autonomous routine or have to coordinate multi-threaded execution. It turns out that Lua's coroutine functionality is perfect for achieving this functionality. When the Lua code calls a C++ function, the function pauses execution of the script and keeps a tab on the requested function. On each update of the script interpreter, the function is checked for completion, and upon completion, the script is resumed and is run until the next pause or the end of the script. This is great because from the script's perspective, everything is clean and nice and you don't have to deal with waiting for routines to complete and whatnot. The next issue we wanted to address was running parallel routines. To do this, we created two functions, beginActionGroup(name:string) and endActionGroup(). If calls to C++ functions are made between these two functions, the script delays execution and instead adds the routine to a list instead of running the routine immediately (and yielding execution of the script). When the action group is run, each of the sub-routines are run in parallel. To run action groups in parallel, the function runParallel(group1:string, group2:string, group3:string, ...) is called and behaves like any other routine (e.g. script execution is paused until completion). With these issues solved, we were able to write the following for our double ball hot routine: Code:
--[[Code:
function dribbleDrive(distance, waitTime) |
Re: Share you Autonomous
Seeing all the examples here makes me realize that there are major differences not only in coding styles or technologies used but also in the logic implemented. I wonder how much what teams do in autonomous is influenced by the style in which it's written.
At each step in our autonomous program we had multiple things that could happen. Basically, there was: 1) What if autonomous mode ends? 2) What if you're running out of time in autonomous mode? 3) What if the normal action of the step has completed? 4) What if none of the above have happened? This seems like it would be horribly awkward to code in the styles that most people appear to be using but it was no big deal for us since we had an explicit state machine. It seems weird to me that even teams that care enough to embed a Lua interpreter or write their own scripting language to run their autonomous modes don't seem to be doing anything like this. |
Re: Share you Autonomous
My answers are in bold red:
Quote:
|
Re: Share you Autonomous
Quote:
Code:
State next_state(State current_state){Does your robot always do the same thing on abortion of the Lua script? It seems like it should be possible to make it do different things since you could call some C++ function to set a variable to remember what mode you should go to after the script finishes. |
Re: Share you Autonomous
Quote:
Is it possible? Sure! Lua is really flexible in that you can call into C++, so yes, you would be able to call a C++ function to set a flag, and after autonomous your code could read that flag and act upon it. |
Re: Share you Autonomous
We implemented a simple state-machine framework this season. It was used in both teleop and autonomous.
It worked as such: States (which were a lot like commands) could return SUCCESS, FAILURE, or NOT_DONE. StateMachines would add a number of states into them, then map the state transitions. It would look something like Code:
int one = new DetectHotState(); //returns SUCCESS for left, FAILURE for right |
Re: Share you Autonomous
Here's our 2-ball script. Works off of a custom JavaFX text editor on the developer laptop than is FTP'd and saved on the crio in raw binary format.
Might open source it before 2015, not sure. Code:
Auton: 2 MoveKickTargetingIndenting doesnt actually matter, but linebreaks do. The way the commands work is as follows Code:
public class RequestPeriodic |
| All times are GMT -5. The time now is 23:57. |
Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi