1 / 21

Autonomous Flexibility

Autonomous Flexibility. Creating Flexible, Script-Controlled Autonomous Software Example Explanation. Contents. Do this first... Running the autonomous simulator The example autonomous code Example autonomous script template Blank auton.vi

kellems
Télécharger la présentation

Autonomous Flexibility

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Autonomous Flexibility Creating Flexible, Script-Controlled Autonomous Software Example Explanation

  2. Contents • Do this first... • Running the autonomous simulator • The example autonomous code • Example autonomous script template • Blank auton.vi • Integrating your autonomous vi into your robot cRIO project • Other stuff to make it work on the robot • Where to go from here

  3. Do this first... • Create a new folder on your hard drive • Save autonExamples.zip to the folder you created in step 1 and unzip • The autonomous simulator, example autonomous software, example cRIO project, and some other useful files will be in the folder you created • Autonomous simulator and example autonomous software will be in <folder>\autoSim • Example cRIO project will be in <folder>\exampleRobotCode

  4. Running the autonomous simulator • The autonomous simulator is probably the most important tool for understanding the examples – spend some time working with it • To run the simulator, open “autonSim.vi” in LabVIEW. • From the autonSim front panel, click the Run button on the tool bar (upper left).

  5. Running the autonomous simulator, continued • From the dialog that opens, open the file “LeftScore2.csv” (example 2 tube auton) • The simulation should now be running. If you look at the front panel, you should be seeing the robot’s X and Y coordinate as well as the heading changing in real-time. • When the simulation is finished, it will ask you to save the robot path data to a file. Type “out.csv” in the dialog and press OK. • The path of the robot will now be plotted on the field.

  6. Running the autonomous simulator, continued • If you want, you can open out.csv in Excel (or Matlab, etc.) to analyze the path data. • Now that you have it running, you can create your own autonomous scripts or new code and test it out. You should find the simulator to be extremely helpful in debugging your code. • You can find the autonomous code (autonSample.vi) in the block diagram of autonSim.vi.

  7. Behind The simulator • If you are interested in how the simulator works, I would suggest reading my other presentation on Software Testing via Simulation (see CD media papers area). • Opening robotModel.vi shows that the robot model is actually two simple first-order models. • Think of the model as “inverse arcade drive” • The speed is modelled with a first order filter and the turning is modelled with another first order filter • The speed and turning are coupled together with a little trigonometry (like inverse odometry).

  8. Example autonomous code • Open autonSample.vi • This is the autonomous software that was developed during the conference presentation, with the following additions: • Added the code to reset the time (see Tzero) when the primitive exits • Added code to keep track of the encoder distance at the exit of each primitive • Added new primitive: drive straight with gradual approach (could be used as “hold position” if exit condition is changed to time). • Added output for desired arm position using the last parameter of the script. I didn’t clean it up or make it pretty – sorry for the crossed wires, etc.

  9. Auton script template example • A script template file is a good idea to document how the autonomous scripts are supposed to be written. • autonTemplate.xls is provided as an example script template. • Note that the script template attempts to explain everything needed to write a script, including how to do it and how to get it to the cRIO.

  10. Breakdown of leftscore2.csv • Recall primitive IDs: 0 = Delay/Coast; 1 = Straight; 2 = Turn In Place; 3 = Straight with Gradual Approach. • Column / Meaning: • Initial position: X=410, Y=225 (start of line leading to left rack) • Straight Gradual Approach, Heading = 0 deg, 210 inches, 0.8 power • Delay/Coast, 1500 msec. • Straight Gradual Approach, Heading = 0 deg, -195 inches, 0.8 power • Turn In Place to heading of -80 degrees, 0.8 power • Straight Gradual Approach, Heading = -90 deg, 30 inches, 0.8 power • Turn In Place to heading of 0 degrees, 0.8 power • Straight Gradual Approach, Heading = 0 deg, 195 inches, 0.8 power • Delay/Coast 1500 msec. • Delay 10000 msec (10 seconds – guarantees autonomous mode ends before script ends).

  11. Blank autonomous vi • A blank autonomous vi (blankAuton.vi) was included to give you a template as a starting point for your coding • All you have to do is add more cases to the structure if needed, and add more outputs to unpackAutonArray.vi if needed.

  12. Integrating the software in your robot crio project • An example cRIO project was provided and is in <folder>/exampleRobotCode • The example project is called wof2011.lvproj • AutonomousIndependent.vi in the sample cRIO project shows how your autonomous vi should be integrated. • Step by step instructions for integration (the example shows this already completed): • Open AutonomousIndependent.vi • Use “Select a vi” to add your autonomous vi that you developed using the simulation tool. • Wrap a “while” loop around your auton vi. • Hook up the inputs and outputs. • Voila. You’re done.

  13. Example crio project - warning • Note: I did not test the cRIO project, so it may contain a bug or two. • IMPORTANT: Before running on the real robot, check that 1) motors go in expected direction, 2) sensor polarity is correct. • What happens if a sensor or motor goes in the opposite direction of what you expect? (Answer: it will go in the opposite direction at full power, most likely breaking something!)

  14. Other stuff to make it work • Question: Now that I have the autonomous software working in simulation and integrated into my robot project, how do I modify my robot code to read the script files? • Answer: everything you need is in the example cRIO project. See the following: • Begin.vi (bottom of block diagram): • Code that looks in the “auton” folder of the cRIO, determines how many files are in the folder, and reads all of the file names into a string array. • After getting all of the file names, the code reads the first file (see readAutonCSV.vi). • Also, encoders are opened in Begin.vi so the autonomous software has sensors for feedback.

  15. Other stuff to make it work • Disabled.vi: • Open selectAutonMode.vi • The code reads two buttons on the driver’s joystick – one button cycles UP the file list, the other button cycles DOWN the file list. • If the driver exceeds one end of the file list, the code wraps back to the other end of the list. • After a button press, the newly selected file is read using readAutonCSV.vi. • The starting position is updated from the first column of the CSV file. • All sensors are reset to 0.

  16. Other stuff to make it work • PeriodicTasks.vi: • There is a lot of code here for controlling an elevator and arm. Feel free to ignore it (or use it if you want to). • The code needed for autonomous is at the bottom of the fast loop: • The left and right drive encoders are read. • The average of the two encoders is used as distance feedback (how far the robot has driven). • The difference between the two encoders (along with some math) gives the heading of the robot. • The distance and heading can be used to calculate the robot’s X,Y position on the field (see CalcXY.vi). • Note: this two-encoder setup can be replaced with a single encoder and a gyro for the heading.

  17. Other stuff to make it work • Where to put the files on the cRIO? • The example code is set up to use a folder called “auton” that is created in the root of the cRIO drive. To do this: • Open FileZilla (or your favorite FTP program) and connect to the cRIO. • To connect to the cRIO, in the “Host:” box, type: “10.xx.yy.2” and click the “Quickconnect” button. (Note: xx.yy is your team number. For example, team 51 would be 10.0.51.2. Team 2112 would be 10.21.12.2, etc.) • The left half of the FileZilla window will be your computer. The right half is the cRIO. • On the cRIO side in the box where you see “Filename”, right click and select “Create directory”. • You will see a new folder – name it “auton”

  18. Other stuff to make it work • How to get the files to the cRIO? • Connect using FileZilla or other FTP program. • In the cRIO side (right side in FileZilla), navigate to the “auton” folder you created. • In the left side, navigate to your .csv autonomous scripts. • Drag from the left side, drop in the right side. Your files will be copied to the cRIO. • What if I want to delete files from the cRIO? • FileZilla is just like Windows Explorer. • In the cRIO side (right side in FileZilla), navigate to the “auton” folder, select the files you want to delete, then press the delete key. It’s as simple as that.

  19. Where to go from here? • Try creating some simple scripts for the example autonomous software that was provided. Get them to run in the simulator and make sure they do what you want. • Once you get a feel for the scripts, use the simulation tool to develop your own autonomous software. • Try creating a few primitives on your own and get them working in simulation. • Use the example code to get it working on your robot – you may need to add some encoders and/or a gyro to your robot.

  20. Where to go from here? • Try expanding the number of parameters the primitives need (currently there are 5 rows to the script file – row one is the ID, so that leaves 4 parameters). • If you expand to use more parameters, you will need to make the following changes: • readAutonCSV.vi – change “number of rows” constant into ReadFromSpreadsheetFile.vi. Don’t forget to do this in autoSimRun.vi as well. • unpackAutonArray.vi – expand to unpack more rows from AutonArray.

  21. Things to try • Create a primitive that actively holds the robot’s position on the field. This is useful when using an appendage to score (especially in games where defense is allowed during autonomous mode). • Create a primitive that uses the arm position as an exit condition. You’ll need to add an arm model to the robot model to make the simulation work. • Create a “Go to XY coordinate” primitive. • Create a “drive an arc” primitive. • If you can think it, you can create it. Have fun.

More Related