Skip to content

Commit

Permalink
[docs] Fix nav bar and update ChoreoLib usage docs (#813)
Browse files Browse the repository at this point in the history
  • Loading branch information
calcmogul authored Oct 2, 2024
1 parent 20bd55c commit 219c200
Show file tree
Hide file tree
Showing 5 changed files with 49 additions and 29 deletions.
3 changes: 1 addition & 2 deletions docs/choreolib/auto-routines.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
# Auto Routines

Choreolib provides a higher level API to make it easier to create competitive and complex auto routines inside your robot code.
This is done by providing the `AutoFactory` class.
ChoreoLib provides the `AutoFactory` class as higher level API to make it easier to create competitive and complex auto routines inside your robot code.

## Triggers vs Composition

Expand Down
44 changes: 44 additions & 0 deletions docs/choreolib/basic-usage.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# Basic Usage

Teams that want to use their own path following structure can load trajectories directly with the following code.

``` { .java .select }
import java.util.Optional;

import choreo.Choreo;
import choreo.trajectory.ChoreoTrajectory;
import choreo.trajectory.SwerveSample;

// Loading a trajectory from a file, returns an optional if the file does not exist or is invalid
var trajectory = Choreo.loadTrajectory("myTrajectory");
if (trajectory.isPresent()) {
// Do something with the trajectory
drive.followTrajectory(trajectory.get()).schedule();
} else {
// If the trajectory is not found, ChoreoLib already prints to DriverStation
}
```
``` { .py .select }
import choreo

# Loading a trajectory from a file, throwing ValueError if the file does not exist or is invalid
try:
trajectory = choreo.load_swerve_trajectory("myTrajectory")

# Do something with the trajectory
drive.followTrajectory(trajectory).schedule()
except ValueError:
# If the trajectory is not found, ChoreoLib already prints to DriverStation
pass
```
``` { .cpp .select }
#include <choreo/Choreo.h>

// Loading a trajectory from a file, returns an optional if the file does not exist or is invalid
if (auto trajectory = choreo::LoadTrajectory("myTrajectory")) {
// Do something with the trajectory
drive.followTrajectory(trajectory.value()).schedule();
} else {
// If the trajectory is not found, ChoreoLib already prints to DriverStation
}
```
24 changes: 0 additions & 24 deletions docs/choreolib/lowlevel-usage.md

This file was deleted.

3 changes: 1 addition & 2 deletions docs/choreolib/samples.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
# Samples

Choreolib supports swerve and differential drive systems.
The only usage difference between using swerve and differential is the type of the sample used.
ChoreoLib supports swerve and differential drive systems. The only usage difference between using swerve and differential is the type of the sample used.

## Swerve Drive

Expand Down
4 changes: 3 additions & 1 deletion mkdocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,9 @@ nav:
- Estimating Moment of Inertia: usage/estimating-moi.md
- ChoreoLib:
- Installation: choreolib/installation.md
- Usage: choreolib/usage.md
- Basic Usage: choreolib/basic-usage.md
- Samples: choreolib/samples.md
- Auto Routines: choreolib/auto-routines.md
- Java API: api/choreolib/java/index.html
- C++ API: api/choreolib/cpp/index.html
- TrajoptLib:
Expand Down

0 comments on commit 219c200

Please sign in to comment.