Overview
Driver mode allows you to manually control the robot using keyboard inputs. The control system implements a differential drive model with velocity limiting and friction simulation.Keyboard Controls
The robot is controlled using the WASD keys:W Key
Move forward - increases linear velocity
S Key
Move backward - decreases linear velocity
A Key
Turn left - increases angular velocity
D Key
Turn right - decreases angular velocity
Velocity Limits
The driver system enforces maximum velocity constraints to ensure realistic robot behavior:Linear Velocity
- Maximum forward/backward speed: 4.0 units/s
- Acceleration per keypress: 0.2 units/s
- Friction deceleration: 0.07 units/s when no input
Angular Velocity
- Maximum turning speed: 0.07 rad/s
- Turning acceleration: 0.0076 rad/s
- Friction deceleration: 0.005 rad/s when no input
Differential Drive
Mars-RS uses a differential drive model that converts linear and angular velocities into left and right wheel velocities:vel.0is the linear velocityvel.1is the angular velocitytrackis the robot’s track width (distance between wheels)vlandvrare the left and right wheel velocities
Friction Simulation
The driver mode includes friction to make the robot feel more realistic:The friction values are tuned to provide smooth control while preventing the robot from sliding too much.
Switching Modes
To enter driver mode:- Press the T key to toggle between Driver and Auton modes
- Click the Driver button in the UI
Implementation Details
The driver code is located insrc/driver.rs:43-77. The main drive function:
- Calculates absolute values and signs of current velocities
- Clamps velocities to maximum limits
- Applies friction to slow down the robot
- Processes WASD key inputs
- Converts to differential drive wheel velocities
- Updates robot position
Related
Autonomous Mode
Learn about autonomous movement algorithms
Path Creation
Create paths for autonomous execution