amino  1.0-beta2
Lightweight Robot Utility Library
traj.h
Go to the documentation of this file.
1 /* -*- mode: C; c-basic-offset: 4; -*- */
2 /* ex: set shiftwidth=4 tabstop=4 expandtab: */
3 /*
4  * Copyright (c) 2016 Rice University
5  * All rights reserved.
6  *
7  * Author(s): Zachary K. Kingston <zak@rice.edu>
8  *
9  * Redistribution and use in source and binary forms, with or
10  * without modification, are permitted provided that the following
11  * conditions are met:
12  * * Redistributions of source code must retain the above copyright
13  * notice, this list of conditions and the following disclaimer.
14  * * Redistributions in binary form must reproduce the above
15  * copyright notice, this list of conditions and the following
16  * disclaimer in the documentation and/or other materials provided
17  * with the distribution.
18  * * Neither the name of copyright holder the names of its
19  * contributors may be used to endorse or promote products derived
20  * from this software without specific prior written permission.
21  *
22  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
23  * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
24  * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
25  * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
26  * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
27  * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
28  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
29  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
30  * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
31  * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
32  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
33  * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
34  * POSSIBILITY OF SUCH DAMAGE.
35  *
36  */
37 
38 #ifndef AMINO_CT_TRAJ_H
39 #define AMINO_CT_TRAJ_H
40 
41 #include "state.h"
42 
47 #ifdef __cplusplus
48 extern "C" {
49 #endif
50 
51 #define AA_CT_SEG_IN 1
52 #define AA_CT_SEG_OUT 0
53 
54 #define AA_CT_LIN_SEG 1
55 #define AA_CT_PB_SEG 2
56 #define AA_CT_ACCL_SEG 3
57 
61 struct aa_ct_pt {
62  struct aa_ct_state state;
63  struct aa_ct_pt *prev, *next;
64 };
65 
69 struct aa_ct_pt_list;
70 
74 struct aa_ct_seg_list;
75 
76 
84 struct aa_ct_pt_list *aa_ct_pt_list_create(struct aa_mem_region *reg);
85 
93 void aa_ct_pt_list_add(struct aa_ct_pt_list *list, struct aa_ct_state *state);
94 
102 void aa_ct_pt_list_add_front(struct aa_ct_pt_list *list, struct aa_ct_state *state);
103 
107 void aa_ct_pt_list_add_qutr(struct aa_ct_pt_list *list, const double E[7]);
108 
112 void aa_ct_pt_list_add_q(struct aa_ct_pt_list *list, size_t n_q, const double *q);
113 
119 void aa_ct_pt_list_destroy(struct aa_ct_pt_list *list);
120 
124 const struct aa_ct_state *
125 aa_ct_pt_list_start_state(const struct aa_ct_pt_list *list);
126 
130 const struct aa_ct_state *
131 aa_ct_pt_list_final_state(const struct aa_ct_pt_list *list);
132 
136 size_t aa_ct_pt_list_size(const struct aa_ct_pt_list *list);
137 
138 
139 
146 void aa_ct_pt_list_dump(FILE *stream, struct aa_ct_pt_list *list);
147 
158 int aa_ct_seg_list_eval(struct aa_ct_seg_list *list, struct aa_ct_state *state,
159  double t);
160 
164 int aa_ct_seg_list_eval_q(struct aa_ct_seg_list *list, double t, size_t n, double *q);
165 
169 int aa_ct_seg_list_eval_dq(struct aa_ct_seg_list *list, double t, size_t n, double *q, double *dq);
170 
178 void aa_ct_seg_list_plot(struct aa_ct_seg_list *list, size_t n_q, double dt);
179 
185 void aa_ct_seg_list_destroy(struct aa_ct_seg_list *list);
186 
190 size_t aa_ct_seg_list_n_q(const struct aa_ct_seg_list *list);
191 
195 double aa_ct_seg_list_duration(const struct aa_ct_seg_list *list);
196 
206 struct aa_ct_seg_list *aa_ct_tjq_pb_generate(struct aa_mem_region *reg,
207  struct aa_ct_pt_list *list,
208  struct aa_ct_limit *limits);
209 
219 struct aa_ct_seg_list *aa_ct_tjq_trap_generate(struct aa_mem_region *reg,
220  struct aa_ct_pt_list *list,
221  struct aa_ct_limit *limits);
222 
223 
233 struct aa_ct_seg_list *aa_ct_tjq_lin_generate(struct aa_mem_region *reg,
234  struct aa_ct_pt_list *list,
235  struct aa_ct_limit *limits);
236 
246 struct aa_ct_seg_list *aa_ct_tjX_pb_generate(struct aa_mem_region *reg,
247  struct aa_ct_pt_list *list,
248  struct aa_ct_limit *limits);
249 
250 
251 
263 int
264 aa_ct_seg_list_check( struct aa_ct_seg_list * segs, double dt,
265  int (*function)(void *cx, double t, const struct aa_ct_state *state ),
266  void *cx );
267 
280 int aa_ct_seg_list_check_c0( struct aa_ct_seg_list * segs, double dt,
281  double tol, double eps );
282 
291 struct aa_ct_seg_list *aa_ct_tjx_slerp_generate(struct aa_mem_region *reg,
292  struct aa_ct_pt_list *list );
293 
294 
295 #ifdef __cplusplus
296 }
297 #endif
298 
299 #endif
Limits on robot state.
Definition: state.h:75
Waypoint.
Definition: traj.h:61
struct aa_ct_pt * next
Links to next and previous points.
Definition: traj.h:63
struct aa_ct_state state
Description of state at waypoint.
Definition: traj.h:62
State description of a robot.
Definition: state.h:52
double * dq
Velocity.
Definition: state.h:58
double * q
Position.
Definition: state.h:57
size_t n_q
Number of configuration variables.
Definition: state.h:53
Data Structure for Region-Based memory allocation.
Definition: mem.h:199
int aa_ct_seg_list_eval_dq(struct aa_ct_seg_list *list, double t, size_t n, double *q, double *dq)
Evaluate trajectory and fill configuration and velocity arrays.
struct aa_ct_seg_list * aa_ct_tjq_trap_generate(struct aa_mem_region *reg, struct aa_ct_pt_list *list, struct aa_ct_limit *limits)
Generate a trapezoidal blend trajectory from a point list.
struct aa_ct_seg_list * aa_ct_tjx_slerp_generate(struct aa_mem_region *reg, struct aa_ct_pt_list *list)
Generate a SLERP trajectory from a point list.
void aa_ct_pt_list_dump(FILE *stream, struct aa_ct_pt_list *list)
Print out a list of points to a file.
void aa_ct_pt_list_add_front(struct aa_ct_pt_list *list, struct aa_ct_state *state)
Add a reference to a waypoint to the front of a point list.
void aa_ct_pt_list_add_qutr(struct aa_ct_pt_list *list, const double E[7])
Add a quaternion-translation pose to the point list.
double aa_ct_seg_list_duration(const struct aa_ct_seg_list *list)
Return duration (time) of segment list.
int aa_ct_seg_list_eval_q(struct aa_ct_seg_list *list, double t, size_t n, double *q)
Evaluate trajectory and fill configuration array.
struct aa_ct_seg_list * aa_ct_tjq_pb_generate(struct aa_mem_region *reg, struct aa_ct_pt_list *list, struct aa_ct_limit *limits)
Generate a parabolic blend trajectory from a point list.
void aa_ct_pt_list_add_q(struct aa_ct_pt_list *list, size_t n_q, const double *q)
Add a quaternion-translation position the point list.
const struct aa_ct_state * aa_ct_pt_list_final_state(const struct aa_ct_pt_list *list)
Return the final state of the point list.
void aa_ct_seg_list_destroy(struct aa_ct_seg_list *list)
Destroys an allocated segment list.
int aa_ct_seg_list_check(struct aa_ct_seg_list *segs, double dt, int(*function)(void *cx, double t, const struct aa_ct_state *state), void *cx)
Check the trajectory by evaluting function at points along the trajectory.
struct aa_ct_seg_list * aa_ct_tjX_pb_generate(struct aa_mem_region *reg, struct aa_ct_pt_list *list, struct aa_ct_limit *limits)
Generate a parabolic blend trajectory in the workspace from a point list.
int aa_ct_seg_list_check_c0(struct aa_ct_seg_list *segs, double dt, double tol, double eps)
Check C0 (position) continuity of the trajectory.
size_t aa_ct_pt_list_size(const struct aa_ct_pt_list *list)
Return the number of points in the point list.
int aa_ct_seg_list_eval(struct aa_ct_seg_list *list, struct aa_ct_state *state, double t)
Evaluates a segment list at a given time.
struct aa_ct_seg_list * aa_ct_tjq_lin_generate(struct aa_mem_region *reg, struct aa_ct_pt_list *list, struct aa_ct_limit *limits)
Generate a linear trajectory from a point list.
const struct aa_ct_state * aa_ct_pt_list_start_state(const struct aa_ct_pt_list *list)
Return the initial state of the point list.
void aa_ct_pt_list_add(struct aa_ct_pt_list *list, struct aa_ct_state *state)
Add a reference to a waypoint to the back of a point list.
size_t aa_ct_seg_list_n_q(const struct aa_ct_seg_list *list)
Return segment list configuration count.
void aa_ct_seg_list_plot(struct aa_ct_seg_list *list, size_t n_q, double dt)
Plots a segment list with a given resolution.
void aa_ct_pt_list_destroy(struct aa_ct_pt_list *list)
Destroys an allocated point list.
struct aa_ct_pt_list * aa_ct_pt_list_create(struct aa_mem_region *reg)
Initialize and construct a point list from a memory region.