amino  1.0-beta2
Lightweight Robot Utility Library
traj_internal.hpp
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_INTERNAL_HPP
39 #define AMINO_CT_TRAJ_INTERNAL_HPP
40 
45 #ifdef __cplusplus
46 extern "C" {
47 #endif
48 
49 
50 typedef int (*aa_ct_seg_eval_fun)(struct aa_ct_seg *seg,
51  struct aa_ct_state *state, double t);
52 
56 struct aa_ct_seg {
57  int type;
58  int (*eval)(struct aa_ct_seg *seg,
59  struct aa_ct_state *state, double t);
60  struct aa_ct_seg *prev, *next;
61  void *cx;
62 };
63 
64 
72 void aa_ct_seg_list_add(struct aa_ct_seg_list *list, struct aa_ct_seg *seg);
73 
74 
75 void aa_ct_seg_list_add_cx( struct aa_ct_seg_list *list,
76  aa_ct_seg_eval_fun eval,
77  void *cx );
78 
79 
80 #ifdef __cplusplus
81 }
82 #endif
83 
84 #ifdef __cplusplus
85 
86 struct aa_ct_pt_list {
87  struct aa_mem_region reg;
89  amino::RegionList<struct aa_ct_pt *>::type list;
90 
91  aa_ct_pt_list(struct aa_mem_region *_reg) : alloc(_reg), list(alloc) {
92  aa_mem_region_init(&reg, 512);
93  };
94 
95  ~aa_ct_pt_list(void) {
96  list.~list();
98  }
99 };
100 
101 struct aa_ct_seg_list {
102  struct aa_mem_region reg;
104  amino::RegionList<struct aa_ct_seg *>::type list;
105  amino::RegionList<struct aa_ct_seg *>::iterator it;
106  int it_on;
107 
108  size_t n_q;
109  double duration;
110 
111  aa_ct_seg_list(struct aa_mem_region *_reg) :
112  alloc(_reg),
113  list(alloc)
114  {
115  aa_mem_region_init(&reg, 512);
116  it_on = 0;
117  }
118 
119  ~aa_ct_seg_list(void) {
120  list.~list();
121  aa_mem_region_destroy(&reg);
122  }
123 };
124 
125 #endif
126 
127 #endif
An STL allocator that allocates out of a memory region.
Definition: mem.hpp:111
AA_API void aa_mem_region_init(aa_mem_region_t *region, size_t size)
Initialize memory region with an initial chunk of size bytes.
AA_API void aa_mem_region_destroy(aa_mem_region_t *region)
Destroy memory region freeing all chunks.
Trajectory segment.
void * cx
Segment context.
int(* eval)(struct aa_ct_seg *seg, struct aa_ct_state *state, double t)
Evaluate function.
struct aa_ct_seg * next
Links to next and previous segments.
int type
Type label for disambiguation.
State description of a robot.
Definition: state.h:52
Data Structure for Region-Based memory allocation.
Definition: mem.h:199
void aa_ct_seg_list_add(struct aa_ct_seg_list *list, struct aa_ct_seg *seg)
Add a reference to a segment to a segment list.