Skip to main content

Overview

Mars-RS includes a built-in path creation tool that allows you to visually design paths for autonomous routines. You can draw paths by clicking on the field, edit existing waypoints, and save/load paths for later use.

Entering Create Mode

To access the path creator:
  1. Click the Create button in the UI (located at coordinates 3.0, 80.0)
  2. The interface will switch to Create mode with Draw state enabled
You cannot switch between Driver and Auton modes while in Create mode. Exit Create mode first.

Create Mode States

The path creator has four states:

Draw

Add new waypoints by clicking on the field

Edit

Drag existing waypoints to modify the path

Save

Save the current path (prints to console)

Load

Load a previously saved path

Drawing Paths

Adding Waypoints

In Draw mode:
  1. Click the New Path button to start a fresh path
  2. Click anywhere on the field to add waypoints
  3. Waypoints are automatically connected with lines
if leftButton && createValid {
    self.path.push(mouse_position());
}
Waypoints are displayed as red circles (4 pixel radius) connected by black lines.

Visual Feedback

As you create a path:
  • Waypoints appear as red circles (4px radius normally)
  • Connecting lines are drawn in black (3px width)
  • Hovering near a waypoint (within 8 pixels) makes it larger (8px radius)
if dist(mouse_position(), self.path[i]) < 8.0 {
    draw_circle(self.path[i].0, self.path[i].1, 8.0, RED);
}
else {
    draw_circle(self.path[i].0, self.path[i].1, 4.0, RED)
}

Editing Paths

Moving Waypoints

In Edit mode:
  1. Click the Edit Path button
  2. Click and drag any waypoint to reposition it
  3. The waypoint follows your mouse while the button is held
if is_mouse_button_down(MouseButton::Left) {
    self.path[i] = mouse_position().clone();
    self.editing = i as i8;
}

Deleting Waypoints

To remove a waypoint:
  1. Hover over the waypoint (it will turn into a larger red circle)
  2. Press Backspace
  3. The waypoint is immediately removed
if is_key_pressed(KeyCode::Backspace) {
    self.path.remove(i);
    break;
}
Deleting waypoints cannot be undone. Be careful when removing points from your path.

Saving Paths

Save Function

To save your current path:
  1. Click the Save Path button
  2. The path coordinates are printed to the console
  3. The mode automatically returns to Draw state
if mode == ui::CreateState::Save {
    createValid = false;
    println!("{:?}", self.path);
    self.set(ui::State::Create(ui::CreateState::Draw));
}
Currently, paths are saved to the console output. You can copy these coordinates to use in your autonomous code.

Loading Paths

Click the Load Path button to enter Load mode.
The load functionality is defined in the UI but the implementation for loading from file is not yet complete in the current codebase.

Path Data Structure

Paths are stored as a vector of (x, y) coordinate tuples:
pub path: Vec<(f32, f32)>
Example path output:
[(100.0, 150.0), (200.0, 200.0), (300.0, 150.0), (400.0, 200.0)]

UI Button Layout

The Create mode buttons are arranged horizontally:
ButtonPositionFunction
New Path(130, 8)Start a new path
Edit Path(193, 8)Edit existing waypoints
Save Path(263, 8)Save path to console
Load Path(333, 8)Load saved path

Interaction Detection

The path editor uses distance-based detection to determine if you’re interacting with a waypoint:
let mut createValid = true;

if dist(mouse_position(), self.path[i]) < 8.0 || self.editing == i as i8 {
    draw_circle(self.path[i].0, self.path[i].1, 8.0, RED);
    createValid = false;
    // Enable editing...
}
  • Detection radius: 8 pixels
  • createValid prevents creating new waypoints when hovering over existing ones

Bézier Curves (Experimental)

Mars-RS includes a Bezier struct for future curve-based paths:
pub struct Bezier {
    pub points: (f32, f32, f32, f32)
}
Methods include:
  • length(): Calculate curve length
  • curvature(t: f32): Calculate curvature at parameter t
Bézier curve functionality is currently a stub and not fully implemented.

Using Paths in Autonomous

Once you’ve created a path, you can use it with autonomous functions:
// Copy path from console output
let my_path = vec![
    (100.0, 150.0), 
    (200.0, 200.0), 
    (300.0, 150.0)
];

// Execute with followPath
followPath(robot, my_path, 5000, 0.5, 0.0, 90.0, linearPID, angularPID, 0.2);

Best Practices

Space waypoints 30-50 pixels apart for smooth autonomous execution. Too close together can cause erratic movement.
Keep waypoints within the field boundaries. The field is rendered at 90% of 12 feet scaled to screen size.
After creating a path, test it in Autonomous mode before using it in competition.

Autonomous Mode

Execute paths with movement algorithms

Field Layout

Understand the VEX field coordinate system

Build docs developers (and LLMs) love