COPP C ABI
C interface for COPP trajectory optimization
Loading...
Searching...
No Matches
reach_set2.c
Go to the documentation of this file.
1#include "example_common.h"
2
3int main(void)
4{
5 /*
6 * 1) Deterministic 3-axis Lissajous path q(s), s in [0, 1].
7 */
8 double s[EXAMPLE_NUM_POINTS];
9 struct CoppPath *path = NULL;
10 struct CoppRobot *robot = NULL;
11 struct CoppReachSet2Result reach_back = {{NULL, 0, 0}, {NULL, 0, 0}};
12 struct CoppReachSet2Result reach_bidir = {{NULL, 0, 0}, {NULL, 0, 0}};
13 int rc = 1;
14
15 example_fill_stations(s, EXAMPLE_NUM_POINTS);
16 if (example_create_analytic_path_2nd(&path))
17 {
18 goto cleanup;
19 }
20
21 /*
22 * 2) Build robot constraints (3-axis), then apply symmetric limits
23 * velocity/acceleration = [-1, 1].
24 */
25 if (example_create_robot_2nd(path, s, EXAMPLE_NUM_POINTS, &robot))
26 {
27 goto cleanup;
28 }
29
30 /*
31 * 3) Build TOPP2 problem and compute reachable sets. The backward-only
32 * pass constrains the terminal boundary; the bidirectional pass constrains
33 * both the start and terminal boundaries.
34 */
35 struct Topp2RaOptions options;
36 enum CoppStatus status = topp2_ra_default_options(&options);
37 if (example_expect_ok(status, "topp2_ra_default_options"))
38 {
39 goto cleanup;
40 }
41
42 struct Topp2Problem problem = {robot, 0, EXAMPLE_NUM_POINTS - 1, 0.0, 0.0};
43 status = copp_reach_set2_backward(problem, options, &reach_back);
44 if (example_expect_ok(status, "copp_reach_set2_backward"))
45 {
46 goto cleanup;
47 }
48
49 status = copp_reach_set2_bidirectional(problem, options, &reach_bidir);
50 if (example_expect_ok(status, "copp_reach_set2_bidirectional"))
51 {
52 goto cleanup;
53 }
54
55 /*
56 * 4) Print the tutorial summary.
57 */
58 const size_t k0 = 0;
59 const size_t km = EXAMPLE_NUM_POINTS / 2;
60 const size_t k1 = EXAMPLE_NUM_POINTS - 1;
61
62 printf("reach_set2 done.\n");
63 printf("dim = %d, N = %d\n", EXAMPLE_DIM, EXAMPLE_NUM_POINTS);
64 printf("backward-only: a_max.len() = %zu, a_min.len() = %zu\n",
65 reach_back.a_max.len,
66 reach_back.a_min.len);
67 printf("bidirectional: a_max.len() = %zu, a_min.len() = %zu\n",
68 reach_bidir.a_max.len,
69 reach_bidir.a_min.len);
70 printf("bidirectional bounds @k=0/mid/end: [%.6f, %.6f], [%.6f, %.6f], [%.6f, %.6f]\n",
71 reach_bidir.a_min.data[k0],
72 reach_bidir.a_max.data[k0],
73 reach_bidir.a_min.data[km],
74 reach_bidir.a_max.data[km],
75 reach_bidir.a_min.data[k1],
76 reach_bidir.a_max.data[k1]);
77 rc = 0;
78
79cleanup:
80 copp_reach_set2_result_free(reach_bidir);
83 copp_path_free(path);
84 return rc;
85}
@ EXAMPLE_NUM_POINTS
@ EXAMPLE_DIM
CoppStatus
C ABI status code returned by COPP FFI functions.
Definition core.h:34
struct CoppPath CoppPath
Opaque C handle for a library-owned Path.
Definition path.h:34
void copp_path_free(struct CoppPath *path)
Release a path handle created by this module.
struct CoppRobot CoppRobot
Opaque C handle for a library-owned robot and constraint buffer.
Definition robot.h:35
void copp_robot_free(struct CoppRobot *robot)
Release a robot handle created by copp_robot_create.
void copp_reach_set2_result_free(struct CoppReachSet2Result result)
Release a reachable-set result returned by COPP.
enum CoppStatus topp2_ra_default_options(struct Topp2RaOptions *out_options)
Write default TOPP2-RA options into out_options.
enum CoppStatus copp_reach_set2_bidirectional(struct Topp2Problem problem, struct Topp2RaOptions options, struct CoppReachSet2Result *out_result)
Compute bidirectional TOPP2 reachable intervals.
enum CoppStatus copp_reach_set2_backward(struct Topp2Problem problem, struct Topp2RaOptions options, struct CoppReachSet2Result *out_result)
Compute backward-only TOPP2 reachable intervals.
int main(void)
Definition reach_set2.c:3
Reachable intervals returned by TOPP2 reachable-set construction.
Definition topp2.h:97
struct CoppVecF64 a_min
Lower reachable bound for each station.
Definition topp2.h:105
struct CoppVecF64 a_max
Upper reachable bound for each station.
Definition topp2.h:101
size_t len
Number of initialized elements.
Definition core.h:836
double * data
Pointer to the first element, or null for an empty vector.
Definition core.h:832
Borrowed value descriptor for a TOPP2 problem solved from C.
const struct CoppRobot * robot
Robot handle that owns the station-indexed constraint storage.
Options for TOPP2-RA reachability analysis.
Definition topp2.h:31