We are Team 6560, the Charging Champions, a student robotics team based in Irvine, California, participating in the FIRST Robotics Competition (FRC). Our work brings together mechanical design, electronics, and programming to build and operate a competition robot. Software connects these parts: it interprets sensor measurements, controls motors, and coordinates the robot's actions.
This project explores how mathematical models and sensor feedback can help our robot move more accurately and perform coordinated tasks more reliably. In simple terms, state-space control describes what a mechanism is doing now, such as its position and velocity, and uses a model of its motion to calculate how the motors should respond. For example, an arm approaching its target quickly needs to slow down before it reaches that target.
We want to study these methods in simulation, compare them with our existing controllers, and evaluate them on physical mechanisms. The broader goal is to connect the mathematics with practical robot software: estimating motion from imperfect measurements, responding to changing conditions, and coordinating several mechanisms during a task. The sections below describe our planned approach; they are a roadmap, rather than a claim that every capability is already implemented.
The project is also an opportunity for students to learn how physics, mathematics, and computer science work together in a real engineering system.
This repository describes Team 6560's plan to study state-space control and determine where it can improve the accuracy, stability, and coordination of an FRC robot. Our goal is not to replace every Proportional-Integral-Derivative (PID) controller with a more complicated method. Instead, we plan to model each mechanism, compare model-based control against our existing methods, and use state-space control only when the additional information produces a measurable improvement.
A complex robot may need to drive, move an arm, rotate a turret, spin a flywheel, and operate an intake during the same task. These mechanisms do not always finish at predictable times because their response depends on starting position, battery voltage, friction, game-piece load, and motion of the rest of the robot. As a result, an autonomous sequence based only on fixed delays can either continue before a mechanism is stable or wait longer than necessary.
We plan to separate this problem into three layers. State estimation will determine the current condition of the robot from its sensors. Local controllers will move each mechanism toward a defined position or velocity. Finally, a command-based coordinator will run independent motions in parallel and continue the sequence only after the necessary states remain within defined tolerances. With this structure, state-space control handles the physical behavior of each mechanism, while the command scheduler still determines the task that the robot performs.
The state is the minimum collection of variables required to predict the future behavior of a system. For a rotating arm, we can represent the state as
where
For software operating at discrete time steps, the system is written as
The matrix
This model requires physical information such as motor characteristics, gear ratio, moving mass, moment of inertia, and mechanism geometry. We can initially calculate these values from the design, but theoretical estimates will not represent friction, mechanical compliance, or changes made during construction. Therefore, we plan to characterize the completed mechanism with WPILib SysId and replace uncertain estimates with measured system constants before evaluating the controller.
State feedback calculates motor voltage using both the desired state and the estimated current state:
Here,
We plan to calculate
The matrix
Not every state can be measured accurately. Encoder position is usually reliable over a short time, but encoder-derived velocity can be noisy, and drivetrain odometry accumulates error as the wheels slip. An observer combines the predicted state with the difference between the predicted and actual sensor measurements:
The matrix
For drivetrain localization, we plan to combine swerve-module odometry and gyro measurements with field-position measurements from a Limelight observing AprilTags. Odometry provides frequent and smooth short-term updates, while AprilTags correct the position error that accumulates over time. The vision measurement must use the timestamp at which the image was captured so that camera latency does not apply an old position to the robot's current state. Furthermore, distant, high-ambiguity, or physically inconsistent measurements should be rejected or assigned greater uncertainty instead of being treated as equally accurate.
To understand and modify these controllers, we need the following mathematical background:
- Vectors: representing a collection of states, references, measurements, or actuator inputs.
- Matrices: transforming the current state and input into a predicted future state.
- Matrix multiplication: verifying how the dimensions and units of each model component relate.
- Systems of linear equations: solving for unknown states or model parameters.
- Eigenvalues: evaluating whether the modeled response is stable and how quickly it changes.
- Discretization: converting continuous differential equations into updates at the robot's loop period.
- Covariance matrices: describing the uncertainty and correlation of estimation errors.
- Controllability: determining whether the available actuators can move every required state.
- Observability: determining whether the available sensors can reconstruct every required state.
WPILib can perform much of the matrix calculation, but it cannot determine whether our selected state, units, model, or sensor assumptions are physically correct. We therefore need to understand what each matrix represents even when a library calculates the final controller or estimator gains.
We plan to develop the project in the following stages:
- Select one simple mechanism and define its states, inputs, measurements, operating range, and safety constraints.
- Calculate an initial model from the motor, gearing, mass, inertia, and geometry.
- Simulate PID with feedforward and LQR under the same reference motion, voltage limit, and disturbance conditions.
- Measure rise time, settling time, overshoot, steady-state error, and voltage use rather than judging the controllers only by appearance.
- Characterize the physical mechanism with SysId and update the model with measured constants.
- Add an observer when a required state is missing or a direct measurement is too noisy.
- Test the controller under battery-voltage changes, additional load, sensor noise, actuator saturation, and reasonable model error.
- Apply the same process to coupled or multivariable mechanisms only when the simpler experiment supports the additional complexity.
- Coordinate complete robot actions with commands that run independent mechanisms in parallel and wait for measured position, velocity, and stability conditions instead of fixed delays.
Based on these tests, we will retain state-space control only where it produces a useful and repeatable improvement. A simple mechanism may still be controlled more effectively with PID and feedforward because that solution is easier to tune, diagnose, and repair during a competition.
- An arm or elevator that must control position and velocity while compensating for gravity.
- A turret that tracks a moving target while remaining inside its mechanical rotation limits.
- A flywheel that must reach a stable angular velocity before a game piece is released.
- A swerve drivetrain that follows a trajectory using estimated field position and velocity.
- A multi-joint mechanism in which the motion of one joint changes the behavior of another.
State-space control is most useful when prediction, state estimation, coupled motion, or multiple actuators affect the result. The purpose of this project is to identify those situations, validate the models experimentally, and give Team 6560 a repeatable process for implementing model-based control when it provides a practical advantage.