1 of 10

Team 302 Software Training

Autonomous Structure

2 of 10

Autonomous Structure

Prerequisite Training:

  • C++ Programming I or equivalent
  • Introduction to WPILIB/CTRE or equivalent
  • Introduction to Iterative Robot or equivalent
  • Introduction to XML or equivalent
  • C++ Programming II or equivalent

3 of 10

Autonomous Structure

  • Primitives
  • XML Definition
  • Parsing
  • Cycling Primitives

4 of 10

Concepts

  • Each autonomous routine is defined in an XML file
  • Autonomous file is selected from the dashboard (or in 2018 the criteria that allows the selection of the file)
  • Field Information may need to be determined (2018) to help determine the file
  • Each autonomous routine is made up of many Primitive (simple) movements (drive to a position, turn to an angle, pick up a game piece, deploy a game piece, etc.)
  • Primitives need to be configurable (e.g. how far do we drive straight and at what speed)
  • Primitives need to be robust
  • Primitives need to be able to indicate when they are done

5 of 10

Autonomous Primitives

  • Simple pieces of robot control
  • Robust
    • Do One Thing
    • Do It Well
    • Handle Error Situation
  • Configurable/Flexible
  • Drive/Positioning Primitives call Game Piece Primitives
    • Allows the robot to drive and control its mechanisms at one time

6 of 10

Autonomous Primitives

Drive

  • Drive Time
  • Drive Distance
  • Drive to Wall
  • Drive to Lidar Distance
  • Drive in an Arc
  • Drive To Peg (game specific)

Positioning

  • Do Nothing
  • Hold Position
  • Turn To Angle

Game Piece

  • Grab/Place Cube
  • Lift/Lower Elevator/4Bar
  • Turn To Cube
  • Place Gear
  • Shoot Fuel

7 of 10

Autonomous XML Definition

  • auton.dtd defines the structure
  • Each element defines a primitive

<!ELEMENT primitive EMPTY >

<!ATTLIST primitive

id ( 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 ) "0"

time CDATA #IMPLIED

distance CDATA "0.0"

heading CDATA "0.0"

drivespeed CDATA "0.0"

enddrivespeed CDATA "0.0"

xloc CDATA "0.0"

yloc CDATA "0.0"

liftheight CDATA "-1"

opengrabber ( true | false ) "false"

cubespeed CDATA "0.0"

>

8 of 10

Autonomous XML Definition

<?xml version="1.0"?>

<!DOCTYPE auton SYSTEM "auton.dtd">

<auton>

<!-- Drive to blue dot -->

<primitive id="2"

liftheight="1"

heading="0.0"

distance="116.0"

drivespeed="120.0"

enddrivespeed="50"/>

<primitive id="2"

liftheight="2"

heading="0.0"

distance="100.0"

drivespeed="50.0"

enddrivespeed="40"/>

9 of 10

Autonomous XML Parsing

  • Leverages PugiXML
  • PrimitiveParser class parses the XML file
    • Validates/Gathers inputs from XML file
    • Creates a PrimitiveParams object for each Primitive Definition in the XML file
    • Returns a Vector with the PrimitiveParams
  • CyclePrimitives class controls running the primitives defined in the XML
    • Looks at the current PrimitiveParams
    • Constructs the Primitive using the PrimitiveFactory
    • Initializes the Primitive using the PrimitiveParams
    • Runs the Current Primitive until it indicates it is finished
      • Constructs, initializes and runs it
      • Continues until there are no more primitives to run

10 of 10

Autonomous XML Parsing

  • Leverages PugiXML
  • PrimitiveParser class parses the XML file
    • Validates/Gathers inputs from XML file
    • Creates a PrimitiveParams object for each Primitive Definition in the XML file
    • Returns a Vector with the PrimitiveParams
  • CyclePrimitives class controls running the primitives defined in the XML
    • Looks at the current PrimitiveParams
    • Constructs the Primitive using the PrimitiveFactory
    • Initializes the Primitive using the PrimitiveParams
    • Runs the Current Primitive until it indicates it is finished
      • Constructs, initializes and runs it
      • Continues until there are no more primitives to run