COPP C++ API
C++ interface for COPP trajectory optimization
Loading...
Searching...
No Matches
path_from_waypoints.cpp
Go to the documentation of this file.
1
// Tutorial example: construct a C++ `copp::Path` from waypoint-list notation.
2
//
3
// This is the shortest path-construction route for users who already have a
4
// small list of waypoints. Each inner initializer list is one waypoint vector;
5
// the facade converts it to the `(dim x n_points)` matrix expected by Rust.
6
7
#include <iostream>
8
#include <vector>
9
10
#include <
copp/copp.hpp
>
11
12
int
main
()
13
{
14
// Step 1: Build a two-dimensional quintic spline over the default range
15
// `[0, 1]`. The three columns are q(0), q(0.5), and q(1).
16
auto
path =
copp::Path::from_waypoints
({
17
{0.0, 0.0},
18
{0.5, 0.25},
19
{1.0, 1.0},
20
});
21
22
// Step 2: Evaluate the path at the waypoint stations. `out.q`, `out.dq`,
23
// and `out.ddq` are column-major matrices with shape `(dim, samples.size())`.
24
std::vector<double> s{0.0, 0.5, 1.0};
25
auto
out = path.
evaluate_up_to_2nd
(s);
26
27
// Step 3: Read matrix entries by `(row, column)`: row is the joint/path
28
// dimension, column is the query sample index.
29
std::cout <<
"dim = "
<< path.dim() <<
"\n"
;
30
std::cout <<
"q(0, 1) = "
<< out.
q
(0, 1) <<
"\n"
;
31
std::cout <<
"dq(0, 1) = "
<< out.dq.value()(0, 1) <<
"\n"
;
32
std::cout <<
"ddq(0, 1) = "
<< out.ddq.value()(0, 1) <<
"\n"
;
33
}
copp::Path::from_waypoints
static Path from_waypoints(MatrixView waypoints, SplineConfig config={})
Build a spline path from waypoint positions.
copp::Path::evaluate_up_to_2nd
PathDerivatives evaluate_up_to_2nd(Span< const double > s) const
Evaluate position, first derivative, and second derivative.
copp.hpp
main
int main()
Definition
path_from_waypoints.cpp:12
copp::PathDerivatives::q
Matrix q
Definition
path.hpp:341
bindings
cpp
examples
path_from_waypoints.cpp
Generated by
1.17.0