amino  1.0-beta2
Lightweight Robot Utility Library
scenegraph.h File Reference

The scenegraph data structure. More...

#include "amino/mat.h"
#include "rxtype.h"

Go to the source code of this file.

Macros

#define AA_RX_FRAME_ROOT   ((aa_rx_frame_id)-1)
 Magic frame_id for the root/global/absolute frame.
 
#define AA_RX_FRAME_NONE   ((aa_rx_frame_id)-2)
 Magic frame_id for no frame.
 
#define AA_RX_CONFIG_NONE   ((aa_rx_config_id)-1)
 Magic config_id for no configuration variable.
 
#define AA_RX_CONFIG_MULTI   ((aa_rx_config_id)-2)
 Magic config_id for multiple configuration variables.
 

Typedefs

typedef signed long aa_rx_frame_id
 Type for frame indices.
 
typedef signed long aa_rx_config_id
 Type for configuration indices.
 

Enumerations

enum  aa_rx_frame_type { AA_RX_FRAME_FIXED , AA_RX_FRAME_REVOLUTE , AA_RX_FRAME_PRISMATIC }
 Enum of frame types. More...
 

Functions

AA_API struct aa_rx_sgaa_rx_sg_create ()
 Construct a new, empty scene graph.
 
AA_API void aa_rx_sg_destroy (struct aa_rx_sg *scene_graph)
 Destroy a scene graph.
 
AA_API int aa_rx_sg_init (struct aa_rx_sg *scene_graph)
 Setup the scenegraph internal indices. More...
 
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. More...
 
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. More...
 
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. More...
 
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. More...
 
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 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 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. More...
 
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 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. More...
 
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. More...
 
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 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 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. More...
 
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. More...
 
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. More...
 
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. More...
 
AA_API void aa_rx_sg_rm_frame (struct aa_rx_sg *scene_graph, const char *name)
 Remove a frame.
 
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_set_limit_vel (struct aa_rx_sg *scenegraph, const char *config_name, double min, double max)
 Set velocity limit values.
 
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 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 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. More...
 
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. More...
 
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. More...
 
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. More...
 
AA_API double aa_rx_sg_config_center (const struct aa_rx_sg *sg, aa_rx_config_id config_id)
 Get the centered position of a configuration variable.
 
AA_API void aa_rx_sg_center_configs (const struct aa_rx_sg *sg, size_t n, double *q)
 Fill q with the centered positions of each configuration.
 
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. More...
 
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 as quaternion-translations. More...
 
AA_API struct aa_dmataa_rx_sg_get_tf_abs (const struct aa_rx_sg *scene_graph, struct aa_mem_region *reg, const struct aa_dvec *q)
 Allocate and compute absolute transforms for the scene graph. More...
 
AA_API void aa_rx_sg_fill_tf_abs (const struct aa_rx_sg *scene_graph, const struct aa_dvec *q, struct aa_dmat *tf_abs)
 
