amino
Lightweight Robot Utility Library
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
scenegraph.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_SCENEGRAPH_H
39 #define AMINO_SCENEGRAPH_H
40 
49 typedef signed long aa_rx_frame_id;
50 
54 typedef signed long aa_rx_config_id;
55 
59 #define AA_RX_FRAME_ROOT ((aa_rx_frame_id)-1)
60 
61 #define AA_RX_FRAME_NONE ((aa_rx_frame_id)-2)
62 
66 #define AA_RX_CONFIG_NONE ((aa_rx_config_id)-1)
67 #define AA_RX_CONFIG_MULTI ((aa_rx_config_id)-2)
68 
76 };
77 
81 AA_API struct aa_rx_sg *
83 
87 AA_API void aa_rx_sg_destroy(struct aa_rx_sg *scene_graph);
88 
95 AA_API int aa_rx_sg_init ( struct aa_rx_sg *scene_graph );
96 
105  const struct aa_rx_sg *scene_graph, aa_rx_frame_id frame_id );
106 
113 AA_API const char *
115  const struct aa_rx_sg *scene_graph, aa_rx_frame_id frame_id );
116 
123 AA_API const char *
125  const struct aa_rx_sg *scene_graph, aa_rx_config_id config_id );
126 
135  const struct aa_rx_sg *scene_graph, aa_rx_frame_id frame_id );
136 
137 
141 AA_API size_t
143  const struct aa_rx_sg *scene_graph );
144 
148 AA_API size_t
150  const struct aa_rx_sg *scene_graph );
151 
160  const struct aa_rx_sg *scene_graph, aa_rx_frame_id frame);
161 
166 AA_API size_t
168  const struct aa_rx_sg *scene_graph, size_t n_names,
169  const char **names );
170 
178  const struct aa_rx_sg *scene_graph, const char *config_name);
179 
186 AA_API void
188  const struct aa_rx_sg *scene_graph, size_t n,
189  const char **config_name, aa_rx_config_id *ids );
190 
191 
192 AA_API void
193 aa_rx_sg_config_get(
194  const struct aa_rx_sg *scene_graph, size_t n_all, size_t n_subset,
195  const aa_rx_config_id *ids,
196  const double *config_all,
197  double *config_subset );
198 
199 AA_API void
200 aa_rx_sg_config_set(
201  const struct aa_rx_sg *scene_graph, size_t n_all, size_t n_subset,
202  const aa_rx_config_id *ids, const double *config_subset,
203  double *config_all
204  );
205 
213  const struct aa_rx_sg *scene_graph, const char *frame_name);
214 
215 
216 /* /\** */
217 /* * Return the index of a configuration variable for the given frame. */
218 /* *\/ */
219 /* AA_API aa_rx_config_id aa_rx_sg_frame_config_id( */
220 /* struct aa_rx_sg *scene_graph, aa_rx_frame_id frame_id); */
221 
238 ( struct aa_rx_sg *scene_graph,
239  const char *parent, const char *name,
240  const double q[4], const double v[3] );
241 
258 ( struct aa_rx_sg *scene_graph,
259  const char *parent, const char *name,
260  const double q[4], const double v[3],
261  const char *config_name,
262  const double axis[3], double offset );
263 
280 ( struct aa_rx_sg *scene_graph,
281  const char *parent, const char *name,
282  const double q[4], const double v[3],
283  const char *config_name,
284  const double axis[3], double offset );
285 
290 ( struct aa_rx_sg *scene_graph,
291  const char *name );
292 
296 AA_API void
297 aa_rx_sg_set_limit_pos( struct aa_rx_sg *scenegraph,
298  const char *config_name,
299  double min, double max );
300 
304 AA_API void
305 aa_rx_sg_set_limit_vel( struct aa_rx_sg *scenegraph,
306  const char *config_name,
307  double min, double max );
308 
312 AA_API void
313 aa_rx_sg_set_limit_acc( struct aa_rx_sg *scenegraph,
314  const char *config_name,
315  double min, double max );
316 
320 AA_API void
321 aa_rx_sg_set_limit_eff( struct aa_rx_sg *scenegraph,
322  const char *config_name,
323  double min, double max );
330 AA_API int
331 aa_rx_sg_get_limit_pos( const struct aa_rx_sg *scenegraph,
332  aa_rx_config_id config_id,
333  double *min, double *max );
334 
341 AA_API int
342 aa_rx_sg_get_limit_vel( const struct aa_rx_sg *scenegraph,
343  aa_rx_config_id config_id,
344  double *min, double *max );
345 
352 AA_API int
353 aa_rx_sg_get_limit_acc( const struct aa_rx_sg *scenegraph,
354  aa_rx_config_id config_id,
355  double *min, double *max );
356 
363 AA_API int
364 aa_rx_sg_get_limit_eff( const struct aa_rx_sg *scenegraph,
365  aa_rx_config_id config_id,
366  double *min, double *max );
367 
368 
374 AA_API const double *aa_rx_sg_frame_axis
375 ( const struct aa_rx_sg *scene_graph, aa_rx_frame_id frame );
376 
396 AA_API void aa_rx_sg_tf
397 ( const struct aa_rx_sg *scene_graph,
398  size_t n_q, const double *q,
399  size_t n_tf,
400  double *TF_rel, size_t ld_rel,
401  double *TF_abs, size_t ld_abs );
402 
403 AA_API void aa_rx_sg_tf_update
404 ( const struct aa_rx_sg *scene_graph,
405  size_t n_q,
406  const double *q0,
407  const double *q,
408  size_t n_tf,
409  const double *TF_rel0, size_t ld_rel0,
410  const double *TF_abs0, size_t ld_abs0,
411  double *TF_rel, size_t ld_rel,
412  double *TF_abs, size_t ld_abs );
413 
414 
415 
427  const struct aa_rx_sg *scene_graph,
428  void (*function)(void *context, aa_rx_frame_id frame_id, struct aa_rx_geom *geom),
429  void *context );
430 
442 AA_API void aa_rx_sg_rel_tf (
443  const struct aa_rx_sg *scene_graph,
444  const aa_rx_frame_id frame_from,
445  const aa_rx_frame_id frame_to,
446  const double * tf_abs,
447  size_t ld_abs,
448  double * from_tf_to);
449 
450 AA_API void aa_rx_sg_reparent (
451  const struct aa_rx_sg *scene_graph,
452  const aa_rx_frame_id frame,
453  const aa_rx_frame_id new_parent,
454  const double * q);
455 
456 AA_API struct aa_rx_sg * aa_rx_sg_copy( const struct aa_rx_sg * orig);
457 
458 AA_API void aa_rx_sg_allow_collision( struct aa_rx_sg *scene_graph, const aa_rx_frame_id id0, const aa_rx_frame_id id1, const int allowed );
459 
460 AA_API void aa_rx_sg_allow_collision_name( struct aa_rx_sg *scene_graph, const char* id0, const char* id1, const int allowed );
461 
462 #endif /*AMINO_SCENEGRAPH_H*/
AA_API int aa_rx_sg_get_limit_vel(const struct aa_rx_sg *scenegraph, aa_rx_config_id config_id, double *min, double *max)
Get velocity limit values.
AA_API void aa_rx_sg_config_indices(const struct aa_rx_sg *scene_graph, size_t n, const char **config_name, aa_rx_config_id *ids)
Return the indices of a configuration variable in the scene graph.
AA_API const double * aa_rx_sg_frame_axis(const struct aa_rx_sg *scene_graph, aa_rx_frame_id frame)
Return pointer to frame axis.
A rotating transform.
Definition: scenegraph.h:74
AA_API const char * aa_rx_sg_config_name(const struct aa_rx_sg *scene_graph, aa_rx_config_id config_id)
Return the config of the given frame.
AA_API void aa_rx_sg_set_limit_eff(struct aa_rx_sg *scenegraph, const char *config_name, double min, double max)
Set effort limit values.
AA_API aa_rx_config_id aa_rx_sg_config_id(const struct aa_rx_sg *scene_graph, const char *config_name)
Return the index of a configuration variable in the scene graph.
AA_API int aa_rx_sg_init(struct aa_rx_sg *scene_graph)
Setup the scenegraph internal indices.
AA_API const char * aa_rx_sg_frame_name(const struct aa_rx_sg *scene_graph, aa_rx_frame_id frame_id)
Return the name of the given frame.
Container for scene geometry.
Definition: rxtype.h:56
signed long aa_rx_frame_id
Type for frame indices.
Definition: scenegraph.h:49
A fixed transform.
Definition: scenegraph.h:73
AA_API void aa_rx_sg_rm_frame(struct aa_rx_sg *scene_graph, const char *name)
Remove a frame.
AA_API aa_rx_frame_id aa_rx_sg_frame_id(const struct aa_rx_sg *scene_graph, const char *frame_name)
Return the index of a frame in the scene graph.
AA_API void aa_rx_sg_destroy(struct aa_rx_sg *scene_graph)
Destroy a scene graph.
AA_API enum aa_rx_frame_type aa_rx_sg_frame_type(const struct aa_rx_sg *scene_graph, aa_rx_frame_id frame_id)
Return the type of the given frame.
AA_API void aa_rx_sg_add_frame_fixed(struct aa_rx_sg *scene_graph, const char *parent, const char *name, const double q[4], const double v[3])
Add a fixed-transform frame to the scene graph.
A prismatic (sliding) transform.
Definition: scenegraph.h:75
AA_API void aa_rx_sg_tf(const struct aa_rx_sg *scene_graph, size_t n_q, const double *q, size_t n_tf, double *TF_rel, size_t ld_rel, double *TF_abs, size_t ld_abs)
Compute transforms for the scene graph.
AA_API aa_rx_frame_id aa_rx_sg_frame_parent(const struct aa_rx_sg *scene_graph, aa_rx_frame_id frame_id)
Return the parent id of the frame.
AA_API void aa_rx_sg_rel_tf(const struct aa_rx_sg *scene_graph, const aa_rx_frame_id frame_from, const aa_rx_frame_id frame_to, const double *tf_abs, size_t ld_abs, double *from_tf_to)
Get transform between two given frames.
Opaque type for a scene_graph.
AA_API size_t aa_rx_sg_frame_count(const struct aa_rx_sg *scene_graph)
Return the number of frames in scene_graph.
AA_API void aa_rx_sg_add_frame_revolute(struct aa_rx_sg *scene_graph, const char *parent, const char *name, const double q[4], const double v[3], const char *config_name, const double axis[3], double offset)
Add a revolute-joint frame to the scene graph.
AA_API int aa_rx_sg_get_limit_pos(const struct aa_rx_sg *scenegraph, aa_rx_config_id config_id, double *min, double *max)
Get position limit values.
AA_API aa_rx_config_id aa_rx_sg_frame_config(const struct aa_rx_sg *scene_graph, aa_rx_frame_id frame)
Return the config id of frame.
AA_API int aa_rx_sg_get_limit_eff(const struct aa_rx_sg *scenegraph, aa_rx_config_id config_id, double *min, double *max)
Get effort limit values.
#define AA_API
calling and name mangling convention for functions
Definition: amino.h:95
AA_API size_t aa_rx_sg_config_names(const struct aa_rx_sg *scene_graph, size_t n_names, const char **names)
Fill names with pointers to config names.
AA_API void aa_rx_sg_map_geom(const struct aa_rx_sg *scene_graph, void(*function)(void *context, aa_rx_frame_id frame_id, struct aa_rx_geom *geom), void *context)
Call function for every geometry object in the scene graph.
AA_API size_t aa_rx_sg_config_count(const struct aa_rx_sg *scene_graph)
Return the number of configuration variables in scene_graph.
AA_API void aa_rx_sg_set_limit_pos(struct aa_rx_sg *scenegraph, const char *config_name, double min, double max)
Set position limit values.
AA_API void aa_rx_sg_add_frame_prismatic(struct aa_rx_sg *scene_graph, const char *parent, const char *name, const double q[4], const double v[3], const char *config_name, const double axis[3], double offset)
Add a prismatic-joint frame to the scene graph.
AA_API void aa_rx_sg_set_limit_acc(struct aa_rx_sg *scenegraph, const char *config_name, double min, double max)
Set acceleration limit values.
AA_API int aa_rx_sg_get_limit_acc(const struct aa_rx_sg *scenegraph, aa_rx_config_id config_id, double *min, double *max)
Get acceleration limit values.
signed long aa_rx_config_id
Type for configuration indices.
Definition: scenegraph.h:54
aa_rx_frame_type
Enum of frame types.
Definition: scenegraph.h:72
AA_API void aa_rx_sg_set_limit_vel(struct aa_rx_sg *scenegraph, const char *config_name, double min, double max)
Set velocity limit values.
AA_API struct aa_rx_sg * aa_rx_sg_create()
Construct a new, empty scene graph.