Intro to FRC Programming - Romi
  • INTRODUCTION
    • Overview
    • Important Links
  • 💽Setup
    • Setting up the Romi's Software
    • Downloading Essential Tools
    • APCS vs FRC
  • How To Code in VSC
    • VSC- Intro
    • A Tour Through VSC
    • Creating a Regular Java Project
  • Intro to Java
    • What is Java?
    • Beginning Steps
    • 🟩Fundimentals of Java
      • Variables
      • Operations
      • Methods
      • Comments
      • If Statements and Conditions
      • Boolean Zen
      • Loops
      • Challenge- Create a Box House
    • 🟨Advanced Concepts
      • Objects
      • Scanners
      • Null Objects
      • Arrays
      • Errors
      • For-Each Loops
    • 🟥Object Oriented Programming
      • Basics of OOP
      • Instance Classes
      • Static Classes
  • 🕑Romi Curriculum- Timed Base
    • Romi Curriculum- Introduction
    • Creating a WPILIB Project
    • Running Your Code
    • The Robot Class
    • Subsystems
      • RomiDrivetrain
    • Cool stuff i will rename this category later
      • Spark Motors
      • PIDs
      • External Controllers
      • Encoders
  • 🖥️Romi Curriculum- Command Based
    • Command Based Code
    • RobotContainer
    • Commands
    • CommandScheduler
  • UNRELATED IMPORTANT CODING KNOWLEDGE
    • Constants
  • SAMPLE CODE
    • Tank Drive Example
      • RobotContainer
      • TankDriveSubsystem
      • MoveRobotCommand
    • Worktop Systems Sample Java Code
      • Belt Elevator Sample Code
      • Rotating Arm Sample Code
Powered by GitBook
On this page
  • ConfigureBindings()
  • Triggers
  1. Romi Curriculum- Command Based

RobotContainer

PreviousCommand Based CodeNextCommands

Last updated 2 months ago

RobotContainer is a class that combines the subsystems, commands, and triggers of the robot. It's basically the brain of the robot.


ConfigureBindings()

ConfigureBindings() holds triggers that listen for controller inputs.

Triggers

Triggers are a powerful feature in WPILIB's command-based framework that lets you bind commands to various events. For example, we can use them to run commands when we press a button, or when a sensor detects something.

Some examples of things we can use triggers for are:

  • Getting inputs

  • Checking sensors

  • Checking state changes

However, on this page, we'll focus primarily on using triggers for moving the robot. When doing this, we don't create brand new Trigger objects— we just use the built-in ones from our External Controllers.

All of these triggers can be found .

Triggers have three built-in methods that we use to run commands depending on specific criteria. The most common ones are:

  • OnTrue(Command c)

  • OnFalse(Command c)

  • WhileTrue(Command c)

  • WhileFalse(Command c)

As you can tell, all four of these methods take in a command for a parameter. All four of them also run whatever's in their parameters, but depending on their name, run at completely different times. (for example: WhileTrue() runs its command while a condition is true)

If you want an example of how to use them, look back at configureBindings() at the second trigger statement. As it stands, while the B button is held down, it will constantly schedule this example method command.

If I change it to onTrue(), the trigger will only schedule the command when the B button is pressed down for the first time.

By mastering triggers, you can create responsive, sophisticated robot behaviors that react intelligently to both operator inputs and changing field conditions, all while maintaining readable and maintainable code.

🖥️
here