Skip to main content

Sensors and Feedback

In this training module, we will explore the various sensors commonly used in FRC robots. We will also cover how to read data from these sensors and use that data to provide feedback for robot control in our software.


Presentation​


Do this lesson in Scriptum

The exercises below are the Sensors and Feedback lesson in Scriptum. Open the lesson, start the simulated robot and follow its README. Each step is checked with the Verify button.

New Java in this lesson: if / else statements, comparison operators, and static final constants.

Exercises​

Sensors​

  • Convert the encoder readings (getLeftPositionRad(), getRightPositionRad()) from wheel radians to meters
    • meters = wheel radians * wheel radius (0.0762 m)
  • Show chassis speeds in AdvantageScope
    • Linear speed in m/s (forward / backward)
    • Angular speed in rad/s (rotation)
  • Show distance traveled by driving
    • Use encoders to measure distance

Conditions​

  • Add a deadband so the robot ignores small stick drift
    • Declare a DEADBAND constant
    • Use an if statement on each stick to set small values to zero

Feedback​

  • Implement a simple Bang Bang controller to drive 2 meters in autonomous
    • Use encoders to measure distance
    • Use an if / else: a constant speed until the robot reaches the target distance, then stop
    • Where does the robot actually stop? Why?
    • Run Auto a second time: resetting the encoders in autonomousInit() makes it start counting from zero again

Software​

  • Variables and Data Types: Declaring variables and constants.
  • Conditions: Explanation of conditional statements in programming.
  • Control Types: Overview of different control types used in robotics.
  • VSCode: Our primary Integrated Development Environment (IDE) for programming.
  • Elastic: Guide on using the Elastic dashboard for monitoring robot data.