Models
[libstage API reference]
Detailed Description
Implements the basic objectDefine Documentation
#define STG_AUDIO_MAX_STRING_LEN 256 |
Referenced by audio_init(), audio_update(), InterfaceAudio::ProcessMessage(), and InterfaceAudio::Publish().
#define STG_BLOB_CHANNELS_MAX 16 |
Referenced by blobfinder_load(), and blobfinder_update().
#define STG_MOVE_ROT (1 << 1) |
#define STG_MOVE_SCALE (1 << 2) |
#define STG_MOVE_TRANS (1 << 0) |
#define STG_MP_AUDIO_RETURN "_mp_audio_return" |
Referenced by stg_model_set_property_named().
#define STG_MP_COLOR "_mp_color" |
Referenced by stg_model_set_property_named().
#define STG_MP_FIDUCIAL_RETURN "_mp_fiducial_return" |
Referenced by stg_model_set_property_named().
#define STG_MP_GEOM "_mp_geom" |
#define STG_MP_GRIPPER_RETURN "_mp_gripper_return" |
Referenced by stg_model_set_property_named().
#define STG_MP_LASER_RETURN "_mp_laser_return" |
Referenced by stg_model_set_property_named().
#define STG_MP_MASS "_mp_mass" |
Referenced by stg_model_set_property_named().
#define STG_MP_OBSTACLE_RETURN "_mp_obstacle_return" |
Referenced by stg_model_set_property_named().
#define STG_MP_POSE "_mp_pose" |
#define STG_MP_PREFIX "_mp_" |
Referenced by stg_model_set_property().
#define STG_MP_RANGER_RETURN "_mp_ranger_return" |
Referenced by stg_model_set_property_named().
#define STG_MP_VELOCITY "_mp_velocity" |
#define STG_MP_WATTS "_mp_watts" |
Referenced by stg_model_set_property_named().
#define STG_POSITION_CONTROL_DEFAULT STG_POSITION_CONTROL_VELOCITY |
Referenced by position_init().
#define STG_POSITION_DRIVE_DEFAULT STG_POSITION_DRIVE_DIFFERENTIAL |
Referenced by position_init().
#define STG_POSITION_LOCALIZATION_DEFAULT STG_POSITION_LOCALIZATION_GPS |
Referenced by position_init().
#define STG_SPEECH_MAX_STRING_LEN 256 |
Referenced by InterfaceSpeech::ProcessMessage().
Typedef Documentation
typedef int(* stg_model_callback_t)(stg_model_t *mod, void *user) |
Define a callback function type that can be attached to a record within a model and called whenever the record is set.
typedef int(* stg_model_initializer_t)(stg_model_t *) |
function type for an initialization function that configures a specialized model. Each special model type (laser, position, etc) has a single initializer function that is called when the model type is specified in the worldfile. The mapping is done in a table in typetable.cc.
typedef int stg_movemask_t |
typedef stg_ptz_t stg_ptz_cmd_t |
ptz command: specify desired PTZ angles. Tilt has no effect.
typedef stg_ptz_t stg_ptz_data_t |
ptz data: specifies actual PTZ angles.
Enumeration Type Documentation
enum stg_audio_cmd_type_t |
enum stg_laser_return_t |
Function Documentation
void stg_model_add_callback | ( | stg_model_t * | mod, | |
void * | member, | |||
stg_model_callback_t | cb, | |||
void * | user | |||
) |
void stg_model_add_property_toggles | ( | stg_model_t * | mod, | |
void * | member, | |||
stg_model_callback_t | callback_on, | |||
void * | arg_on, | |||
stg_model_callback_t | callback_off, | |||
void * | arg_off, | |||
const char * | name, | |||
const char * | label, | |||
gboolean | enabled | |||
) |
Add an item to the View menu that will automatically install and remove a callback when the item is toggled. The specialized model types use this call to set up their data visualization.
References _stg_disable_gui, stg_property_toggle_args_t::action, stg_property_toggle_args_t::arg_off, stg_property_toggle_args_t::arg_on, stg_property_toggle_args_t::callback_off, stg_property_toggle_args_t::callback_on, FALSE, stg_property_toggle_args_t::member, stg_property_toggle_args_t::mod, model_change(), stg_property_toggle_args_t::name, stg_property_toggle_args_t::path, stg_model_add_callback(), TOGGLE_PATH, toggle_property_callback(), wf_property_exists(), and wf_read_int().
Referenced by audio_init(), blobfinder_init(), bumper_init(), fiducial_init(), gc_laser_init(), gc_model_init(), gc_ranger_init(), gripper_init(), laser_init(), position_init(), ranger_init(), speech_init(), stg_model_create(), and wifi_init().
GPtrArray* stg_model_array_from_tree | ( | stg_model_t * | root | ) |
Convert a tree of models into a GPtrArray containing the same models.
stg_model_t* stg_model_create | ( | stg_world_t * | world, | |
stg_model_t * | parent, | |||
stg_id_t | id, | |||
char * | typestr | |||
) |
create a new model
References _model_update(), _stg_disable_gui, FALSE, gc_model_init(), gui_model_create(), gui_model_grid(), gui_model_lines(), gui_model_mask(), gui_model_move(), gui_model_polygons(), LaserVisible, model_render_velocity(), model_unrender_velocity(), PRINT_DEBUG3, PRINT_ERR1, STG_DEFAULT_GRID, STG_DEFAULT_MASK, STG_DEFAULT_NOSE, STG_DEFAULT_OUTLINE, stg_model_add_callback(), stg_model_add_property_toggles(), stg_model_set_polygons(), STG_TOKEN_MAX, stg_unit_polygon_create(), and TRUE.
Referenced by stg_world_create_from_file().
void stg_model_destroy | ( | stg_model_t * | mod | ) |
destroy a model, freeing its memory
References FALSE, and gui_model_destroy().
Referenced by model_destroy_cb().
void stg_model_draw_points | ( | stg_model_t * | mod, | |
const char * | group, | |||
double | x, | |||
double | y, | |||
double | a, | |||
stg_point_t * | points, | |||
size_t | point, | |||
double | size, | |||
stg_color_t | color | |||
) |
void stg_model_draw_polygons | ( | stg_model_t * | mod, | |
const char * | group, | |||
double | x, | |||
double | y, | |||
double | a, | |||
stg_polygon_t * | polys, | |||
size_t | polycount | |||
) |
void stg_model_draw_polylines | ( | stg_model_t * | mod, | |
const char * | group, | |||
double | x, | |||
double | y, | |||
double | a, | |||
stg_polyline_t * | lines, | |||
size_t | linecount, | |||
double | thickness, | |||
stg_color_t | colot | |||
) |
int stg_model_fig_clear_cb | ( | stg_model_t * | mod, | |
void * | data, | |||
size_t | len, | |||
void * | userp | |||
) |
References stg_model_fig_clear().
void* stg_model_get_cfg | ( | stg_model_t * | mod, | |
size_t * | lenp | |||
) |
void* stg_model_get_cmd | ( | stg_model_t * | mod, | |
size_t * | lenp | |||
) |
void* stg_model_get_data | ( | stg_model_t * | mod, | |
size_t * | lenp | |||
) |
Referenced by indicator_shutdown(), and indicator_update().
void stg_model_get_geom | ( | stg_model_t * | mod, | |
stg_geom_t * | dest | |||
) |
Get a model's geometry - it's size and local pose (offset from origin in local coords)
Referenced by audio_findpoints(), gc_laser_data(), gc_model_polygons(), gc_ranger_data(), gripper_break_beam(), gripper_paddle_contact(), gripper_render_cfg(), gripper_update(), gui_model_grid(), gui_model_polygons(), gui_model_render_geom_global(), laser_render_data(), laser_update(), model_fiducial_check_neighbor(), InterfacePosition::ProcessMessage(), InterfaceLaser::ProcessMessage(), InterfaceGripper::ProcessMessage(), InterfaceFiducial::ProcessMessage(), ranger_render_cfg(), ranger_render_data(), speech_update(), and wifi_update().
void stg_model_get_global_pose | ( | stg_model_t * | mod, | |
stg_pose_t * | pose | |||
) |
get the pose of a model in the global CS
References stg_pose_t::a, NORMALIZE, stg_model_get_global_pose(), stg_pose_t::x, and stg_pose_t::y.
Referenced by append_link_information(), audio_deliver_msgs(), audio_render_data(), audio_update(), blobfinder_render_data(), blobfinder_update(), compare_models(), fiducial_update(), gc_laser_data(), gripper_update(), gui_model_render_geom_global(), laser_render_data(), model_fiducial_check_neighbor(), model_render_velocity(), position_load(), position_update(), stg_model_get_global_pose(), stg_model_get_global_velocity(), stg_model_global_to_local(), stg_model_local_to_global(), stg_model_position_set_odom(), stg_model_set_global_velocity(), stg_model_update_pose(), wifi_render_cfg(), and wifi_render_data().
void stg_model_get_global_velocity | ( | stg_model_t * | mod, | |
stg_velocity_t * | gvel | |||
) |
get the velocity of a model in the global CS
References stg_pose_t::a, stg_model_get_global_pose(), stg_pose_t::x, and stg_pose_t::y.
Referenced by model_render_velocity(), and stg_model_update_pose().
stg_polygon_t* stg_model_get_polygons | ( | stg_model_t * | mod, | |
size_t * | poly_count | |||
) |
gets a model's "polygons" property and fills poly_count with the number of polygons to be found
Referenced by audio_findpoints(), and stg_model_test_collision().
void stg_model_get_pose | ( | stg_model_t * | mod, | |
stg_pose_t * | dest | |||
) |
Get the pose of a model in its parent's coordinate system
Referenced by model_event_callback(), InterfaceLaser::ProcessMessage(), InterfaceGripper::ProcessMessage(), InterfaceFiducial::ProcessMessage(), and InterfaceLocalize::Publish().
void* stg_model_get_property | ( | stg_model_t * | mod, | |
char * | key | |||
) |
Get a named property associated with a model
Referenced by gc_laser_data(), gc_model_group_create(), gc_model_group_destroy(), gc_model_highlight(), gc_model_highlight_remove(), gc_model_init(), gc_model_move(), and stg_model_draw_clear().
void stg_model_get_velocity | ( | stg_model_t * | mod, | |
stg_velocity_t * | dest | |||
) |
Get a model's velocity (in its local reference frame)
Referenced by gui_model_mouse().
void stg_model_global_to_local | ( | stg_model_t * | mod, | |
stg_pose_t * | pose | |||
) |
Convert a pose in the world coordinate system into a model's local coordinate system. Overwrites [pose] with the new coordinate.
References stg_pose_t::a, stg_model_get_global_pose(), stg_pose_t::x, and stg_pose_t::y.
Referenced by audio_draw_path(), audio_render_cfg(), gripper_paddle_contact(), and stg_model_set_global_pose().
int stg_model_is_antecedent | ( | stg_model_t * | mod, | |
stg_model_t * | testmod | |||
) |
returns TRUE iff [testmod] exists above [mod] in a model tree
References FALSE, stg_model_is_antecedent(), and TRUE.
Referenced by stg_model_is_antecedent().
int stg_model_is_descendent | ( | stg_model_t * | mod, | |
stg_model_t * | testmod | |||
) |
returns TRUE iff [testmod] exists below [mod] in a model tree
References FALSE, stg_model_is_descendent(), and TRUE.
Referenced by stg_model_is_descendent(), and stg_model_is_related().
int stg_model_is_related | ( | stg_model_t * | mod1, | |
stg_model_t * | mod2 | |||
) |
returns TRUE iff [mod1] and [mod2] both exist in the same model tree
References stg_model_is_descendent(), and TRUE.
Referenced by audio_deliver_msgs(), blobfinder_raytrace_filter(), bumper_raytrace_match(), compare_models(), fiducial_raytrace_match(), itl_wall_distance(), laser_raytrace_match(), lines_raytrace_match(), ranger_raytrace_match(), and wifi_raytrace_match().
void stg_model_load | ( | stg_model_t * | mod | ) |
configure a model by reading from the current world file
References stg_pose_t::a, stg_polyline_t::points, stg_polyline_t::points_count, stg_geom_t::pose, PRINT_ERR1, PRINT_WARN1, stg_geom_t::size, stg_lookup_color(), stg_model_set_audio_return(), stg_model_set_blob_return(), stg_model_set_boundary(), stg_model_set_color(), stg_model_set_fiducial_key(), stg_model_set_fiducial_return(), stg_model_set_geom(), stg_model_set_gripper_return(), stg_model_set_gui_grid(), stg_model_set_gui_mask(), stg_model_set_gui_nose(), stg_model_set_gui_outline(), stg_model_set_laser_return(), stg_model_set_map_resolution(), stg_model_set_mass(), stg_model_set_obstacle_return(), stg_model_set_polygons(), stg_model_set_polylines(), stg_model_set_pose(), stg_model_set_ranger_return(), stg_model_set_velocity(), stg_polygon_append_points(), stg_polygons_create(), stg_polygons_from_image_file(), STG_TOKEN_MAX, wf_get_filename(), wf_property_exists(), wf_read_float(), wf_read_int(), wf_read_string(), wf_read_tuple_angle(), wf_read_tuple_length(), stg_point_t::x, stg_size_t::x, stg_pose_t::x, stg_point_t::y, stg_size_t::y, and stg_pose_t::y.
Referenced by stg_model_reload_cb(), and stg_world_create_from_file().
void stg_model_local_to_global | ( | stg_model_t * | mod, | |
stg_pose_t * | pose | |||
) |
Convert a pose in the model's local coordinate system into the world coordinate system. Overwrites [pose] with the new coordinate.
References stg_model_get_global_pose(), and stg_pose_sum().
Referenced by gripper_break_beam(), gripper_paddle_contact(), gripper_update(), gui_model_render_geom_global(), gui_model_trail(), laser_update(), ranger_update(), speech_update(), stg_model_map(), and stg_model_test_collision().
void stg_model_position_set_odom | ( | stg_model_t * | mod, | |
stg_pose_t * | odom | |||
) |
set the current odometry estimate
References stg_pose_t::a, model_change(), stg_position_data_t::origin, stg_position_data_t::pose, stg_model_get_global_pose(), stg_pose_t::x, and stg_pose_t::y.
Referenced by InterfacePosition::ProcessMessage().
void stg_model_print | ( | stg_model_t * | mod, | |
char * | prefix | |||
) |
print human-readable information about the model on stdout. If prefix is non-null, it is printed first.
Referenced by model_print_cb().
int stg_model_remove_callback | ( | stg_model_t * | mod, | |
void * | member, | |||
stg_model_callback_t | callback | |||
) |
Referenced by model_call_callbacks(), and toggle_property_callback().
stg_model_t* stg_model_root | ( | stg_model_t * | mod | ) |
return the top-level model above mod
void stg_model_save | ( | stg_model_t * | mod | ) |
save the state of the model to the current world file
References PRINT_DEBUG4, wf_write_tuple_angle(), and wf_write_tuple_length().
Referenced by stg_model_save_cb().
void stg_model_set_audio_return | ( | stg_model_t * | mod, | |
int | val | |||
) |
References model_change().
Referenced by audio_init(), stg_model_load(), and stg_model_set_property_named().
void stg_model_set_blob_return | ( | stg_model_t * | mod, | |
int | val | |||
) |
References model_change().
Referenced by audio_init(), position_init(), speech_init(), stg_model_load(), and wifi_init().
void stg_model_set_boundary | ( | stg_model_t * | mod, | |
int | val | |||
) |
void stg_model_set_cfg | ( | stg_model_t * | mod, | |
void * | cfg, | |||
size_t | len | |||
) |
References model_change().
Referenced by audio_init(), blobfinder_init(), blobfinder_load(), bumper_init(), fiducial_init(), fiducial_load(), gripper_init(), gripper_update(), indicator_init(), laser_init(), position_init(), InterfaceLaser::ProcessMessage(), ptz_init(), ranger_init(), ranger_load(), speech_init(), speech_update(), and wifi_init().
void stg_model_set_cmd | ( | stg_model_t * | mod, | |
void * | cmd, | |||
size_t | len | |||
) |
References model_change().
Referenced by audio_init(), gripper_init(), indicator_init(), position_init(), position_shutdown(), InterfaceSpeech::ProcessMessage(), InterfacePosition::ProcessMessage(), InterfaceGripper::ProcessMessage(), InterfaceAudio::ProcessMessage(), InterfacePosition::Publish(), and speech_init().
void stg_model_set_color | ( | stg_model_t * | mod, | |
stg_color_t | col | |||
) |
References model_change().
Referenced by audio_init(), indicator_init(), laser_init(), ptz_init(), ranger_init(), speech_init(), stg_model_load(), stg_model_set_property_named(), and wifi_init().
void stg_model_set_data | ( | stg_model_t * | mod, | |
void * | data, | |||
size_t | len | |||
) |
References model_change().
Referenced by audio_init(), blobfinder_init(), blobfinder_shutdown(), blobfinder_update(), bumper_init(), fiducial_init(), fiducial_shutdown(), fiducial_update(), gripper_init(), gripper_update(), indicator_init(), indicator_load(), indicator_shutdown(), laser_init(), laser_shutdown(), laser_update(), position_init(), ptz_init(), ranger_init(), ranger_shutdown(), ranger_update(), speech_init(), speech_update(), wifi_init(), and wifi_update().
void stg_model_set_fiducial_key | ( | stg_model_t * | mod, | |
int | key | |||
) |
set a model's fiducial key: only fiducial finders with a matching key can detect this model as a fiducial.
References model_change().
Referenced by stg_model_load().
void stg_model_set_fiducial_return | ( | stg_model_t * | mod, | |
int | fid | |||
) |
set a model's geometry (size and center offsets)
References model_change().
Referenced by InterfaceFiducial::ProcessMessage(), stg_model_load(), and stg_model_set_property_named().
void stg_model_set_geom | ( | stg_model_t * | mod, | |
stg_geom_t * | src | |||
) |
set a model's geometry (size and center offsets)
References model_change(), stg_geom_t::size, stg_model_map(), stg_polygons_normalize(), stg_size_t::x, and stg_size_t::y.
Referenced by audio_init(), blobfinder_init(), bumper_init(), fiducial_init(), gripper_init(), indicator_init(), laser_init(), ptz_init(), ranger_init(), speech_init(), stg_model_load(), and wifi_init().
void stg_model_set_global_pose | ( | stg_model_t * | mod, | |
stg_pose_t * | gpose | |||
) |
get a human-readable string for the model's type set the pose of model in global coordinates
References stg_model_global_to_local(), and stg_model_set_pose().
Referenced by gripper_update().
void stg_model_set_global_velocity | ( | stg_model_t * | mod, | |
stg_velocity_t * | gvel | |||
) |
References stg_pose_t::a, stg_model_get_global_pose(), stg_model_set_velocity(), stg_pose_t::x, and stg_pose_t::y.
Referenced by stg_model_update_pose().
void stg_model_set_gripper_return | ( | stg_model_t * | mod, | |
int | val | |||
) |
References model_change().
Referenced by gripper_init(), stg_model_load(), and stg_model_set_property_named().
void stg_model_set_gui_grid | ( | stg_model_t * | mod, | |
int | val | |||
) |
void stg_model_set_gui_mask | ( | stg_model_t * | mod, | |
int | val | |||
) |
void stg_model_set_gui_nose | ( | stg_model_t * | mod, | |
int | val | |||
) |
void stg_model_set_gui_outline | ( | stg_model_t * | mod, | |
int | val | |||
) |
void stg_model_set_laser_return | ( | stg_model_t * | mod, | |
int | val | |||
) |
References model_change().
Referenced by audio_init(), speech_init(), stg_model_load(), stg_model_set_property_named(), and wifi_init().
void stg_model_set_lines | ( | stg_model_t * | mod, | |
stg_polyline_t * | lines, | |||
size_t | lines_count | |||
) |
set an array oflines to be drawn for the model
void stg_model_set_map_resolution | ( | stg_model_t * | mod, | |
stg_meters_t | res | |||
) |
void stg_model_set_mass | ( | stg_model_t * | mod, | |
stg_kg_t | mass | |||
) |
void stg_model_set_obstacle_return | ( | stg_model_t * | mod, | |
int | val | |||
) |
References model_change().
Referenced by audio_init(), speech_init(), stg_model_load(), stg_model_set_property_named(), and wifi_init().
int stg_model_set_parent | ( | stg_model_t * | mod, | |
stg_model_t * | newparent | |||
) |
Change a model's parent - experimental
References gui_model_create(), gui_model_destroy(), and model_change().
Referenced by gripper_paddle_contact(), and gripper_update().
void stg_model_set_polygons | ( | stg_model_t * | mod, | |
stg_polygon_t * | polys, | |||
size_t | poly_count | |||
) |
References model_change(), stg_model_map(), stg_polygons_destroy(), and stg_polygons_normalize().
Referenced by blobfinder_init(), bumper_init(), fiducial_init(), gripper_init(), indicator_init(), indicator_load(), indicator_update(), laser_init(), ranger_init(), stg_model_create(), and stg_model_load().
void stg_model_set_pose | ( | stg_model_t * | mod, | |
stg_pose_t * | pose | |||
) |
set a model's pose in its parent's coordinate system
References model_change(), and stg_model_map_with_children().
Referenced by gripper_paddle_contact(), gui_model_mouse(), model_event_callback(), InterfaceSimulation::ProcessMessage(), stg_model_load(), stg_model_set_global_pose(), and stg_model_update_pose().
int stg_model_set_property | ( | stg_model_t * | mod, | |
char * | propname, | |||
void * | data | |||
) |
Set a named property of a Stage model.
Set a property of a Stage model.
This function can set both predefined and user-defined properties of a model. Predefined properties are intrinsic to every model, such as pose and color. Every supported predefined properties has its identifying string defined as a preprocessor macro in stage.h. Users should use the macro instead of a hard-coded string, so that the compiler can help you to avoid mis-naming properties.
User-defined properties allow the user to attach arbitrary data pointers to a model. User-defined property data is not copied, so the original pointer must remain valid. User-defined property names are simple strings. Names beginning with an underscore ('_') are reserved for internal libstage use: users should not use names beginning with underscore (at risk of causing very weird behaviour).
Any callbacks registered for the named property will be called.
Returns 0 on success, or a positive error code on failure.
CAUTION* The caller is responsible for making sure the pointer points to data of the correct type for the property, so use carefully. Check the docs or the equivalent stg_model_set_<property>() function definition to see the type of data required for each property.
References stg_model_set_property_named(), and STG_MP_PREFIX.
Referenced by gc_laser_data(), gc_model_group_create(), gc_model_group_destroy(), gc_model_highlight(), gc_model_init(), and InterfaceSimulation::ProcessMessage().
void stg_model_set_ranger_return | ( | stg_model_t * | mod, | |
int | val | |||
) |
void stg_model_set_stall | ( | stg_model_t * | mod, | |
stg_bool_t | stall | |||
) |
Referenced by stg_model_update_pose().
void stg_model_set_velocity | ( | stg_model_t * | mod, | |
stg_velocity_t * | vel | |||
) |
set a model's velocity in its parent's coordinate system
References model_change().
Referenced by gui_model_mouse(), position_init(), position_shutdown(), stg_model_load(), stg_model_set_global_velocity(), and stg_model_update_pose().
void stg_model_set_watts | ( | stg_model_t * | mod, | |
stg_watts_t | watts | |||
) |
References model_change().
Referenced by fiducial_shutdown(), fiducial_startup(), gripper_shutdown(), gripper_startup(), indicator_shutdown(), indicator_startup(), laser_shutdown(), laser_startup(), position_shutdown(), position_startup(), ranger_shutdown(), ranger_startup(), stg_model_set_property_named(), wifi_shutdown(), and wifi_startup().
int stg_model_shutdown | ( | stg_model_t * | mod | ) |
finalize a model - called when a model goes from one to zero subscriptions
References PRINT_WARN1.
Referenced by stg_model_unsubscribe().
int stg_model_startup | ( | stg_model_t * | mod | ) |
initialize a model - called when a model goes from zero to one subscriptions
References PRINT_WARN1.
Referenced by stg_model_subscribe().
void stg_model_subscribe | ( | stg_model_t * | mod | ) |
void stg_model_unset_property | ( | stg_model_t * | mod, | |
char * | propname | |||
) |
Remove a property from a model.
Removes a data item previously associated with the model using stg_model_set_property(). No memory is freed, so the user should take care to free the memory.
Referenced by gc_model_highlight_remove().
void stg_model_unsubscribe | ( | stg_model_t * | mod | ) |
unsubscribe from a model's data
References stg_model_shutdown().
Referenced by StgDriver::Unsubscribe().
int stg_model_update | ( | stg_model_t * | model | ) |
Update a model by one simulation timestep. This is called by stg_world_update(), so users don't usually need to call this.
Referenced by model_update_cb().
Generated on Wed Jun 3 23:12:29 2009 for Stage by
