A library for generating spline-based paths for robots.
The "squiggles" created by this path generation library allow for smooth, fast autonomous movements. Robots can follow the generated paths through the use of the wheel velocities calculated at each point along with an appropriate feedback controller.
The Squiggles source code contains no external dependencies. You can include
Squiggles in any existing project that uses C++17 standard by adding the
contents of the include
and src
directories to your project.
You can also add Squiggles to your project as a static library by downloading the latest release from Github.
For instructions on building the library in a development environment see CONTRIBUTING.
The above path can be created in three simple steps. First, define the
Constraints
with the robot's maximum velocity, acceleration, and jerk when
driving:
#include "squiggles.hpp"
const double MAX_VEL = 2.0; // in meters per second
const double MAX_ACCEL = 3.0; // in meters per second per second
const double MAX_JERK = 6.0; // in meters per second per second per second
auto constraints = squiggles::Constraints(MAX_VEL, MAX_ACCEL, MAX_JERK);
Then measure the width between the robot's wheels and create a SplineGenerator
with the constraints and the width measurement:
#include "squiggles.hpp"
const double MAX_VEL = 2.0; // in meters per second
const double MAX_ACCEL = 3.0; // in meters per second per second
const double MAX_JERK = 6.0; // in meters per second per second per second
const double ROBOT_WIDTH = 0.4; // in meters
auto constraints = squiggles::Constraints(MAX_VEL, MAX_ACCEL, MAX_JERK);
auto generator = squiggles::SplineGenerator(
constraints,
std::make_shared<squiggles::TankModel>(ROBOT_WIDTH, constraints));
And finally specify a starting point for the robot (probably 0, 0, 0
) and a
goal point to drive to:
#include "squiggles.hpp"
const double MAX_VEL = 2.0; // in meters per second
const double MAX_ACCEL = 3.0; // in meters per second per second
const double MAX_JERK = 6.0; // in meters per second per second per second
const double ROBOT_WIDTH = 0.4; // in meters
auto constraints = squiggles::Constraints(MAX_VEL, MAX_ACCEL, MAX_JERK);
auto generator = squiggles::SplineGenerator(
constraints,
std::make_shared<squiggles::TankModel>(ROBOT_WIDTH, constraints));
auto path = generator.generate({Pose(0, 0, 0), Pose(2, 2, 0)});
The robot's Constraints
provide the maximum allowable dynamics for the
generated paths. Careful measurement and configuration of these parameters ensures
that the path will not expect the robot to move more quickly than it actually
can. Resolving such discrepancies in the generated path and reality is an important
first step in ensuring that the robot performs reliably.
While these motion profiles help the robot's path-following abilities considerably they are far from a guarantee that the robot will exactly follow the generated path. It is recommended to pair the output of Squiggles with a feedback controller. A velocity PID controller is an easy start but a controller optimized for path following such as the Pure Pursuit Controller or Ramsete Controller is the best choice.
Currently only "tank drive" or "differential drive" robots are supported, as shown below.
Use of this source code is governed by an MIT-style license that can be found in the LICENSE file or at opensource.org.
This code was made possible by influence from the following sources: