run() vs runTo() Commands
Quick Reference
Method
Command Ends?
Motor Stops?
Best For
run() - Continuous Control
/**
* Set the height of the elevator. Command runs forever until interrupted.
* @param height Target height
* @return A Command that never ends on its own
*/
public Command setHeight(Distance height) {
return elevator.run(height);
}When to Use run()
Example: Teleop Elevator Control
runTo() - Goal-Based Control
When to Use runTo()
Example: Autonomous Sequence
The Default Command Pitfall
The Problem
Solution 1: Use run() Instead
Solution 2: No Default Command
Solution 3: Use whileTrue() for Momentary Control
Solution 4: Use Triggers for State-Based Control
Understanding Motor Behavior
If You Need to Stop the Motor
Autonomous with runTo()
Common Pitfalls Summary
Pitfall
Symptom
Solution
Decision Flowchart
Best Practices
Further Reading
Last updated