Model class More...
#include <stage.hh>

Classes | |
class | cb_t |
class | Flag |
class | GuiState |
class | RasterVis |
class | TrailItem |
class | Visibility |
Public Types | |
enum | callback_type_t { CB_FLAGDECR, CB_FLAGINCR, CB_GEOM, CB_INIT, CB_LOAD, CB_PARENT, CB_POSE, CB_SAVE, CB_SHUTDOWN, CB_STARTUP, CB_UPDATE, CB_VELOCITY, __CB_TYPE_COUNT } |
Public Member Functions | |
Block * | AddBlockRect (meters_t x, meters_t y, meters_t dx, meters_t dy, meters_t dz) |
void | AddCallback (callback_type_t type, model_callback_t cb, void *user) |
void | AddFlag (Flag *flag) |
void | AddToPose (const Pose &pose) |
void | AddToPose (double dx, double dy, double dz, double da) |
void | AddVisualizer (Visualizer *custom_visual, bool on_by_default) |
void | BecomeParentOf (Model *child) |
int | CallCallbacks (callback_type_t type) |
void | ClearBlocks () |
bool | DataIsFresh () const |
void | Disable () |
void | Enable () |
PowerPack * | FindPowerPack () const |
Model * | GetChild (const std::string &name) const |
Color | GetColor () const |
usec_t | GetEnergyInterval () const |
int | GetFiducialReturn () const |
unsigned int | GetFlagCount () const |
Geom | GetGeom () const |
Pose | GetGlobalPose () const |
Velocity | GetGlobalVelocity () const |
uint32_t | GetId () const |
usec_t | GetInterval () |
kg_t | GetMassOfChildren () const |
const std::string & | GetModelType () const |
Pose | GetPose () const |
std::string | GetSayString () |
unsigned int | GetSubscriptionCount () const |
kg_t | GetTotalMass () const |
Model * | GetUnsubscribedModelOfType (const std::string &type) const |
Model * | GetUnusedModelOfType (const std::string &type) |
usec_t | GetUpdateInterval () const |
World * | GetWorld () const |
Pose | GlobalToLocal (const Pose &pose) const |
bool | HasSubscribers () const |
void | InitControllers () |
bool | IsAntecedent (const Model *testmod) const |
bool | IsDescendent (const Model *testmod) const |
bool | IsRelated (const Model *testmod) const |
void | Load (Worldfile *wf, int wf_entity) |
virtual void | Load () |
void | LoadBlock (Worldfile *wf, int entity) |
void | LoadControllerModule (const char *lib) |
Pose | LocalToGlobal (const Pose &pose) const |
point_t | LocalToGlobal (const point_t &pt) const |
std::vector< point_int_t > | LocalToPixels (const std::vector< point_t > &local) const |
Model (World *world, Model *parent=NULL, const std::string &type="model", const std::string &name="") | |
Model () | |
void | NeedRedraw () |
Model * | Parent () const |
void | PlaceInFreeSpace (meters_t xmin, meters_t xmax, meters_t ymin, meters_t ymax) |
virtual void | PopColor () |
Flag * | PopFlag () |
std::string | PoseString () |
virtual void | Print (char *prefix) const |
virtual const char * | PrintWithPose () const |
virtual void | PushColor (Color col) |
virtual void | PushColor (double r, double g, double b, double a) |
void | PushFlag (Flag *flag) |
void | Rasterize (uint8_t *data, unsigned int width, unsigned int height, meters_t cellwidth, meters_t cellheight) |
void | Redraw () |
int | RemoveCallback (callback_type_t type, model_callback_t callback) |
void | RemoveFlag (Flag *flag) |
void | RemoveVisualizer (Visualizer *custom_visual) |
Model * | Root () |
virtual void | Save () |
void | Say (const std::string &str) |
void | SetBlobReturn (bool val) |
void | SetBoundary (bool val) |
void | SetColor (Color col) |
void | SetFiducialKey (int key) |
void | SetFiducialReturn (int fid) |
void | SetFriction (double friction) |
void | SetGeom (const Geom &src) |
void | SetGlobalPose (const Pose &gpose) |
void | SetGlobalVelocity (const Velocity &gvel) |
void | SetGravityReturn (bool val) |
void | SetGripperReturn (bool val) |
void | SetGuiGrid (bool val) |
void | SetGuiMove (bool val) |
void | SetGuiNose (bool val) |
void | SetGuiOutline (bool val) |
void | SetMapResolution (meters_t res) |
void | SetMass (kg_t mass) |
void | SetObstacleReturn (bool val) |
int | SetParent (Model *newparent) |
void | SetPose (const Pose &pose) |
void | SetRangerReturn (double val) |
void | SetRangerReturn (bool val) |
void | SetStall (bool stall) |
void | SetStickyReturn (bool val) |
virtual void | SetToken (const std::string &str) |
void | SetWatts (watts_t watts) |
void | SetWorldfile (Worldfile *wf, int wf_entity) |
bool | Stalled () const |
void | Subscribe () |
void | Unsubscribe () |
virtual | ~Model () |
![]() | |
virtual void | AddChild (Model *mod) |
Ancestor () | |
void | ForEachDescendant (model_callback_t func, void *arg) |
std::vector< Model * > & | GetChildren () |
void * | GetProperty (std::string &key) |
virtual void | RemoveChild (Model *mod) |
void | SetProperty (std::string &key, void *value) |
const char * | Token () const |
const std::string & | TokenStr () const |
virtual | ~Ancestor () |
Static Public Member Functions | |
static Model * | LookupId (uint32_t id) |
Public Attributes | |
class Stg::Model::Visibility | vis |
Static Public Attributes | |
static std::map< std::string, creator_t > | name_map |
Protected Member Functions | |
void | AppendTouchingModels (std::set< Model * > &touchers) |
void | CallUpdateCallbacks (void) |
void | CommitTestedPose () |
virtual void | DataVisualize (Camera *cam) |
void | DataVisualizeTree (Camera *cam) |
virtual void | DrawBlocks () |
void | DrawBlocksTree () |
void | DrawBoundingBox () |
void | DrawBoundingBoxTree () |
void | DrawFlagList () |
void | DrawGrid () |
void | DrawImage (uint32_t texture_id, Camera *cam, float alpha, double width=1.0, double height=1.0) |
void | DrawOrigin () |
void | DrawOriginTree () |
virtual void | DrawPicker () |
void | DrawPose (Pose pose) |
virtual void | DrawSelected (void) |
virtual void | DrawStatus (Camera *cam) |
void | DrawStatusTree (Camera *cam) |
void | DrawTrailArrows () |
void | DrawTrailBlocks () |
void | DrawTrailFootprint () |
void | Map (unsigned int layer) |
void | Map () |
void | MapFromRoot (unsigned int layer) |
void | MapWithChildren (unsigned int layer) |
meters_t | ModelHeight () const |
void | PopCoords () |
void | PushLocalCoords () |
RaytraceResult | Raytrace (const Pose &pose, const meters_t range, const ray_test_func_t func, const void *arg, const bool ztest=true) |
void | Raytrace (const Pose &pose, const meters_t range, const radians_t fov, const ray_test_func_t func, const void *arg, RaytraceResult *samples, const uint32_t sample_count, const bool ztest=true) |
RaytraceResult | Raytrace (const radians_t bearing, const meters_t range, const ray_test_func_t func, const void *arg, const bool ztest=true) |
void | Raytrace (const radians_t bearing, const meters_t range, const radians_t fov, const ray_test_func_t func, const void *arg, RaytraceResult *samples, const uint32_t sample_count, const bool ztest=true) |
void | RegisterOption (Option *opt) |
virtual void | Shutdown () |
virtual void | Startup () |
Model * | TestCollision () |
void | UnMap (unsigned int layer) |
void | UnMap () |
void | UnMapFromRoot (unsigned int layer) |
void | UnMapWithChildren (unsigned int layer) |
virtual void | Update () |
virtual void | UpdateCharge () |
void | UpdateTrail () |
![]() | |
Ancestor & | Load (Worldfile *wf, int section) |
void | Save (Worldfile *wf, int section) |
Static Protected Member Functions | |
static int | UpdateWrapper (Model *mod, void *arg) |
Protected Attributes | |
bool | alwayson |
BlockGroup | blockgroup |
int | blocks_dl |
int | boundary |
std::vector< std::set< cb_t > > | callbacks |
Color | color |
std::list< Visualizer * > | cv_list |
bool | data_fresh |
bool | disabled |
unsigned int | event_queue_num |
std::list< Flag * > | flag_list |
double | friction |
Geom | geom |
class Stg::Model::GuiState | gui |
bool | has_default_block |
uint32_t | id |
usec_t | interval |
time between updates in usec More... | |
usec_t | interval_energy |
time between updates of powerpack in usec More... | |
usec_t | last_update |
time of last update in us More... | |
bool | log_state |
iff true, model state is logged More... | |
meters_t | map_resolution |
kg_t | mass |
Model * | parent |
Pose | pose |
PowerPack * | power_pack |
std::list< PowerPack * > | pps_charging |
Stg::Model::RasterVis | rastervis |
bool | rebuild_displaylist |
iff true, regenerate block display list before redraw More... | |
std::string | say_string |
if non-empty, this string is displayed in the GUI More... | |
bool | stack_children |
whether child models should be stacked on top of this model or not More... | |
bool | stall |
Set to true iff the model collided with something else. More... | |
int | subs |
the number of subscriptions to this model More... | |
bool | thread_safe |
std::vector< TrailItem > | trail |
unsigned int | trail_index |
const std::string | type |
bool | used |
TRUE iff this model has been returned by GetUnusedModelOfType() More... | |
watts_t | watts |
power consumed by this model More... | |
watts_t | watts_give |
watts_t | watts_take |
Worldfile * | wf |
int | wf_entity |
World * | world |
WorldGui * | world_gui |
![]() | |
std::map< std::string, unsigned int > | child_type_counts |
std::vector< Model * > | children |
bool | debug |
std::map< std::string, void * > | props |
std::string | token |
Static Protected Attributes | |
static uint64_t | trail_interval |
static unsigned int | trail_length |
Detailed Description
Model class
Member Enumeration Documentation
Constructor & Destructor Documentation
Model::Model | ( | World * | world, |
Model * | parent = NULL , |
||
const std::string & | type = "model" , |
||
const std::string & | name = "" |
||
) |
Constructor
|
virtual |
Destructor
|
inline |
Alternate constructor that creates dummy models with only a pose
Member Function Documentation
Add a block to this model centered at [x,y] with extent [dx, dy,
dz]
void Model::AddCallback | ( | callback_type_t | type, |
model_callback_t | cb, | ||
void * | user | ||
) |
Add a callback. The specified function is called whenever the
indicated model method is called, and passed the user data.
- Parameters
-
cb Pointer the function to be called. user Pointer to arbitrary user data, passed to the callback when called.
void Model::AddFlag | ( | Flag * | flag | ) |
void Model::AddToPose | ( | const Pose & | pose | ) |
add values to a model's pose in its parent's coordinate system
void Model::AddToPose | ( | double | dx, |
double | dy, | ||
double | dz, | ||
double | da | ||
) |
add values to a model's pose in its parent's coordinate system
void Model::AddVisualizer | ( | Visualizer * | custom_visual, |
bool | on_by_default | ||
) |
Attach a user supplied visualization to a model.
|
protected |
void Model::BecomeParentOf | ( | Model * | child | ) |
int Model::CallCallbacks | ( | callback_type_t | type | ) |
|
protected |
Calls CallCallback( CB_UPDATE )
void Model::ClearBlocks | ( | ) |
remove all blocks from this model, freeing their memory
|
protected |
|
inline |
|
protectedvirtual |
Reimplemented in Stg::ModelCamera, and Stg::ModelBlinkenlight.
|
protected |
|
inline |
Disable the model. Its pose will not change due to velocity
until re-enabled using Enable(). This is used for example when dragging a model with the mouse pointer. The model is enabled by default.
|
protectedvirtual |
Reimplemented in Stg::ModelLightIndicator.
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
Draw the image stored in texture_id above the model
|
protected |
|
protected |
|
protectedvirtual |
|
protected |
|
protectedvirtual |
|
protectedvirtual |
|
protected |
|
protected |
|
protected |
|
protected |
|
inline |
Enable the model, so that non-zero velocities will change the
model's pose. Models are enabled by default.
PowerPack * Model::FindPowerPack | ( | ) | const |
Model * Model::GetChild | ( | const std::string & | name | ) | const |
Returns a pointer to the model identified by name, or NULL if
it doesn't exist in this model.
|
inline |
|
inline |
|
inline |
Get a model's fiducial return value.
|
inline |
|
inline |
Get (a copy of) the model's geometry - it's size and local
pose (offset from origin in local coords).
|
virtual |
get the pose of a model in the global CS
Reimplemented from Stg::Ancestor.
Velocity Stg::Model::GetGlobalVelocity | ( | ) | const |
get the velocity of a model in the global CS
|
inline |
return a model's unique process-wide identifier
|
inline |
return the update interval in usec
kg_t Model::GetMassOfChildren | ( | ) | const |
Get the mass of this model's children recursively.
|
inline |
|
inline |
Get (a copy of) the pose of a model in its parent's coordinate
system.
|
inline |
|
inline |
Returns the current number of subscriptions. If alwayson, this
is never less than 1.
kg_t Model::GetTotalMass | ( | ) | const |
Get the total mass of a model and it's children recursively
Model * Model::GetUnsubscribedModelOfType | ( | const std::string & | type | ) | const |
returns the first descendent of this model that is unsubscribed
and has the type indicated by the string
Model * Model::GetUnusedModelOfType | ( | const std::string & | type | ) |
returns the first descendent of this model that is unused
and has the type indicated by the string. This model is tagged as used.
|
inline |
|
inline |
Returns a pointer to the world that contains this model
Given a global pose, returns that pose in the model's local
coordinate system.
|
inline |
Returns true if the model has one or more subscribers, else false.
void Model::InitControllers | ( | ) |
Call Init() for all attached controllers.
bool Model::IsAntecedent | ( | const Model * | testmod | ) | const |
bool Model::IsDescendent | ( | const Model * | testmod | ) | const |
returns true if model [testmod] is a descendent of this model
bool Model::IsRelated | ( | const Model * | testmod | ) | const |
returns true if model [testmod] is a descendent or antecedent of this model
|
inline |
Set the worldfile and worldfile entity ID - must be called
before Load()
|
virtual |
configure a model by reading from the current world file
Reimplemented in Stg::ModelActuator, Stg::ModelPosition, Stg::ModelCamera, Stg::ModelBlinkenlight, Stg::ModelRanger, Stg::ModelFiducial, Stg::ModelGripper, and Stg::ModelBlobfinder.
void Model::LoadBlock | ( | Worldfile * | wf, |
int | entity | ||
) |
Add a block to this model by loading it from a worldfile
entity
void Model::LoadControllerModule | ( | const char * | lib | ) |
Load a control program for this model from an external
library
Return the global pose (i.e. pose in world coordinates) of a
pose specified in the model's local coordinate system
Return the 2d point in world coordinates of a 2d point
specified in the model's local coordinate system
std::vector< point_int_t > Model::LocalToPixels | ( | const std::vector< point_t > & | local | ) | const |
Return a vector of global pixels corresponding to a vector of local points.
|
inlinestatic |
Look up a model pointer by a unique model ID
|
protected |
|
inlineprotected |
Call Map on all layers
|
protected |
|
protected |
|
protected |
void Model::NeedRedraw | ( | void | ) |
Sets the redraw flag, so this model will be redrawn at the
earliest opportunity
|
inline |
Returns a pointer to this model's parent model, or NULL if this
model has no parent
|
inlinevirtual |
|
protected |
Model::Flag * Model::PopFlag | ( | ) |
|
inline |
Return a human-readable string describing the model's pose
|
virtual |
Reimplemented in Stg::ModelRanger.
|
virtual |
|
inlinevirtual |
|
inlinevirtual |
void Model::PushFlag | ( | Flag * | flag | ) |
|
protected |
void Model::Rasterize | ( | uint8_t * | data, |
unsigned int | width, | ||
unsigned int | height, | ||
meters_t | cellwidth, | ||
meters_t | cellheight | ||
) |
Render the model's blocks as an occupancy grid into the
preallocated array of width by height pixels
|
protected |
raytraces a single ray from the point and heading identified by
pose, in local coords
|
protected |
raytraces multiple rays around the point and heading identified
by pose, in local coords
|
protected |
|
protected |
void Model::Redraw | ( | void | ) |
Force the GUI (if any) to redraw this model
int Model::RemoveCallback | ( | callback_type_t | type, |
model_callback_t | callback | ||
) |
void Model::RemoveFlag | ( | Flag * | flag | ) |
void Model::RemoveVisualizer | ( | Visualizer * | custom_visual | ) |
remove user supplied visualization to a model - supply the same ptr passed to AddCustomVisualizer
|
inline |
return the root model of the tree containing this model
|
virtual |
save the state of the model to the current world file
Reimplemented in Stg::ModelGripper.
void Model::Say | ( | const std::string & | str | ) |
void Model::SetBlobReturn | ( | bool | val | ) |
void Model::SetBoundary | ( | bool | val | ) |
void Model::SetColor | ( | Color | col | ) |
void Model::SetFiducialKey | ( | int | key | ) |
set a model's fiducial key: only fiducial finders with a
matching key can detect this model as a fiducial.
void Model::SetFiducialReturn | ( | int | fid | ) |
Set a model's fiducial return value. Values less than zero
are not detected by the fiducial sensor.
void Model::SetFriction | ( | double | friction | ) |
void Model::SetGeom | ( | const Geom & | src | ) |
set a model's geometry (size and center offsets)
void Model::SetGlobalPose | ( | const Pose & | gpose | ) |
set the pose of model in global coordinates
void Stg::Model::SetGlobalVelocity | ( | const Velocity & | gvel | ) |
void Stg::Model::SetGravityReturn | ( | bool | val | ) |
void Model::SetGripperReturn | ( | bool | val | ) |
void Model::SetGuiGrid | ( | bool | val | ) |
void Model::SetGuiMove | ( | bool | val | ) |
void Model::SetGuiNose | ( | bool | val | ) |
void Model::SetGuiOutline | ( | bool | val | ) |
void Model::SetMapResolution | ( | meters_t | res | ) |
void Model::SetMass | ( | kg_t | mass | ) |
void Model::SetObstacleReturn | ( | bool | val | ) |
int Model::SetParent | ( | Model * | newparent | ) |
Change a model's parent - experimental
void Model::SetPose | ( | const Pose & | pose | ) |
Enable update of model pose according to velocity state Disable update of model pose according to velocity state set a model's pose in its parent's coordinate system
void Model::SetRangerReturn | ( | double | val | ) |
void Stg::Model::SetRangerReturn | ( | bool | val | ) |
void Model::SetStall | ( | bool | stall | ) |
void Stg::Model::SetStickyReturn | ( | bool | val | ) |
|
inlinevirtual |
Reimplemented from Stg::Ancestor.
void Model::SetWatts | ( | watts_t | watts | ) |
|
inline |
Set the worldfile and worldfile entity ID
|
protectedvirtual |
Reimplemented in Stg::ModelActuator, Stg::ModelPosition, Stg::ModelRanger, Stg::ModelFiducial, and Stg::ModelBlobfinder.
|
inline |
Returns the value of the model's stall boolean, which is true
iff the model has crashed into another model
|
protectedvirtual |
Reimplemented in Stg::ModelActuator, Stg::ModelPosition, Stg::ModelRanger, and Stg::ModelBlobfinder.
void Model::Subscribe | ( | void | ) |
subscribe to a model's data
|
protected |
Check to see if the current pose will yield a collision with
obstacles. Returns a pointer to the first entity we are in collision with, or NULL if no collision exists. Recursively calls TestCollision() on all descendents.
|
protected |
|
inlineprotected |
Call UnMap on all layers
|
protected |
|
protected |
void Model::Unsubscribe | ( | void | ) |
unsubscribe from a model's data
|
protectedvirtual |
Reimplemented in Stg::ModelActuator, Stg::ModelPosition, Stg::ModelCamera, Stg::ModelBlinkenlight, Stg::ModelRanger, and Stg::ModelBlobfinder.
|
protectedvirtual |
|
protected |
Record the current pose in our trail. Delete the trail head if it is full.
|
inlinestaticprotected |
Member Data Documentation
|
protected |
If true, the model always has at least one subscription, so
always runs. Defaults to false.
|
protected |
|
protected |
OpenGL display list identifier for the blockgroup
|
protected |
Iff true, 4 thin blocks are automatically added to the model,
forming a solid boundary around the bounding box of the model.
|
protected |
A list of callback functions can be attached to any
address. When Model::CallCallbacks( void*) is called, the callbacks are called.
|
protected |
Default color of the model's blocks.
|
protected |
Container for Visualizers attached to this model.
|
protected |
This can be set to indicate that the model has new data that
may be of interest to users. This allows polling the model instead of adding a data callback.
|
protected |
If set true, Update() is not called on this model. Useful
e.g. for temporarily disabling updates when dragging models with the mouse.
|
protected |
The index into the world's vector of event queues. Initially
-1, to indicate that it is not on a list yet.
|
protected |
Container for flags attached to this model.
|
protected |
Model the interaction between the model's blocks and the
surface they touch.
- Todo:
- primitive at the moment
|
protected |
Specifies the the size of this model's bounding box, and the
offset of its local coordinate system wrt that its parent.
|
protected |
|
protected |
|
protected |
unique process-wide identifier for this model
|
protected |
time between updates in usec
|
protected |
time between updates of powerpack in usec
|
protected |
time of last update in us
|
protected |
iff true, model state is logged
|
protected |
|
protected |
|
static |
|
protected |
Pointer to the parent of this model, possibly NULL.
|
protected |
The pose of the model in it's parents coordinate frame, or the
global coordinate frame is the parent is NULL.
|
protected |
list of powerpacks that this model is currently charging,
initially NULL.
|
protected |
|
protected |
iff true, regenerate block display list before redraw
|
protected |
if non-empty, this string is displayed in the GUI
|
protected |
whether child models should be stacked on top of this model or not
|
protected |
Set to true iff the model collided with something else.
|
protected |
the number of subscriptions to this model
|
protected |
Thread safety flag. Iff true, Update() may be called in
parallel with other models. Defaults to false for safety. Derived classes can set it true in their constructor to allow parallel Updates().
|
protected |
a ring buffer for storing recent poses
|
protected |
current position in the ring buffer
|
staticprotected |
Number of world updates between trail records.
|
staticprotected |
The maxiumum length of the trail drawn. Default is 20, but can
be set in the world file using the tail_length model property.
|
protected |
|
protected |
TRUE iff this model has been returned by GetUnusedModelOfType()
class Stg::Model::Visibility Stg::Model::vis |
|
protected |
power consumed by this model
|
protected |
If >0, this model can transfer energy to models that have
watts_take >0
|
protected |
If >0, this model can transfer energy from models that have
watts_give >0
|
protected |
|
protected |
|
protected |
|
protected |
The documentation for this class was generated from the following files:
Generated on Mon Feb 18 2013 11:55:16 for Stage by
