amino  1.0-beta2
Lightweight Robot Utility Library
scene_collision.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) 2015, Rice University
5  * All rights reserved.
6  *
7  * Author(s): Neil T. Dantam <ntd@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_RX_SCENE_COLLISION_H
39 #define AMINO_RX_SCENE_COLLISION_H
40 
41 #include "scene_fk.h"
42 
51 AA_API void
53 
59 struct aa_rx_cl_set;
60 
64 AA_API struct aa_rx_cl_set*
65 aa_rx_cl_set_create( const struct aa_rx_sg *sg );
66 
70 AA_API void
71 aa_rx_cl_set_destroy(struct aa_rx_cl_set *cl_set);
72 
76 AA_API void
77 aa_rx_cl_set_set( struct aa_rx_cl_set *cl_set,
80  int is_colliding );
81 
87 AA_API void
88 aa_rx_cl_set_fill( struct aa_rx_cl_set *dst,
89  const struct aa_rx_cl_set *src );
90 
94 AA_API int
95 aa_rx_cl_set_get( const struct aa_rx_cl_set *cl_set,
97  aa_rx_frame_id j );
98 
104 AA_API void
105 aa_rx_cl_set_merge(struct aa_rx_cl_set* into, const struct aa_rx_cl_set* from);
106 
107 
111 AA_API void
112 aa_rx_cl_set_clear(struct aa_rx_cl_set* cl_set );
113 
117 struct aa_rx_cl;
118 
122 AA_API void
123 aa_rx_sg_cl_init( struct aa_rx_sg *scene_graph );
124 
128 AA_API struct aa_rx_cl *
129 aa_rx_cl_create( const struct aa_rx_sg *scene_graph );
130 
134 AA_API void
135 aa_rx_cl_destroy( struct aa_rx_cl *cl );
136 
140 AA_API void
141 aa_rx_cl_allow( struct aa_rx_cl *cl,
142  aa_rx_frame_id i,
143  aa_rx_frame_id j,
144  int allowed );
145 
149 AA_API void
150 aa_rx_cl_allow_set( struct aa_rx_cl *cl,
151  const struct aa_rx_cl_set *set );
152 
156 AA_API void
157 aa_rx_cl_allow_name( struct aa_rx_cl *cl,
158  const char *frame0,
159  const char *frame1,
160  int allowed );
161 
170 AA_API int
171 aa_rx_cl_check( struct aa_rx_cl *cl,
172  size_t n_tf,
173  const double *TF, size_t ldTF,
174  struct aa_rx_cl_set *cl_set );
175 
184 AA_API int
185 aa_rx_cl_check_fk( struct aa_rx_cl *cl,
186  struct aa_rx_fk *fk,
187  struct aa_rx_cl_set *cl_set );
188 
192 AA_API void
193 aa_rx_sg_allow_config( struct aa_rx_sg* scene_graph, size_t n_q, const double* q);
194 
198 AA_API void
199 aa_rx_sg_cl_set_copy(const struct aa_rx_sg* sg, struct aa_rx_cl_set * cl_set);
200 
204 AA_API void
205 aa_rx_sg_get_collision(const struct aa_rx_sg* scene_graph, size_t n_q, const double* q, struct aa_rx_cl_set* cl_set);
206 
207 
208 /*--------------------*/
209 /* Collision Distance */
210 /*--------------------*/
211 
212 
217 struct aa_rx_cl_dist;
218 
220 AA_API struct aa_rx_cl_dist *
221 aa_rx_cl_dist_create( const struct aa_rx_cl * );
222 
224 AA_API void
225 aa_rx_cl_dist_destroy( struct aa_rx_cl_dist* dist );
226 
228 AA_API int
229 aa_rx_cl_dist_check( struct aa_rx_cl_dist *cl_dist,
230  const struct aa_rx_fk *fk );
231 
233 AA_API double
234 aa_rx_cl_dist_get_min_dist(const struct aa_rx_cl_dist *cl_dist,
235  aa_rx_frame_id id0, aa_rx_frame_id *id1, double* points);
236 
238 AA_API double
239 aa_rx_cl_dist_get_dist( const struct aa_rx_cl_dist *cl_dist,
240  aa_rx_frame_id id0, aa_rx_frame_id id1 );
241 
243 AA_API double
244 aa_rx_cl_dist_get_points( const struct aa_rx_cl_dist *cl_dist,
246  double point0[3], double point1[3] );
247 
248 
249 #endif /*AMINO_RX_SCENE_COLLISION_H*/
#define AA_API
calling and name mangling convention for functions
Definition: amino.h:95
AA_API void aa_rx_sg_cl_init(struct aa_rx_sg *scene_graph)
Initialize the collision structures within scene_graph.
AA_API void aa_rx_sg_get_collision(const struct aa_rx_sg *scene_graph, size_t n_q, const double *q, struct aa_rx_cl_set *cl_set)
Check the collisions at q.
AA_API void aa_rx_cl_set_merge(struct aa_rx_cl_set *into, const struct aa_rx_cl_set *from)
Fill set ‘into’ with all elements in set ‘from’.
AA_API struct aa_rx_cl * aa_rx_cl_create(const struct aa_rx_sg *scene_graph)
Create a new collision detection context for scene_graph.
AA_API void aa_rx_cl_set_set(struct aa_rx_cl_set *cl_set, aa_rx_frame_id i, aa_rx_frame_id j, int is_colliding)
Set the value of collision between frames i and j.
AA_API void aa_rx_sg_cl_set_copy(const struct aa_rx_sg *sg, struct aa_rx_cl_set *cl_set)
Retrieve the set of allowed collisions.
AA_API void aa_rx_cl_allow_name(struct aa_rx_cl *cl, const char *frame0, const char *frame1, int allowed)
Allow (ignore) collisions between frames0 and frame1 if allowed is true.
AA_API struct aa_rx_cl_dist * aa_rx_cl_dist_create(const struct aa_rx_cl *)
Create a collision distance context.
AA_API int aa_rx_cl_check_fk(struct aa_rx_cl *cl, struct aa_rx_fk *fk, struct aa_rx_cl_set *cl_set)
Detect collisions.
AA_API int aa_rx_cl_set_get(const struct aa_rx_cl_set *cl_set, aa_rx_frame_id i, aa_rx_frame_id j)
Return the value of collision between frames i and j.
AA_API struct aa_rx_cl_set * aa_rx_cl_set_create(const struct aa_rx_sg *sg)
Create a collision set.
AA_API int aa_rx_cl_dist_check(struct aa_rx_cl_dist *cl_dist, const struct aa_rx_fk *fk)
Run a collision distance check.
AA_API void aa_rx_cl_set_destroy(struct aa_rx_cl_set *cl_set)
Destroy a collision set.
AA_API void aa_rx_cl_allow(struct aa_rx_cl *cl, aa_rx_frame_id i, aa_rx_frame_id j, int allowed)
Allow (ignore) collisions between frames i and j if allowed is true.
AA_API double aa_rx_cl_dist_get_points(const struct aa_rx_cl_dist *cl_dist, aa_rx_frame_id id0, aa_rx_frame_id id1, double point0[3], double point1[3])
Get the closest points between specified frames.
AA_API void aa_rx_cl_set_clear(struct aa_rx_cl_set *cl_set)
Clear all collisions stored in the set.
AA_API void aa_rx_cl_dist_destroy(struct aa_rx_cl_dist *dist)
Destroy a collision distance context.
AA_API void aa_rx_cl_set_fill(struct aa_rx_cl_set *dst, const struct aa_rx_cl_set *src)
Fill dst with all true entries in src.
AA_API void aa_rx_sg_allow_config(struct aa_rx_sg *scene_graph, size_t n_q, const double *q)
Allow all collisions at configuration q.
AA_API void aa_rx_cl_init()
Initialize collision handling.
AA_API void aa_rx_cl_allow_set(struct aa_rx_cl *cl, const struct aa_rx_cl_set *set)
Allow collisions between all frame pairs in set.
AA_API void aa_rx_cl_destroy(struct aa_rx_cl *cl)
Destroy a collision detection context.
AA_API double aa_rx_cl_dist_get_min_dist(const struct aa_rx_cl_dist *cl_dist, aa_rx_frame_id id0, aa_rx_frame_id *id1, double *points)
Get the minimum separation distance.
AA_API int aa_rx_cl_check(struct aa_rx_cl *cl, size_t n_tf, const double *TF, size_t ldTF, struct aa_rx_cl_set *cl_set)
Detect collisions.
AA_API double aa_rx_cl_dist_get_dist(const struct aa_rx_cl_dist *cl_dist, aa_rx_frame_id id0, aa_rx_frame_id id1)
Get the separation distance between specified frames.
Forward kinematics.
signed long aa_rx_frame_id
Type for frame indices.
Definition: scenegraph.h:54
Opaque type for a scene_graph.