amino  1.0-beta2
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 
64 #define AA_RX_FRAME_NONE ((aa_rx_frame_id)-2)
65 
69 #define AA_RX_CONFIG_NONE ((aa_rx_config_id)-1)
70 
74 #define AA_RX_CONFIG_MULTI ((aa_rx_config_id)-2)
75 
83 };
84 
88 AA_API struct aa_rx_sg *
90 
94 AA_API void aa_rx_sg_destroy(struct aa_rx_sg *scene_graph);
95 
102 AA_API int aa_rx_sg_init ( struct aa_rx_sg *scene_graph );
103 
112  const struct aa_rx_sg *scene_graph, aa_rx_frame_id frame_id );
113 
120 AA_API const char *
122  const struct aa_rx_sg *scene_graph, aa_rx_frame_id frame_id );
123 
130 AA_API const char *
132  const struct aa_rx_sg *scene_graph, aa_rx_config_id config_id );
133 
142  const struct aa_rx_sg *scene_graph, aa_rx_frame_id frame_id );
143 
144 
148 AA_API size_t
150  const struct aa_rx_sg *scene_graph );
151 
155 AA_API size_t
157  const struct aa_rx_sg *scene_graph );
158 
167  const struct aa_rx_sg *scene_graph, aa_rx_frame_id frame);
168 
173 AA_API size_t
175  const struct aa_rx_sg *scene_graph, size_t n_names,
176  const char **names );
177 
185  const struct aa_rx_sg *scene_graph, const char *config_name);
186 
193 AA_API void
195  const struct aa_rx_sg *scene_graph, size_t n,
196  const char **config_name, aa_rx_config_id *ids );
197 
198 
202 AA_API void
204  const struct aa_rx_sg *scene_graph, size_t n_all, size_t n_subset,
205  const aa_rx_config_id *ids,
206  const double *config_all,
207  double *config_subset );
208 
212 AA_API void
214  const struct aa_rx_sg *scene_graph, size_t n_all, size_t n_subset,
215  const aa_rx_config_id *ids, const double *config_subset,
216  double *config_all
217  );
218 
226  const struct aa_rx_sg *scene_graph, const char *frame_name);
227 
228 
229 /* /\** */
230 /* * Return the index of a configuration variable for the given frame. */
231 /* *\/ */
232 /* AA_API aa_rx_config_id aa_rx_sg_frame_config_id( */
233 /* struct aa_rx_sg *scene_graph, aa_rx_frame_id frame_id); */
234 
251 ( struct aa_rx_sg *scene_graph,
252  const char *parent, const char *name,
253  const double q[4], const double v[3] );
254 
272 ( struct aa_rx_sg *scene_graph,
273  const char *parent, const char *name,
274  const double q[4], const double v[3],
275  const char *config_name,
276  const double axis[3], double offset );
277 
295 ( struct aa_rx_sg *scene_graph,
296  const char *parent, const char *name,
297  const double q[4], const double v[3],
298  const char *config_name,
299  const double axis[3], double offset );
300 
305 ( struct aa_rx_sg *scene_graph,
306  const char *name );
307 
311 AA_API void
312 aa_rx_sg_set_limit_pos( 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_vel( struct aa_rx_sg *scenegraph,
321  const char *config_name,
322  double min, double max );
323 
327 AA_API void
328 aa_rx_sg_set_limit_acc( struct aa_rx_sg *scenegraph,
329  const char *config_name,
330  double min, double max );
331 
335 AA_API void
336 aa_rx_sg_set_limit_eff( struct aa_rx_sg *scenegraph,
337  const char *config_name,
338  double min, double max );
347 AA_API int
348 aa_rx_sg_get_limit_pos( const struct aa_rx_sg *scenegraph,
349  aa_rx_config_id config_id,
350  double *min, double *max );
351 
360 AA_API int
361 aa_rx_sg_get_limit_vel( const struct aa_rx_sg *scenegraph,
362  aa_rx_config_id config_id,
363  double *min, double *max );
364 
373 AA_API int
374 aa_rx_sg_get_limit_acc( const struct aa_rx_sg *scenegraph,
375  aa_rx_config_id config_id,
376  double *min, double *max );
377 
384 AA_API int
385 aa_rx_sg_get_limit_eff( const struct aa_rx_sg *scenegraph,
386  aa_rx_config_id config_id,
387  double *min, double *max );
388 
389 
395 AA_API const double *aa_rx_sg_frame_axis
396 ( const struct aa_rx_sg *scene_graph, aa_rx_frame_id frame );
397 
417 AA_API void aa_rx_sg_tf
418 ( const struct aa_rx_sg *scene_graph,
419  size_t n_q, const double *q,
420  size_t n_tf,
421  double *TF_rel, size_t ld_rel,
422  double *TF_abs, size_t ld_abs );
423 
453 ( const struct aa_rx_sg *scene_graph,
454  size_t n_q,
455  const double *q0,
456  const double *q,
457  size_t n_tf,
458  const double *TF_rel0, size_t ld_rel0,
459  const double *TF_abs0, size_t ld_abs0,
460  double *TF_rel, size_t ld_rel,
461  double *TF_abs, size_t ld_abs );
462 
463 
464 
476  const struct aa_rx_sg *scene_graph,
477  void (*function)(void *context, aa_rx_frame_id frame_id, struct aa_rx_geom *geom),
478  void *context );
479 
490 AA_API void aa_rx_sg_rel_tf (
491  const struct aa_rx_sg *scene_graph,
492  const aa_rx_frame_id frame_from,
493  const aa_rx_frame_id frame_to,
494  const double * tf_abs,
495  size_t ld_abs,
496  double * from_tf_to);
497 
501 AA_API void aa_rx_sg_reparent_id ( const struct aa_rx_sg *scene_graph,
502  aa_rx_frame_id new_parent,
503  aa_rx_frame_id frame,
504  const double *E1);
505 
509 AA_API void aa_rx_sg_reparent_name ( const struct aa_rx_sg *scene_graph,
510  const char *new_parent,
511  const char *frame,
512  const double *E1);
513 
519 AA_API struct aa_rx_sg * aa_rx_sg_copy( const struct aa_rx_sg * orig);
520 
524 AA_API void aa_rx_sg_allow_collision( struct aa_rx_sg *scene_graph,
525  aa_rx_frame_id id0, aa_rx_frame_id id1, int allowed );
526 
530 AA_API void aa_rx_sg_allow_collision_name( struct aa_rx_sg *scene_graph,
531  const char* frame0, const char* frame1, int allowed );
532 
533 #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_reparent_id(const struct aa_rx_sg *scene_graph, aa_rx_frame_id new_parent, aa_rx_frame_id frame, const double *E1)
Change the parent of frame in the scenegraph.
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:81
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:80
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:82
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_reparent_name(const struct aa_rx_sg *scene_graph, const char *new_parent, const char *frame, const double *E1)
Change the parent of frame in the scenegraph.
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.
AA_API void aa_rx_sg_tf_update(const struct aa_rx_sg *scene_graph, size_t n_q, const double *q0, const double *q, size_t n_tf, const double *TF_rel0, size_t ld_rel0, const double *TF_abs0, size_t ld_abs0, double *TF_rel, size_t ld_rel, double *TF_abs, size_t ld_abs)
Updated transforms efficiently when only some configurations change.
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 void aa_rx_sg_config_get(const struct aa_rx_sg *scene_graph, size_t n_all, size_t n_subset, const aa_rx_config_id *ids, const double *config_all, double *config_subset)
Retrieve a subset of the configuration vector.
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 void aa_rx_sg_allow_collision_name(struct aa_rx_sg *scene_graph, const char *frame0, const char *frame1, int allowed)
Set allowed collisions between frame0 and frame1.
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_config_set(const struct aa_rx_sg *scene_graph, size_t n_all, size_t n_subset, const aa_rx_config_id *ids, const double *config_subset, double *config_all)
Fill a subset of the configuration vector.
AA_API struct aa_rx_sg * aa_rx_sg_copy(const struct aa_rx_sg *orig)
Deeply copy a scenegraph.
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:79
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.
AA_API void aa_rx_sg_allow_collision(struct aa_rx_sg *scene_graph, aa_rx_frame_id id0, aa_rx_frame_id id1, int allowed)
Set allowed collisions between frames id0 and id1.