Giter Club home page Giter Club logo

trajoptlib's Introduction

TrajoptLib has moved into the Choreo repo.

TrajoptLib

Build C++ Documentation Discord

This library is used to generate time-optimal trajectories for FRC robots.

Trajectory optimization works by mathematically formulating the problem of travelling along a given path with the minimum possible time. The physical constraints of motor power capacity are applied along with waypoint constraints, which force the robot to begin and end a segment of the trajectory with a certain state. A mathematical solver must vary the position of the robot at each discrete timestamp to minimize total time.

Features

  • Currently only supports swerve drives with arbitray module configurations
  • Position and velocity constraints at each waypoint
  • Circle and polygon obstacle avoidance
  • Custom physical constraints of robot
  • Custom bumper shape

Build

Dependencies

  • C++23 compiler
    • On Windows, install Visual Studio Community 2022 and select the C++ programming language during installation
    • On Linux, install GCC 14 or greater via sudo apt install g++
    • On macOS 14 or greater, install the Xcode command-line build tools via xcode-select --install. Xcode 15.3 or greater is required.
  • CMake 3.21 or greater
    • On Windows, install from the link above
    • On Linux, install via sudo apt install cmake
    • On macOS, install via brew install cmake
  • Rust compiler
  • Sleipnir (optional backend)
  • Catch2 (tests only)

Library dependencies which aren't installed locally will be automatically downloaded and built by CMake.

C++ library

On Windows, open a Developer PowerShell. On Linux or macOS, open a Bash shell.

# Clone the repository
git clone [email protected]:SleipnirGroup/TrajoptLib
cd TrajoptLib

# Configure
cmake -B build -S .

# Build
cmake --build build

# Test
ctest --test-dir build --output-on-failure

# Install
cmake --install build --prefix pkgdir

The following build types can be specified via -DCMAKE_BUILD_TYPE during CMake configure:

  • Debug
    • Optimizations off
    • Debug symbols on
  • Release
    • Optimizations on
    • Debug symbols off
  • RelWithDebInfo (default)
    • Release build type, but with debug info
  • MinSizeRel
    • Minimum size release build

Rust library

On Windows, open a Developer PowerShell. On Linux or macOS, open a Bash shell.

# Clone the repository
git clone [email protected]:SleipnirGroup/TrajoptLib
cd TrajoptLib

cargo build

trajoptlib's People

Contributors

jlbabilino avatar calcmogul avatar shueja avatar bruingineer avatar lewis-seiden avatar spacey-sooty avatar theverysharpflat avatar bbscholar avatar cfinn68916 avatar

Stargazers

Matthew Milunic avatar  avatar  avatar Guilherme Samuel avatar Du avatar  avatar Jerry avatar  avatar  avatar Rocky_ avatar  avatar  avatar Adan Silva avatar Sriman Achanta avatar  avatar  avatar Joshua Nichols avatar

Watchers

 avatar  avatar Joshua Nichols avatar

trajoptlib's Issues

Remove path "splitting"

Sometimes, a trjaopt path can be split into a sequence of paths solvable individually, if the state at a certain waypoint is known ahead of time. This could improve performance if the solve time grows faster than than the dimensionality of the problem.

The library used to do this kind of splitting, but it has since been removed as the new, more flexible constraint system has made it too difficult to determine if state is known ahead of time.

All remnants of this feature should be removed. Start by removing these functions.

Add a CLI interface

A trajopt CLI might allow a user to pass in a path file, then have a trajectory file generated. This could then be used as a build step in an FRC team's code that guarantees all trajectories are up-to-date.

Iteration callback interface for C++

TrajoptLib’s C++ API should allow the user to pass a callback function that gives access to the current state of the trajectory every iteration of the solver.

Here is a concept of what the interface could look like:

SwervePathBuilder path;
// add constraints, waypoints, etc.
SwerveTrajectoryGenerator gen = path.GetGenerator();
gen.SetCallback([](const SwerveSolution& currentState) {
  fmt::print(“Current x: {}”, currentState.x[0]);
});
SwerveSolution finalSol = gen.GenerateSync();

`trajoptlib` Cargo package cannot be vendored or published to registries

The Cargo package's build script currently refers to the rest of trajoptlib at .. relative to the package root. This does work for unvendored git dependencies, but it breaks if you vendor the dependency (with cargo vendor) or try to publish trajoptlib to a Cargo registry (e.g. crates.io).

I'm not entirely sure what the fix for this is yet, besides the obvious, inelegant solution of moving the Cargo manifest to the repository root. I think it may be possible to use relative symlinks and have Cargo resolve the symlink. I'll look into it and submit a PR unless there's a particular way you'd like to fix this.

Add CMake examples

There should be a CMake example for building and using TrajoptLib using Cmake

Add "keep in" zones

A "keep in" zone is defined as a polygon on the field whose convex hull equals itself. Inequality constraints can be used to keep the robot's bumpers within the zone.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.