AA_API void aa_rx_sg_tfmat (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 as matrices. More...
 
AA_API void aa_rx_sg_duqu (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 as dual quaternions. More...
 
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. More...
 
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. More...
 
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. More...
 
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_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 struct aa_rx_sgaa_rx_sg_copy (const struct aa_rx_sg *orig)
 Deeply copy a scenegraph. More...
 
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.
 
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 void aa_rx_sg_copy_frame_geom (struct aa_rx_sg *scene_graph, const char *src_frame, const char *dst_frame)
 
AA_API double * aa_rx_sg_alloc_tf (const struct aa_rx_sg *sg, struct aa_mem_region *region)
 Allocate storage for TF array from region.
 
AA_API double * aa_rx_sg_alloc_config (const struct aa_rx_sg *sg, struct aa_mem_region *region)
 Allocate storage for config array from region.
 
AA_API void aa_rx_sg_add_octree (struct aa_rx_sg *scene_graph, const char *parent, const char *name, struct aa_rx_octree *ocTree, struct aa_rx_geom_opt *opt)
 

Variables

AA_EXTERN const aa_rx_frame_id aa_rx_frame_root
 
AA_EXTERN const aa_rx_frame_id aa_rx_frame_none
 
AA_EXTERN const aa_rx_config_id aa_rx_config_none
 
AA_EXTERN const aa_rx_config_id aa_rx_config_multi
 

Detailed Description

The scenegraph data structure.

Definition in file scenegraph.h.

Enumeration Type Documentation

◆ aa_rx_frame_type

Enum of frame types.

Enumerator
AA_RX_FRAME_FIXED 

A fixed transform.

AA_RX_FRAME_REVOLUTE 

A rotating transform.

AA_RX_FRAME_PRISMATIC 

A prismatic (sliding) transform.

Definition at line 88 of file scenegraph.h.

Function Documentation

◆ aa_rx_sg_add_frame_fixed()

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.

Note that adding a new frame may changes the frame_ids of all previously added frames.

Parameters
scene_graphThe scene graph container
parentThe name of the parent frame
nameThe name of the frame to be added
qThe unit quaternion frame rotation (xyzw)
vThe frame translation vector
Precondition
aa_rx_sg_init() has been called after all frames were added to the scenegraph.

◆ aa_rx_sg_add_frame_prismatic()

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.

Note that adding a new frame may changes the frame_ids and config_ids of all previously added frames.

Parameters
scene_graphThe scene graph container
parentThe name of the parent frame
nameThe name of the frame to be added
qThe unit quaternion frame initial rotation (xyzw)
vThe frame initial translation vector
config_nameThe name of the configuration variable.
axisThe axis of rotation. A non-unit axis will scale the translation accordingly.
offsetAn offset to be added to the configuration value

◆ aa_rx_sg_add_frame_revolute()

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.

Note that adding a new frame may changes the frame_ids and config_ids of all previously added frames.

Parameters
scene_graphThe scene graph container
parentThe name of the parent frame
nameThe name of the frame to be added
qThe unit quaternion frame initial rotation (xyzw)
vThe frame initial translation vector
config_nameThe name of the configuration variable.
axisThe axis of rotation. A non-unit axis will scale the rotation accordingly.
offsetAn offset to be added to the configuration value

◆ aa_rx_sg_config_id()

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.

Precondition
aa_rx_sg_init() has been called after all frames were added to the scenegraph.

◆ aa_rx_sg_config_indices()

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.

Precondition
aa_rx_sg_init() has been called after all frames were added to the scenegraph.

◆ aa_rx_sg_config_name()

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.

Precondition
aa_rx_sg_init() has been called after all frames were added to the scenegraph.

◆ aa_rx_sg_copy()

AA_API struct aa_rx_sg* aa_rx_sg_copy ( const struct aa_rx_sg orig)

Deeply copy a scenegraph.

Note that geometry objects and meshes will be shared via reference-counting.

◆ aa_rx_sg_duqu()

AA_API void aa_rx_sg_duqu ( 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 as dual quaternions.

Transform entries are in {real, dual} format.

Parameters
scene_graphThe scene graph container
n_qSize of configuration vector q
qConfiguraiton vector
n_tfNumber of entries in the TF array
TF_relRelative transform in dual quaternion format
ld_relLeading dimensional of TF_rel, i.e., space between each entry
TF_absAbsolute transform dual quaternion format
ld_absLeading dimensional of TF_abs, i.e., space between each entry
Precondition
aa_rx_sg_init() has been called after all frames were added to the scenegraph.

◆ aa_rx_sg_frame_axis()

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.

Only valid for univariate joint frames.

◆ aa_rx_sg_frame_config()

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.

Precondition
aa_rx_sg_init() has been called after all frames were added to the scenegraph.

◆ aa_rx_sg_frame_id()

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.

Precondition
aa_rx_sg_init() has been called after all frames were added to the scenegraph.

◆ aa_rx_sg_frame_name()

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.

Precondition
aa_rx_sg_init() has been called after all frames were added to the scenegraph.

◆ aa_rx_sg_frame_parent()

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.

Precondition
aa_rx_sg_init() has been called after all frames were added to the scenegraph.

◆ aa_rx_sg_frame_type()

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.

Precondition
aa_rx_sg_init() has been called after all frames were added to the scenegraph.

◆ aa_rx_sg_get_limit_acc()

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.

Precondition
aa_rx_sg_init() has been called after all frames were added to the scenegraph.
Returns
0 when a limit has been set, non-zero otherwise.

◆ aa_rx_sg_get_limit_eff()

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.

Precondition
aa_rx_sg_init() has been called after all frames were added to the scenegraph.

◆ aa_rx_sg_get_limit_pos()

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.

Precondition
aa_rx_sg_init() has been called after all frames were added to the scenegraph.
Returns
0 when a limit has been set, non-zero otherwise.

◆ aa_rx_sg_get_limit_vel()

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.

Precondition
aa_rx_sg_init() has been called after all frames were added to the scenegraph.
Returns
0 when a limit has been set, non-zero otherwise.

◆ aa_rx_sg_get_tf_abs()

AA_API struct aa_dmat* aa_rx_sg_get_tf_abs ( const struct aa_rx_sg scene_graph,
struct aa_mem_region reg,
const struct aa_dvec q 
)

Allocate and compute absolute transforms for the scene graph.

Transform entries are in {q_x, q_y, q_z, q_w, v_x, v_y, v_z} format.

Parameters
scene_graphThe scene graph container
qConfiguraiton vector
Precondition
aa_rx_sg_init() has been called after all frames were added to the scenegraph.

◆ aa_rx_sg_init()

AA_API int aa_rx_sg_init ( struct aa_rx_sg scene_graph)

Setup the scenegraph internal indices.

This function must be called before any frame_ids or config_ids can be used with the scenegraph.

◆ aa_rx_sg_map_geom()

AA_API void aa_rx_sg_map_geom ( const struct aa_rx_sg scene_graph,
void(*)(void *context, aa_rx_frame_id frame_id, struct aa_rx_geom *geom)  function,
void *  context 
)

Call function for every geometry object in the scene graph.

Parameters
scene_graphThe scene graph container
functionA function to call on every geometry object
contextThe context argument to function
Precondition
aa_rx_sg_init() has been called after all frames were added to the scenegraph.

◆ aa_rx_sg_rel_tf()

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.

Parameters
scene_graphThe scene graph container
frame_fromThe parent frame id
frame_toThe child frame id
tf_absArray of absolute transforms
ld_absLeading dimension of tf_abs
from_tf_toThe relative transform

◆ aa_rx_sg_tf()

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 as quaternion-translations.

Transform entries are in {q_x, q_y, q_z, q_w, v_x, v_y, v_z} format.

Parameters
scene_graphThe scene graph container
n_qSize of configuration vector q
qConfiguraiton vector
n_tfNumber of entries in the TF array
TF_relRelative transform matrix in quaternion-vector format
ld_relLeading dimensional of TF_rel, i.e., space between each entry
TF_absAbsolute transform matrix in quaternion-vector format
ld_absLeading dimensional of TF_abs, i.e., space between each entry
Precondition
aa_rx_sg_init() has been called after all frames were added to the scenegraph.

◆ aa_rx_sg_tf_update()

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.

Parameters
scene_graphThe scene graph container
n_qSize of configuration vector q
q0Initial configuration vector
qCurrent configuraiton vector
n_tfNumber of entries in the TF array
TF_rel0Initial relative transform matrix in quaternion-vector format
ld_rel0Initial leading dimensional of TF_rel, i.e., space between each entry
TF_abs0Initial absolute transform matrix in quaternion-vector format
ld_abs0Leading dimensional of TF_abs, i.e., space between each entry
TF_relCurrent relative transform matrix in quaternion-vector format
ld_relCurrent leading dimensional of TF_rel, i.e., space between each entry
TF_absCurrent absolute transform matrix in quaternion-vector format
ld_absCurrent leading dimensional of TF_abs, i.e., space between each entry
Precondition
aa_rx_sg_init() has been called after all frames were added to the scenegraph.
aa_rx_sg_tf() was previously called as aa_rx_sg_tf(scene_graph, n_q, q, n_tf, TF_rel0, ld_rel0, TF_abs0, ld_abs0).

◆ aa_rx_sg_tfmat()

AA_API void aa_rx_sg_tfmat ( 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 as matrices.

Transform entries are in {R, v} format.

Parameters
scene_graphThe scene graph container
n_qSize of configuration vector q
qConfiguraiton vector
n_tfNumber of entries in the TF array
TF_relRelative transform matrix
ld_relLeading dimensional of TF_rel, i.e., space between each entry
TF_absAbsolute transform matrix
ld_absLeading dimensional of TF_abs, i.e., space between each entry
Precondition
aa_rx_sg_init() has been called after all frames were added to the scenegraph.