1 of 42

YEAR 1 SOFTWARE TRAINING

2023

2 of 42

INTRODUCTIONS

  • Name
  • Students: Year in School / Mentors: job experience
  • Coding Experience
  • Robotics Experience
  • Favorite Movie / TV Show

3 of 42

GETTING STARTED

  • Laptop with admin privileges
    • Personal
    • Team laptop
    • Cannot be school laptop
    • We’ll use team laptops tonight

4 of 42

TRAINING

5 of 42

GOALS

  • Learn FRC Coding environment & the tools we use
  • Learn how to code FRC robots the 302 way
  • Write Code to support Y1 Connect 4 Robot
  • Add something to the Team 302 Base Template
  • Get Prepared for FRC Varsity Season
  • Do some 2023 FRC WPILIB beta testing with our base code

6 of 42

FRC ENVIRONMENT - TOOLS

WPI Tools

  • VS Code
  • GitHub/GitKraken
  • PathWeaver
  • System Identification
  • RoboRio Imaging Tool
  • Radio Configuration Tool
  • Robot Simulator

Dashboards

  • Shuffleboard
  • SmartDashboard
  • LabView Dashboard
  • Glass
  • LiveWindow
  • Custom

Vendor Tools

  • Phoenix Tuner
  • REV Hardware Client
  • Limelight Finder

7 of 42

ACTIVITY

  • Get Laptop
  • Follow along
    • RoboRio Imaging Tool
    • FRC Radio Configuration Tool
    • Phoenix Tuner

8 of 42

FRC ENVIRONMENT - CODING

Languages

  • JAVA
  • C++
  • LabView
  • Python

Methods

  • Command Based
  • Timed Robot
  • RobotBase Skeleton
  • RobotBuilder

9 of 42

ACTIVITY

  • Get Laptop
  • Follow on screen to create a C++ project using VS Code

10 of 42

HEADER / IMPLEMENTATION FILES

  • Could be one file, but is normally separated
  • Header (.h) file
    • Contains Class Definition
    • Allows other classes to “include” these so they can call this classes methods
  • Implementation (.cpp) files have the logic that is executed*

11 of 42

HEADER FILE – REVIEW ROBOT.H

  • #pragma
  • #include
  • Class definition and hierarchy
  • Visibility (public, private, protected)
    • Methods
    • Attributes

12 of 42

IMPLEMENTATION FILE – REVIEW ROBOT.CPP

  • #include
  • Methods defined in header file implemented
  • Review when standard robot methods (e.g. when called and timing)
  • Common includes: string, iostream
  • Standard variable types
  • Variable scope
  • Calling provided methods

13 of 42

ACTIVITY

  • Add Counter to Robot code to see how many times things were hit using COUT

14 of 42

INTRODUCTIONS

  • Name
  • Favorite Video Game, Board Game or Card Game
  • Questions from last time

15 of 42

REVIEW

  • RoboRio Imaging Tool
  • Radio Configuration Tool
  • Phoenix Tuner Overview
  • VS Code
    • Created Project
    • Wrote Code to count how many times in each main method and wrote output to the console

16 of 42

OBJECTS VS. CLASSES

  • Class is the “recipe” or “blueprint” for object
    • Subclasses are more specialized recipes
  • Object is an instance of a Class
  • 1 class can have many objects created from it
  • So, a Wheel class could instantiate a left front wheel, right front wheel, left back wheel and right back wheel.

17 of 42

CLASS/SUBCLASS/OBJECT

  • (base) class: Dog
  • (sub) class: Golden Retriever
  • (sub) class: Dalmatian
  • Objects of class Golden Retriever: B-Dawg, Buddha, Budderball, Mudbud, Rosebud, etc.
  • Objects of class Dalmatian: Pongo, Perdita, Patch, etc.

18 of 42

ACTIVITY

Class or Object

  • Willis (aka Sears) Tower
  • Golden Gate Bridge
  • Fenway Park
  • Skyscrapers
  • Mackinac Bridge
  • Wembley Stadium
  • Bridges

  • Empire State Building
  • Wrigley Field
  • Brooklyn Bridge
  • Transamerica Pyramid
  • Stadiums
  • Lambeau Field
  • Petronas Towers

19 of 42

ACTIVITY - ANSWERS

Class or Object

  • Willis (aka Sears) Tower - object
  • Golden Gate Bridge - object
  • Fenway Park - object
  • Skyscrapers - class
  • Mackinac Bridge - object
  • Wembley Stadium - object
  • Bridges - class

  • Empire State Building - object
  • Wrigley Field - object
  • Brooklyn Bridge - object
  • Transamerica Pyramid - object
  • Stadiums - class
  • Lambeau Field - object
  • Petronas Towers - object

