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 
48 typedef signed long aa_rx_frame_id;
49 
53 typedef signed long aa_rx_config_id;
54 
58 #define AA_RX_FRAME_ROOT ((aa_rx_frame_id)-1)
59 
60 #define AA_RX_FRAME_NONE ((aa_rx_frame_id)-2)
61 
65 #define AA_RX_CONFIG_NONE ((aa_rx_config_id)-1)
66 #define AA_RX_CONFIG_MULTI ((aa_rx_config_id)-2)
67 
75 };
76 
80 AA_API struct aa_rx_sg *
82 
86 AA_API void aa_rx_sg_destroy(struct aa_rx_sg *scene_graph);
87 
94 AA_API int aa_rx_sg_init ( struct aa_rx_sg *scene_graph );
95 
104  const struct aa_rx_sg *scene_graph, aa_rx_frame_id frame_id );
105 
112 AA_API const char *
114  const struct aa_rx_sg *scene_graph, aa_rx_frame_id frame_id );
115 
122 AA_API const char *
124  const struct aa_rx_sg *scene_graph, aa_rx_config_id config_id );
125 
134  const struct aa_rx_sg *scene_graph, aa_rx_frame_id frame_id );
135 
136 
140 AA_API size_t
142  const struct aa_rx_sg *scene_graph );
143 
147 AA_API size_t
149  const struct aa_rx_sg *scene_graph );
150 
159  const struct aa_rx_sg *scene_graph, aa_rx_frame_id frame);
160 
165 AA_API size_t
167  const struct aa_rx_sg *scene_graph, size_t n_names,
168  const char **names );
169 
177  const struct aa_rx_sg *scene_graph, const char *config_name);
178 
185 AA_API void
187  const struct aa_rx_sg *scene_graph, size_t n,
188  const char **config_name, aa_rx_config_id *ids );
189 
190 
191 AA_API void
192 aa_rx_sg_config_get(
193  const struct aa_rx_sg *scene_graph, size_t n_all, size_t n_subset,
194  const aa_rx_config_id *ids,
195  const double *config_all,
196  double *config_subset );
197 
198 AA_API void
199 aa_rx_sg_config_set(
200  const struct aa_rx_sg *scene_graph, size_t n_all, size_t n_subset,
201  const aa_rx_config_id *ids, const double *config_subset,
202  double *config_all
203  );
204 
212  const struct aa_rx_sg *scene_graph, const char *frame_name);
213 
214 
215 /* /\** */
216 /* * Return the index of a configuration variable for the given frame. */
217 /* *\/ */
218 /* AA_API aa_rx_config_id aa_rx_sg_frame_config_id( */
219 /* struct aa_rx_sg *scene_graph, aa_rx_frame_id frame_id); */
220 
237 ( struct aa_rx_sg *scene_graph,
238  const char *parent, const char *name,
239  const double q[4], const double v[3] );
240 
257 ( struct aa_rx_sg *scene_graph,
258  const char *parent, const char *name,
259  const double q[4], const double v[3],
260  const char *config_name,
261  const double axis[3], double offset );
262 
279 ( struct aa_rx_sg *scene_graph,
280  const char *parent, const char *name,
281  const double q[4], const double v[3],
282  const char *config_name,
283  const double axis[3], double offset );
284 
289 ( struct aa_rx_sg *scene_graph,
290  const char *name );
291 
295 AA_API void
296 aa_rx_sg_set_limit_pos( struct aa_rx_sg *scenegraph,
297  const char *config_name,
298  double min, double max );
299 
303 AA_API void
304 aa_rx_sg_set_limit_vel( struct aa_rx_sg *scenegraph,
305  const char *config_name,
306  double min, double max );
307 
311 AA_API void
312 aa_rx_sg_set_limit_acc( struct aa_rx_sg *scenegraph,
313  const char *config_name,
314  double min, double max );
315 
319 AA_API void
320 aa_rx_sg_set_limit_eff( struct aa_rx_sg *scenegraph,
321  const char *config_name,
322  double min, double max );
329 AA_API int
330 aa_rx_sg_get_limit_pos( const struct aa_rx_sg *scenegraph,
331  aa_rx_config_id config_id,
332  double *min, double *max );
333 
340 AA_API int
341 aa_rx_sg_get_limit_vel( const struct aa_rx_sg *scenegraph,
342  aa_rx_config_id config_id,
343  double *min, double *max );
344 
351 AA_API int
352 aa_rx_sg_get_limit_acc( const struct aa_rx_sg *scenegraph,
353  aa_rx_config_id config_id,
354  double *min, double *max );
355 
362 AA_API int
363 aa_rx_sg_get_limit_eff( const struct aa_rx_sg *scenegraph,
364  aa_rx_config_id config_id,
365  double *min, double *max );
366 
367 
373 AA_API const double *aa_rx_sg_frame_axis
374 ( const struct aa_rx_sg *scene_graph, aa_rx_frame_id frame );
375 
395 AA_API void aa_rx_sg_tf
396 ( const struct aa_rx_sg *scene_graph,
397  size_t n_q, const double *q,
398  size_t n_tf,
399  double *TF_rel, size_t ld_rel,
400  double *TF_abs, size_t ld_abs );
401 
402 AA_API void aa_rx_sg_tf_update
403 ( const struct aa_rx_sg *scene_graph,
404  size_t n_q,
405  const double *q0,
406  const double *q,
407  size_t n_tf,
408  const double *TF_rel0, size_t ld_rel0,
409  const double *TF_abs0, size_t ld_abs0,
410  double *TF_rel, size_t ld_rel,
411  double *TF_abs, size_t ld_abs );
412 
413 
414 
426  const struct aa_rx_sg *scene_graph,
427  void (*function)(void *context, aa_rx_frame_id frame_id, struct aa_rx_geom *geom),
428  void *context );
429 
441 AA_API void aa_rx_sg_rel_tf (
442  const struct aa_rx_sg *scene_graph,
443  const aa_rx_frame_id frame_from,
444  const aa_rx_frame_id frame_to,
445  const double * tf_abs,
446  size_t ld_abs,
447  double * from_tf_to);
448 
449 AA_API void aa_rx_sg_reparent (
450  const struct aa_rx_sg *scene_graph,
451  const aa_rx_frame_id frame,
452  const aa_rx_frame_id new_parent,
453  const double * q);
454 
455 AA_API struct aa_rx_sg * aa_rx_sg_copy( const struct aa_rx_sg * orig);
456 
457 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 );
458 
459 AA_API void aa_rx_sg_allow_collision_name( struct aa_rx_sg *scene_graph, const char* id0, const char* id1, const int allowed );
460 
461 #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:73
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:55
signed long aa_rx_frame_id
Type for frame indices.
Definition: scenegraph.h:48
A fixed transform.
Definition: scenegraph.h:72
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:74
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:86
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:53
aa_rx_frame_type
Enum of frame types.
Definition: scenegraph.h:71
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.