Skip to content

thdtjdgur/StepTracer_Ray

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

20 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

StepTracer_Ray

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.

Hardware Image

StepTracer hardware

Demo Video

Overview

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.

Race Strategy

1st Race - Search Run

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.

2nd Race - Fast Run

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.

3rd Race - Extreme Run

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 Kp control
  • 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:

Core Modules

  • 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.

Technical Highlights

  • 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

Detailed Code Analysis

Project Idea

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:

  1. learn the course,
  2. replay the course faster,
  3. optimize the trajectory and control for the best run.

About

StepTracer_Ray(code for a contest)

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors