Skip to content
Browse files

removed toby's over-specific models and player interfaces. simplified…

… model constructors, type name lookup, and removed Model::Create method. Added axis label scaling
  • Loading branch information...
1 parent f08183e commit 5a63ae0bf95b49d0e754198c2be4cb4070a0fd22 rtv committed Aug 19, 2009
View
21 examples/ctrl/fasr.cc
@@ -49,7 +49,7 @@ class Robot
ModelLaser* laser;
ModelRanger* ranger;
ModelFiducial* fiducial;
- ModelBlobfinder* blobfinder;
+ //ModelBlobfinder* blobfinder;
//ModelGripper* gripper;
Model *source, *sink;
int avoidcount, randcount;
@@ -66,11 +66,11 @@ class Robot
Model* source,
Model* sink )
: pos(pos),
- laser( (ModelLaser*)pos->GetUnusedModelOfType( MODEL_TYPE_LASER )),
- ranger( (ModelRanger*)pos->GetUnusedModelOfType( MODEL_TYPE_RANGER )),
- fiducial( (ModelFiducial*)pos->GetUnusedModelOfType( MODEL_TYPE_FIDUCIAL )),
- blobfinder( (ModelBlobfinder*)pos->GetUnusedModelOfType( MODEL_TYPE_BLOBFINDER )),
- //gripper( (ModelGripper*)pos->GetUnusedModelOfType( MODEL_TYPE_GRIPPER )),
+ laser( (ModelLaser*)pos->GetUnusedModelOfType( "laser" )),
+ ranger( (ModelRanger*)pos->GetUnusedModelOfType( "ranger" )),
+ fiducial( (ModelFiducial*)pos->GetUnusedModelOfType( "fiducial" )),
+ //blobfinder( (ModelBlobfinder*)pos->GetUnusedModelOfType( "blobfinder" )),
+ //gripper( (ModelGripper*)pos->GetUnusedModelOfType( "gripper" )),
source(source),
sink(sink),
avoidcount(0),
@@ -89,6 +89,8 @@ class Robot
assert( laser );
assert( source );
assert( sink );
+
+ // pos->GetUnusedModelOfType( "laser" );
// PositionUpdate() checks to see if we reached source or sink
pos->AddUpdateCallback( (stg_model_callback_t)PositionUpdate, this );
@@ -105,11 +107,8 @@ class Robot
//gripper->AddUpdateCallback( (stg_model_callback_t)GripperUpdate, this );
//gripper->Subscribe();
- if( blobfinder ) // optional
- {
- blobfinder->AddUpdateCallback( (stg_model_callback_t)BlobFinderUpdate, this );
- blobfinder->Subscribe();
- }
+ //blobfinder->AddUpdateCallback( (stg_model_callback_t)BlobFinderUpdate, this );
+ //blobfinder->Subscribe();
//pos->AddFlagIncrCallback( (stg_model_callback_t)FlagIncr, NULL );
//pos->AddFlagDecrCallback( (stg_model_callback_t)FlagDecr, NULL );
View
1 libstage/CMakeLists.txt
@@ -28,7 +28,6 @@ set( stageSrcs
model_position.cc
model_props.cc
model_ranger.cc
- model_loadcell.cc
model_lightindicator.cc
option.cc
powerpack.cc
View
8 libstage/ancestor.cc
@@ -6,11 +6,9 @@ Ancestor::Ancestor() :
children(),
debug( false ),
token( NULL ),
- access_mutex()
+ access_mutex(),
+ child_type_counts()
{
- for( int i=0; i<MODEL_TYPE_COUNT; i++ )
- child_type_counts[i] = 0;
-
pthread_mutex_init( &access_mutex, NULL );
}
@@ -27,7 +25,7 @@ void Ancestor::AddChild( Model* mod )
// printf( "adding child of type %d token %s\n", mod->type, mod->Token() );
- std::string typestr = Model::type_map[ mod->type ];
+ std::string typestr = mod->type;
if( token ) // if this object has a name, use it
snprintf( buf, TOKEN_MAX, "%s.%s:%d",
View
27 libstage/canvas.cc
@@ -592,19 +592,42 @@ void Canvas::DrawGlobalGrid()
*/
+ /* simple scaling of axis labels - could be better */
+ int skip = 50 / (int)camera.scale();
+ if( skip < 1 ) skip = 1;
+ if( skip > 2 && skip % 2 ) skip += 1;
+
+ //printf( "scale %.4f\n", camera.scale() );
+
char str[64];
PushColor( 0.2, 0.2, 0.2, 1.0 ); // pale gray
- for( double i = ceil(bounds.x.min); i < bounds.x.max; i++)
+
+ for( double i=0; i < bounds.x.max; i+=skip)
+ {
+ snprintf( str, 16, "%d", (int)i );
+ Gl::draw_string( i, 0, 0.00, str );
+ }
+
+ for( double i=0; i >= bounds.x.min; i-=skip)
{
snprintf( str, 16, "%d", (int)i );
Gl::draw_string( i, 0, 0.00, str );
}
+
- for( double i = ceil(bounds.y.min); i < bounds.y.max; i++)
+ for( double i=0; i < bounds.y.max; i+=skip)
+ {
+ snprintf( str, 16, "%d", (int)i );
+ Gl::draw_string( 0, i, 0.00, str );
+ }
+
+ for( double i=0; i >= bounds.y.min; i-=skip)
{
snprintf( str, 16, "%d", (int)i );
Gl::draw_string( 0, i, 0.00, str );
}
+
+
PopColor();
glPolygonMode( GL_FRONT_AND_BACK, GL_FILL );
View
39 libstage/model.cc
@@ -111,8 +111,7 @@ using namespace Stg;
uint32_t Model::count = 0;
std::map<stg_id_t,Model*> Model::modelsbyid;
-std::map<std::string, stg_creator_t> Model::name_map;
-std::map<stg_model_type_t, std::string> Model::type_map;
+std::map<std::string, creator_t> Model::name_map;
void Size::Load( Worldfile* wf, int section, const char* keyword )
{
@@ -187,16 +186,16 @@ void GuiState::Load( Worldfile* wf, int wf_entity )
// constructor
Model::Model( World* world,
- Model* parent,
- const stg_model_type_t type )
- : Ancestor(),
- blockgroup(),
- blocks_dl(0),
- boundary(false),
- callbacks(),
- color( 1,0,0 ), // red
- data_fresh(false),
- disabled(false),
+ Model* parent,
+ const std::string& type ) :
+ Ancestor(),
+ blockgroup(),
+ blocks_dl(0),
+ boundary(false),
+ callbacks(),
+ color( 1,0,0 ), // red
+ data_fresh(false),
+ disabled(false),
cv_list(),
flag_list(),
geom(),
@@ -848,7 +847,7 @@ void Model::UpdatePose( void )
world->Enqueue( 0, World::Event::POSE, interval_pose, this );
}
-Model* Model::GetUnsubscribedModelOfType( stg_model_type_t type ) const
+Model* Model::GetUnsubscribedModelOfType( const std::string& type ) const
{
if( (this->type == type) && (this->subs == 0) )
return const_cast<Model*> (this); // discard const
@@ -875,14 +874,14 @@ void Model::NeedRedraw( void )
world->NeedRedraw();
}
-Model* Model::GetUnusedModelOfType( stg_model_type_t type )
+Model* Model::GetUnusedModelOfType( const std::string& type )
{
//printf( "searching for type %d in model %s type %d\n", type, token, this->type );
-
+
if( (this->type == type) && (!this->used ) )
{
this->used = true;
- return this; // discard const
+ return this;
}
// this model is no use. try children recursively
@@ -892,8 +891,9 @@ Model* Model::GetUnusedModelOfType( stg_model_type_t type )
if( found )
return found;
}
-
+
// nothing matching below this model
+ if( ! parent ) PRINT_WARN1( "Request for unused model of type %s failed", type.c_str() );
return NULL;
}
@@ -907,7 +907,10 @@ stg_kg_t Model::GetTotalMass()
return sum;
}
-
+stg_kg_t Model::GetMassOfChildren()
+{
+ return( GetTotalMass() - mass);
+}
Model* Model::GetModel( const char* modelname ) const
{
View
21 libstage/model_actuator.cc
@@ -60,16 +60,17 @@ static const double STG_ACTUATOR_WATTS_KGMS = 5.0; // cost per kg per meter per
static const double STG_ACTUATOR_WATTS = 2.0; // base cost of position device
ModelActuator::ModelActuator( World* world,
- Model* parent )
- : Model( world, parent, MODEL_TYPE_ACTUATOR ),
- goal(0),
- pos(0),
- max_speed(1),
- min_position(0),
- max_position(1),
- control_mode( STG_ACTUATOR_CONTROL_VELOCITY ),
- actuator_type( STG_ACTUATOR_TYPE_LINEAR ),
- axis(0,0,0)
+ Model* parent,
+ const std::string& type ) :
+ Model( world, parent, type ),
+ goal(0),
+ pos(0),
+ max_speed(1),
+ min_position(0),
+ max_position(1),
+ control_mode( STG_ACTUATOR_CONTROL_VELOCITY ),
+ actuator_type( STG_ACTUATOR_TYPE_LINEAR ),
+ axis(0,0,0)
{
// no power consumed until we're subscribed
this->SetWatts( 0 );
View
15 libstage/model_blinkenlight.cc
@@ -56,14 +56,15 @@ using namespace Stg;
//TODO make instance attempt to register an option (as customvisualizations do)
Option ModelBlinkenlight::showBlinkenData( "Show Blink", "show_blinken", "", true, NULL );
-
+
ModelBlinkenlight::ModelBlinkenlight( World* world,
- Model* parent )
- : Model( world, parent, MODEL_TYPE_BLINKENLIGHT ),
- dutycycle( 1.0 ),
- enabled( true ),
- period( 1000 ),
- on( true )
+ Model* parent,
+ const std::string& type ) :
+ Model( world, parent, type ),
+ dutycycle( 1.0 ),
+ enabled( true ),
+ period( 1000 ),
+ on( true )
{
PRINT_DEBUG2( "Constructing ModelBlinkenlight %d (%s)\n",
id, typestr );
View
9 libstage/model_blobfinder.cc
@@ -78,10 +78,11 @@ blobfinder
*/
-
-ModelBlobfinder::ModelBlobfinder( World* world,
- Model* parent )
- : Model( world, parent, MODEL_TYPE_BLOBFINDER ),
+
+ ModelBlobfinder::ModelBlobfinder( World* world,
+ Model* parent,
+ const std::string& type ) :
+ Model( world, parent, type ),
vis( world ),
blobs(),
colors(),
View
33 libstage/model_camera.cc
@@ -84,22 +84,23 @@ void cross( float& x1, float& y1, float& z1, float x2, float y2, float z2 )
}
-ModelCamera::ModelCamera( World* world, Model* parent )
- : Model( world, parent, MODEL_TYPE_CAMERA ),
-_canvas( NULL ),
-_frame_data( NULL ),
-_frame_color_data( NULL ),
-_valid_vertexbuf_cache( false ),
-_vertexbuf_cache( NULL ),
-_width( 32 ),
-_height( 32 ),
-_camera_quads_size( 0 ),
-_camera_quads( NULL ),
-_camera_colors( NULL ),
-_camera(),
-_yaw_offset( 0.0 ),
-_pitch_offset( 0.0 )
-
+ModelCamera::ModelCamera( World* world,
+ Model* parent,
+ const std::string& type ) :
+ Model( world, parent, type ),
+ _canvas( NULL ),
+ _frame_data( NULL ),
+ _frame_color_data( NULL ),
+ _valid_vertexbuf_cache( false ),
+ _vertexbuf_cache( NULL ),
+ _width( 32 ),
+ _height( 32 ),
+ _camera_quads_size( 0 ),
+ _camera_quads( NULL ),
+ _camera_colors( NULL ),
+ _camera(),
+ _yaw_offset( 0.0 ),
+ _pitch_offset( 0.0 )
{
PRINT_DEBUG2( "Constructing ModelCamera %d (%s)\n",
id, typestr );
View
5 libstage/model_fiducial.cc
@@ -68,8 +68,9 @@ fiducial
*/
ModelFiducial::ModelFiducial( World* world,
- Model* parent ) :
- Model( world, parent, MODEL_TYPE_FIDUCIAL ),
+ Model* parent,
+ const std::string& type ) :
+ Model( world, parent, type ),
fiducials(),
max_range_anon( DEFAULT_RANGEMAXANON ),
max_range_id( DEFAULT_RANGEMAXID ),
View
9 libstage/model_gripper.cc
@@ -60,10 +60,11 @@ Option ModelGripper::showData( "Gripper data", "show_gripper_data", "", true, NU
// TODO - simulate energy use when moving grippers
ModelGripper::ModelGripper( World* world,
- Model* parent )
- : Model( world, parent, MODEL_TYPE_GRIPPER ),
- cfg(), // configured below
- cmd( CMD_NOOP )
+ Model* parent,
+ const std::string& type ) :
+ Model( world, parent, type ),
+ cfg(), // configured below
+ cmd( CMD_NOOP )
{
// set up a gripper-specific config structure
cfg.paddle_size.x = 0.66; // proportion of body length that is paddles
View
17 libstage/model_laser.cc
@@ -73,14 +73,15 @@ Option ModelLaser::Vis::showBeams( "Laser beams", "show_laser_beams", "", false,
ModelLaser::ModelLaser( World* world,
- Model* parent )
- : Model( world, parent, MODEL_TYPE_LASER ),
- vis( world ),
- sample_count( DEFAULT_SAMPLES ),
- samples(),
- range_max( DEFAULT_MAXRANGE ),
- fov( DEFAULT_FOV ),
- resolution( DEFAULT_RESOLUTION )
+ Model* parent,
+ const std::string& type ) :
+ Model( world, parent, type ),
+ vis( world ),
+ sample_count( DEFAULT_SAMPLES ),
+ samples(),
+ range_max( DEFAULT_MAXRANGE ),
+ fov( DEFAULT_FOV ),
+ resolution( DEFAULT_RESOLUTION )
{
PRINT_DEBUG2( "Constructing ModelLaser %d (%s)\n",
id, typestr );
View
8 libstage/model_lightindicator.cc
@@ -2,9 +2,11 @@
using namespace Stg;
-ModelLightIndicator::ModelLightIndicator(World* world, Model* parent)
- : Model(world, parent, MODEL_TYPE_LIGHTINDICATOR)
- , m_IsOn(false)
+ModelLightIndicator::ModelLightIndicator( World* world,
+ Model* parent,
+ const std::string& type ) :
+ Model( world, parent, type ),
+ m_IsOn(false)
{
}
View
41 libstage/model_loadcell.cc
@@ -1,41 +0,0 @@
-///////////////////////////////////////////////////////////////////////////
-//
-// File: model_loadcell.c
-// Author: Richard Vaughan
-// Date: 10 June 2004
-//
-// CVS info:
-// $Source: /home/tcollett/stagecvs/playerstage-cvs/code/stage/libstage/model_loadcell.cc,v $
-// $Author: rtv $
-// $Revision: 1.7 $
-//
-///////////////////////////////////////////////////////////////////////////
-
-#include <sys/time.h>
-#include "stage.hh"
-
-using namespace Stg;
-
-/**
-@ingroup model
-@defgroup model_loadcell Load cell model
-The load cell model simulates a load sensor. It provides a single voltage on an aio interface which represents the mass of it's child models combined.
-*/
-
-ModelLoadCell::ModelLoadCell( World* world,
- Model* parent )
- : Model( world, parent, MODEL_TYPE_LOADCELL )
-{
-}
-
-ModelLoadCell::~ModelLoadCell()
-{
-}
-
-float ModelLoadCell::GetVoltage()
-{
- if (Parent()->Stalled()) // Assume parent is what moves
- return 0.0f; // Load has hit something
- else
- return float(this->GetTotalMass() - this->mass); // Don't include the mass of the loadcell itself
-}
View
29 libstage/model_position.cc
@@ -79,20 +79,21 @@ static const double INTEGRATION_ERROR_MAX_Z = 0.00; // note zero!
static const double INTEGRATION_ERROR_MAX_A = 0.05;
ModelPosition::ModelPosition( World* world,
- Model* parent )
- : Model( world, parent, MODEL_TYPE_POSITION ),
- goal(0,0,0,0),
- control_mode( STG_POSITION_CONTROL_VELOCITY ),
- drive_mode( STG_POSITION_DRIVE_DIFFERENTIAL ),
- localization_mode( STG_POSITION_LOCALIZATION_GPS ),
- integration_error( drand48() * INTEGRATION_ERROR_MAX_X - INTEGRATION_ERROR_MAX_X/2.0,
- drand48() * INTEGRATION_ERROR_MAX_Y - INTEGRATION_ERROR_MAX_Y/2.0,
- drand48() * INTEGRATION_ERROR_MAX_Z - INTEGRATION_ERROR_MAX_Z/2.0,
- drand48() * INTEGRATION_ERROR_MAX_A - INTEGRATION_ERROR_MAX_A/2.0 ),
- waypoints( NULL ),
- waypoint_count( 0 ),
- wpvis(),
- posevis()
+ Model* parent,
+ const std::string& type ) :
+ Model( world, parent, type ),
+ goal(0,0,0,0),
+ control_mode( STG_POSITION_CONTROL_VELOCITY ),
+ drive_mode( STG_POSITION_DRIVE_DIFFERENTIAL ),
+ localization_mode( STG_POSITION_LOCALIZATION_GPS ),
+ integration_error( drand48() * INTEGRATION_ERROR_MAX_X - INTEGRATION_ERROR_MAX_X/2.0,
+ drand48() * INTEGRATION_ERROR_MAX_Y - INTEGRATION_ERROR_MAX_Y/2.0,
+ drand48() * INTEGRATION_ERROR_MAX_Z - INTEGRATION_ERROR_MAX_Z/2.0,
+ drand48() * INTEGRATION_ERROR_MAX_A - INTEGRATION_ERROR_MAX_A/2.0 ),
+ waypoints( NULL ),
+ waypoint_count( 0 ),
+ wpvis(),
+ posevis()
{
PRINT_DEBUG2( "Constructing ModelPosition %d (%s)\n",
id, typestr );
View
7 libstage/model_ranger.cc
@@ -99,11 +99,12 @@ Option ModelRanger::showRangerData( "Ranger ranges", "show_ranger", "", true, NU
Option ModelRanger::showRangerTransducers( "Ranger transducers", "show_ranger_transducers", "", false, NULL );
ModelRanger::ModelRanger( World* world,
- Model* parent )
- : Model( world, parent, MODEL_TYPE_RANGER )
+ Model* parent,
+ const std::string& type )
+ : Model( world, parent, type )
{
PRINT_DEBUG2( "Constructing ModelRanger %d (%s)\n",
- id, typestr );
+ id, type );
// Set up sensible defaults
View
3,078 libstage/stage.hh
1,496 additions, 1,582 deletions not shown because the diff is too large. Please use a local Git client to view these changes.
View
4 libstage/test.cc
@@ -44,7 +44,7 @@ int main( int argc, char* argv[] )
if( 1 )
{
- Model mod( &world, NULL );
+ Model mod( &world );
for( stg_meters_t x=0; x<5; x+=0.1 )
{
@@ -134,7 +134,7 @@ int main( int argc, char* argv[] )
Model* m[POP];
for( int i=0; i<POP; i++ )
{
- m[i] = new ModelLaser( &world, NULL );
+ m[i] = world.CreateModel( NULL, "laser" );
//m[i]->Say( "Hello" );
m[i]->Subscribe();
View
41 libstage/typetable.cc
@@ -2,31 +2,34 @@
using namespace Stg;
-static void Register( stg_model_type_t type,
- const char* desc,
- stg_creator_t func )
+/* Template used to created named wrappers for model constructors */
+template <class T>
+Model* Creator( World* world, Model* parent, const std::string& type )
{
- Model::name_map[ desc ] = func;
- Model::type_map[ type ] = desc;
+ return new T( world, parent, type );
+}
+
+static void Register( const std::string& type,
+ creator_t func )
+{
+ Model::name_map[ type ] = func;
}
/** Map model names to named constructors for each model type */
void Stg::RegisterModels()
{
- // the generic model
- Register( MODEL_TYPE_PLAIN, "model", Model::Create );
+ // generic model
+ Register( "model", Creator<Model> );
- // and the rest (in alphabetical order)
- Register( MODEL_TYPE_ACTUATOR, "actuator", ModelActuator::Create );
- Register( MODEL_TYPE_BLINKENLIGHT, "blinkenlight", ModelBlinkenlight::Create );
- Register( MODEL_TYPE_BLOBFINDER, "blobfinder", ModelBlobfinder::Create );
- Register( MODEL_TYPE_CAMERA, "camera", ModelCamera::Create );
- Register( MODEL_TYPE_FIDUCIAL, "fiducial", ModelFiducial::Create );
- Register( MODEL_TYPE_GRIPPER, "gripper", ModelGripper::Create );
- Register( MODEL_TYPE_LASER, "laser", ModelLaser::Create );
- Register( MODEL_TYPE_LIGHTINDICATOR, "lightindicator", ModelLightIndicator::Create );
- Register( MODEL_TYPE_LOADCELL, "loadcell", ModelLoadCell::Create );
- Register( MODEL_TYPE_POSITION, "position", ModelPosition::Create );
- Register( MODEL_TYPE_RANGER, "ranger", ModelRanger::Create );
+ Register( "actuator", Creator<ModelActuator> );
+ Register( "blinkenlight", Creator<ModelBlinkenlight> );
+ Register( "blobfinder", Creator<ModelBlobfinder> );
+ Register( "camera", Creator<ModelCamera> );
+ Register( "fiducial", Creator<ModelFiducial> );
+ Register( "gripper", Creator<ModelGripper> );
+ Register( "laser", Creator<ModelLaser> );
+ Register( "lightindicator", Creator<ModelLightIndicator> );
+ Register( "position", Creator<ModelPosition> );
+ Register( "ranger", Creator<ModelRanger> );
}
View
20 libstage/world.cc
@@ -232,37 +232,37 @@ void World::LoadBlock( Worldfile* wf, int entity )
}
-Model* World::CreateModel( Model* parent, const char* typestr )
+Model* World::CreateModel( Model* parent, const std::string& typestr )
{
Model* mod = NULL; // new model to return
// find the creator function pointer in the map. use the
// vanilla model if the type is NULL.
- stg_creator_t creator = NULL;
+ creator_t creator = NULL;
// printf( "creating model of type %s\n", typestr );
- std::map< std::string, stg_creator_t>::iterator it =
+ std::map< std::string, creator_t>::iterator it =
Model::name_map.find( typestr );
if( it == Model::name_map.end() )
- PRINT_ERR1( "type %s not found in map\n", typestr );
+ {
+ puts("");
+ PRINT_ERR1( "Model type %s not found in model typetable", typestr.c_str() );
+ }
else
- {
- creator = it->second;
- //puts( "found creator in map" );
- }
+ creator = it->second;
// if we found a creator function, call it
if( creator )
{
//printf( "creator fn: %p\n", creator );
- mod = (*creator)( this, parent );
+ mod = (*creator)( this, parent, typestr );
}
else
{
PRINT_ERR1( "Unknown model type %s in world file.",
- typestr );
+ typestr.c_str() );
exit( 1 );
}
View
7 libstageplugin/CMakeLists.txt
@@ -3,19 +3,18 @@ MESSAGE( STATUS "Configuring libstageplugin" )
link_directories( ${PLAYER_LIBRARY_DIRS} )
include_directories( ${PLAYER_INCLUDE_DIRS} )
-set( stagepluginSrcs p_driver.h
+set( stagepluginSrcs
+ p_driver.h
p_driver.cc
p_actarray.cc
p_blobfinder.cc
- p_gripper.cc
+ p_gripper.cc
p_simulation.cc
p_laser.cc
p_fiducial.cc
p_position.cc
p_sonar.cc
p_speech.cc
- p_aio.cc
- p_dio.cc
p_graphics.cc
stg_time.cc
)
View
80 libstageplugin/p_aio.cc
@@ -1,80 +0,0 @@
-/*
- * Player - One Hell of a Robot Server
- * Copyright (C) 2004, 2005 Richard Vaughan
- *
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- *
- */
-
-/*
- * Desc: A plugin driver for Player that gives access to Stage devices.
- * Author: Richard Vaughan
- * Date: 10 December 2004
- * CVS: $Id: p_laser.cc,v 1.2 2008-01-15 01:25:42 rtv Exp $
- */
-
-// DOCUMENTATION ------------------------------------------------------------
-
-/** @addtogroup player
-@par AIO interface
-- PLAYER_AIO_CMD_STATE
-- PLAYER_AIO_DATA_STATE
-*/
-
-// CODE ----------------------------------------------------------------------
-
-#include "p_driver.h"
-
-InterfaceAio::InterfaceAio( player_devaddr_t addr,
- StgDriver* driver,
- ConfigFile* cf,
- int section )
- : InterfaceModel( addr, driver, cf, section, Stg::MODEL_TYPE_LOADCELL ) // TODO: AIO should not always mean a loadcell
-{
-}
-
-void InterfaceAio::Publish( void )
-{
- Stg::ModelLoadCell* mod = (Stg::ModelLoadCell*)this->mod;
- float voltage = mod->GetVoltage();
-
- player_aio_data data;
- data.voltages_count = 1; // Just one value
- data.voltages = &voltage; // Might look bad but player does a deep copy so it should be ok.
-
- // Write data
- this->driver->Publish(this->addr,
- PLAYER_MSGTYPE_DATA,
- PLAYER_AIO_DATA_STATE,
- (void*)&data, sizeof(data), NULL);
-}
-
-int InterfaceAio::ProcessMessage(QueuePointer & resp_queue,
- player_msghdr_t* hdr,
- void* data)
-{
- //Stg::ModelLoadCell* mod = (Stg::ModelLoadCell*)this->mod;
-
- // Is it a request to set the voltage?
- if(Message::MatchMessage(hdr, PLAYER_MSGTYPE_REQ,
- PLAYER_AIO_CMD_STATE,
- this->addr))
- {
- player_aio_cmd* cmd = (player_aio_cmd*)data;
- PRINT_WARN2( "Got request to set AIO voltage %d to %f. Should not happen, AIO currently only works for load cells!\n", cmd->id, cmd->voltage );
- }
- return -1;
-}
View
37 libstageplugin/p_dio.cc
@@ -1,37 +0,0 @@
-#include "p_driver.h"
-
-
-InterfaceDio::InterfaceDio(player_devaddr_t addr, StgDriver* driver, ConfigFile* cf, int section)
- : InterfaceModel( addr, driver, cf, section, Stg::MODEL_TYPE_LIGHTINDICATOR )
-{
-}
-
-
-InterfaceDio::~InterfaceDio()
-{
-}
-
-
-int InterfaceDio::ProcessMessage(QueuePointer & resp_queue, player_msghdr_t* hdr, void* data)
-{
- Stg::ModelLightIndicator* mod = (Stg::ModelLightIndicator*) this->mod;
-
- if (Message::MatchMessage(hdr, PLAYER_MSGTYPE_CMD, PLAYER_DIO_CMD_VALUES, this->addr))
- {
- player_dio_cmd* cmd = (player_dio_cmd*) data;
- if(cmd->count != 1)
- {
- PRINT_ERR("Invalid light indicator command.");
- }
-
- mod->SetState(cmd->digout != 0);
- return 0;
- }
-
- return -1;
-}
-
-void InterfaceDio::Publish()
-{
-
-}
View
1 worlds/fasr.world
@@ -58,6 +58,7 @@ zone
ctrl "sink"
)
+
define charging_bump model
(
pose [0.240 0 -0.100 0 ]

0 comments on commit 5a63ae0

Please sign in to comment.
Something went wrong with that request. Please try again.