StepTracer_Ray is a competition-oriented line tracer project built around repeated runs on the same track. Instead of driving every lap with the same logic, the robot improves its strategy step by step: it first learns the course, then replays it faster, and finally applies more aggressive tuning for maximum performance.
That multi-stage race strategy is the core idea of this project.
- 3rd race video:
assets/videos/third-race.mp4
The project is organized around three race stages:
- 1st race: search and map generation
- 2nd race: map-based fast replay
- 3rd race: advanced tuning with trajectory shift and gain scheduling
The recorded race data is stored in search_info[], which is then reused by the later runs.
The first race is the learning phase.
During this run, the robot follows the line while detecting turn marks, measuring distances between sections, and recording track information. The collected data is stored in search_info[] and later written to ROM so the next race can reuse the course map.
In short, the goal of the first race is reliable completion and track memorization.
The second race is the replay phase based on the recorded map.
After loading the saved track data, the robot classifies each section as straight, 45-degree turn, 90-degree turn, 180-degree turn, 270-degree turn, or large turn. Based on that information, it calculates acceleration, deceleration distance, entry speed, exit speed, and maximum speed for each segment.
Because the course is already known, the robot can drive more aggressively on straights and prepare for corners earlier than in the first race.
The third race is the fully optimized performance phase.
This stage keeps the map-based replay logic from the second race, but adds more advanced tuning such as:
- target position shift before and after corners
- corner-group speed optimization
- adaptive
Kpcontrol - more detailed acceleration planning
Instead of always following the line with the same center position, the robot intentionally shifts its trajectory depending on corner shape and surrounding track pattern. This allows faster and smoother cornering.
Related demo:
- 3rd race run video:
assets/videos/third-race.mp4
-
main.c
System initialization and startup flow. -
sensor.c
Sensor sampling, normalization, line position calculation, cross detection, turn mark detection, and start/end detection. -
Motor.c
Motion control, distance accumulation, acceleration/deceleration logic, and third-race control behavior. -
search.c
First-race mapping logic. -
fastrun.c
Second-race speed planning and replay logic. -
extremerun.c
Third-race advanced tuning logic. -
Rom.c
Save/load logic for calibration data and recorded race data. -
menu.c
Menu interface for selecting race modes and tuning values.
- 16-sensor line detection system
- weighted position calculation for smooth steering
- track memorization through first-run mapping
- turn classification based on recorded segment distance
- per-section velocity and deceleration planning
- third-run lateral shift and gain scheduling
- interrupt-driven sensor and motor control loop
- Third-race deep dive:
docs/extremerun-analysis.md - Focus areas:
Initial_3rd_Code/main/extremerun.candInitial_3rd_Code/main/Motor.c
This is not just a basic line follower. It is a staged racing system that combines sensing, memory, motion planning, and control tuning to improve lap performance across multiple runs.
The overall idea can be summarized as:
- learn the course,
- replay the course faster,
- optimize the trajectory and control for the best run.