20 of 42

ACTIVITY

Class or Object

  • Marvel Super Hero
  • Black Widow
  • Green Lantern
  • Superman
  • Hulk
  • Aquaman

  • Iron Man
  • DC Comic Super Hero
  • Captain America
  • Super Hero
  • Wonder Woman
  • Black Panther
  • Batman

21 of 42

ACTIVITY - ANSWERS

Class or Object

  • Marvel Super Hero - class
  • Black Widow - object
  • Green Lantern - object
  • Superman - object
  • Hulk - object
  • Aquaman - object

  • Iron Man- object
  • DC Comic Super Hero - class
  • Captain America - object
  • Super Hero - class
  • Wonder Woman - object
  • Black Panther - object
  • Batman - object

22 of 42

CREATING AN OBJECT

  • Constructor – method name matches class name + no return type
  • new, make_shared, make_unique
  • Singleton

23 of 42

WPI CLASSES

  • Static Methods vs. Non-Static Methods
  • Read Method signatures (review with WPI classes)
    • NetworkTable
    • SmartDashboard
    • Timer

24 of 42

ACTIVITY

  • Using the static methods from SmartDashboard to replace cout calls for the counters

25 of 42

ACTIVITY

  • Create 3 Timers to keep track of:
    • Overall time since the robot was turned on
    • Time in Auton
    • Time in Teleop
  • Write the output values in a SmartDashboard

26 of 42

INTRODUCTIONS

  • Name
  • What’s your favorite kind of ice cream?
  • What’s your favorite Halloween Costume that have you worn?
  • Questions

27 of 42

REVIEW

  • RoboRio Imaging Tool, Radio Configuration Tool, Phoenix Tuner
  • VS Code – Create Project/Write Code/Build Code
  • Code
    • Count how many time main methods are called send to console then SmartDashboard
    • Replace Counters with Timers
  • Classes vs. Objects – instantiate classes

28 of 42

CTRE WPI_TALONSRX

  • https://docs.ctre-phoenix.com/en/stable/
  • Add a WPI_TalonSRX to our robot project and make it spin in auton

29 of 42

ACTIVITY

Make the motor reverse direction every 10 seconds

30 of 42

READING ENCODERS

  • https://docs.ctre-phoenix.com/en/stable/
  • Delete the timer and counter stuff from our project
  • Read encoders during auton and put them up on the SmartDashboard

31 of 42

ACTIVITY

  1. Update Auton to spin the motor for 1000 encoder counts and then stop the motor

32 of 42

XBOXCONTROLLER

  • https://docs.wpilib.org/
  • Add an XboxController to our project

33 of 42

ACTIVITY

  1. Make the motor spin in Teleop
  2. Make motor spin in teleop with joystick control

34 of 42

ACTIVITY

  1. Get Access to GitHub by sending email to joe.witcpalek@gmail.com with subject of GitHub
  2. Complete follow up steps when you are invited

35 of 42

BASE LIBRARY REVIEW

  • XML Robot Definition
  • XML Parsing
  • Mechanism Base Classes
  • Mechanism States

36 of 42

ACTIVITY

  • Year 1 Robot Review
    • Identify Mechanisms and what will their Base Class should they inherit from

37 of 42

ACTIVITY

  • Complete your GitHub invitation
  • Make sure laptop is updated to beta environment
  • Sign out an issue on the project and drag it into the In Progress Column
  • Create a branch for your work
  • Use GitKraken to clone Repository
  • Open VS Code to work on your item
  • Commit changes when it compiles
  • Push up to Github and create a pull request

38 of 42

STATES REVIEW

  • Review States

39 of 42

ACTIVITY

  • Year 1 Robot Review
    • What states will each Mechanism have

40 of 42

ACTIVITY

  • Access Year 1 project in GitKraken
  • Create a branch – your name

41 of 42

ADD A CHASSIS CLASS

  • Create a Chassis class
  • Inside the Chassis Class, hold onto:
    • frc::MecanumDrive object
    • a Pigeon (note difference between PigeonIMU and Pigeon2)
    • frc::MecanumDriveKinematics object
    • frc:: MecanumDriveOdometry object
  • Provide public methods to drive the chassis, return its position and update odometry
  • Create an instance of Chassis in RobotInit
  • Update the odometry in RobotPeriodic

42 of 42

ACTIVITY

  1. Add a method to reset the chassis’ position to a known position
  2. In AutonInit, reset the robot’s position to 0 meters, 0 meters and its angle to be 0_degrees
  3. Make Auton drive the chassis forward
  4. Report its current pose in AutonPeriodic to a NetworkTable