amino  1.0-beta2
Lightweight Robot Utility Library
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
scenegraph.h File Reference

The scenegraph data structure. More...

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. More...
 
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 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. 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.
 

Detailed Description

The scenegraph data structure.

Definition in file scenegraph.h.

Enumeration Type Documentation

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 79 of file scenegraph.h.

Function Documentation

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_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_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_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_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_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_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 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_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_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_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_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_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_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_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_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_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_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_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_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_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_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.

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_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).