Lab 7 · Obstacle Avoidance
Crates on the way
The same field as Hello Racer. The waypoints are in a straight line, 8 m apart. Some gaps have a crate in them. The car has a lidar: 24 rays, each a distance to the first thing it hits.
You drive. Your code reads the rays and adds a pull to your steering, so the car leans toward open space. That is teleop assist: a pull, not a takeover.
Do this: drive the course in Play with assist on, gain 1.0. Hold the throttle and let the pull steer you around the crates. Watch the assist number in the readout change sign as a crate passes. Then set the gain to 0 and drive the same course raw. Count the hits both times.
The assist
The Code card has one function: assist(ranges, bearings, goal). It returns
a pull in [-1, 1], + is left. The starter blends two pulls: away from the nearest ray when a
crate is close, toward the waypoint when the way is clear.
Do this: set KP to 3.0, Apply, and drive. The push away from a crate
is now three times harder, and the car swings wide. Then set NEAR to 1.0: the
assist only wakes up when a crate is one meter away, too late at speed. Put both back.
Then do this: the ladder. P first, which is what the starter is. If the car oscillates, add a D term: subtract a share of how fast the pull is changing. If it hugs one side, add an I term: a share of the pull summed over time.
// All six waypoints with hits 0 finishes the lab.
Follow the White Rabbit
The controller ladder (P, then D, then I) is the oldest trick in control. It runs your thermostat, your drone, and every VESC.
- PID controller - the three terms, what each one fixes, and why you tune them in that order.
- Brian Douglas: PID control, a brief introduction - the ten-minute version with plots. The overshoot is your oscillation.
Play
// Arrow keys or W A S D. The waypoints are in a line, 8 m apart; some gaps have a crate. The green rays are the lidar. While you throttle, your assist() from the Code card reads the rays and the waypoint and pulls the steering. Gain 0 is raw driving. All six waypoints with hits 0 finishes the lab.
Code
// Your controller, called 15 times a second while you throttle in the Play card. Apply it, then drive.
- Assist is a pull on your steering, not a takeover. Gain 0 is raw driving.
- The pull comes from the lidar fan: the open path wins, scaled by the gain.
- P first. Oscillates? Add D. Hugs one side? Add I.
- RoboRacer course: Lecture 5 - Follow the Gap - obstacle avoidance from a lidar scan: find the gap, steer to it
- RoboRacer course: Lab 4 - Follow the Gap - the gap follower as a lab
// roboracer.ai (formerly F1TENTH), not goatracer.ai. Each link opens in a new tab.