Revision: 6929
http://playerstage.svn.sourceforge.net/playerstage/?rev=6929&view=rev
Author: jeremy_asher
Date: 2008-07-25 23:17:00 +0000 (Fri, 25 Jul 2008)
Log Message:
-----------
stage: changed blobfinder visualization to rotate to face screen, fixed up
other code with the same functionality
Modified Paths:
--------------
code/stage/trunk/libstage/canvas.cc
code/stage/trunk/libstage/model.cc
code/stage/trunk/libstage/model_blinkenlight.cc
code/stage/trunk/libstage/model_blobfinder.cc
code/stage/trunk/libstage/model_camera.cc
code/stage/trunk/libstage/model_fiducial.cc
code/stage/trunk/libstage/model_laser.cc
code/stage/trunk/libstage/model_ranger.cc
code/stage/trunk/libstage/stage.hh
code/stage/trunk/libstageplugin/p_driver.cc
Modified: code/stage/trunk/libstage/canvas.cc
===================================================================
--- code/stage/trunk/libstage/canvas.cc 2008-07-25 21:53:39 UTC (rev 6928)
+++ code/stage/trunk/libstage/canvas.cc 2008-07-25 23:17:00 UTC (rev 6929)
@@ -663,14 +663,14 @@
if( showData ) {
if ( visualizeAll ) {
for( GList* it = world->StgWorld::children; it;
it=it->next )
- ((StgModel*)it->data)->DataVisualizeTree();
+ ((StgModel*)it->data)->DataVisualizeTree(
current_camera );
}
else if ( selected_models ) {
for( GList* it = selected_models; it; it=it->next )
- ((StgModel*)it->data)->DataVisualizeTree();
+ ((StgModel*)it->data)->DataVisualizeTree(
current_camera );
}
else if ( last_selection ) {
- last_selection->DataVisualizeTree();
+ last_selection->DataVisualizeTree( current_camera );
}
}
@@ -698,7 +698,7 @@
//ensure two icons can't be in the exact same plane
if( camera.pitch() == 0 && !pCamOn )
glTranslatef( 0, 0, 0.1 );
- i->second->DrawStatusTree( this );
+ i->second->DrawStatusTree( current_camera );
}
glPopMatrix();
}
Modified: code/stage/trunk/libstage/model.cc
===================================================================
--- code/stage/trunk/libstage/model.cc 2008-07-25 21:53:39 UTC (rev 6928)
+++ code/stage/trunk/libstage/model.cc 2008-07-25 23:17:00 UTC (rev 6929)
@@ -1001,21 +1001,21 @@
glPopMatrix();
}
-void StgModel::DrawStatusTree( StgCanvas* canvas )
+void StgModel::DrawStatusTree( StgCamera* cam )
{
PushLocalCoords();
- DrawStatus( canvas );
- LISTMETHODARG( children, StgModel*, DrawStatusTree, canvas );
+ DrawStatus( cam );
+ LISTMETHODARG( children, StgModel*, DrawStatusTree, cam );
PopCoords();
}
-void StgModel::DrawStatus( StgCanvas* canvas )
+void StgModel::DrawStatus( StgCamera* cam )
{
if( say_string )
{
float yaw, pitch;
- pitch = - canvas->current_camera->pitch();
- yaw = - canvas->current_camera->yaw();
+ pitch = - cam->pitch();
+ yaw = - cam->yaw();
float robotAngle = -rtod(pose.a);
glPushMatrix();
@@ -1074,21 +1074,16 @@
if( stall )
{
- DrawImage( TextureManager::getInstance()._stall_texture_id,
canvas, 0.85 );
+ DrawImage( TextureManager::getInstance()._stall_texture_id,
cam, 0.85 );
}
}
-void StgModel::DrawImage( uint32_t texture_id, Stg::StgCanvas* canvas, float
alpha )
+void StgModel::DrawImage( uint32_t texture_id, Stg::StgCamera* cam, float
alpha )
{
- float stheta = dtor( canvas->current_camera->pitch() );
- float sphi = - dtor( canvas->current_camera->yaw() );
- if( canvas->pCamOn == true ) {
- sphi = atan2(
- ( pose.x -
canvas->current_camera->x() )
- ,
- ( pose.y -
canvas->current_camera->y() )
- );
- }
+ float yaw, pitch;
+ pitch = - cam->pitch();
+ yaw = - cam->yaw();
+ float robotAngle = -rtod(pose.a);
glEnable(GL_TEXTURE_2D);
glBindTexture( GL_TEXTURE_2D, texture_id );
@@ -1098,14 +1093,10 @@
glTranslatef( 0.0, 0.0, 0.75 );
- //orient 2d sprites to face the camera (left-right)
- float a = rtod( sphi + pose.a );
- glRotatef( -a, 0.0, 0.0, 1.0 );
+ // rotate to face screen
+ glRotatef( robotAngle - yaw, 0,0,1 );
+ glRotatef( -pitch - 90, 1,0,0 );
- //orient to face camera (from top-front)
- a = rtod( stheta );
- glRotatef( -(90.0-a), 1.0, 0.0, 0.0 );
-
//draw a square, with the textured image
glBegin(GL_QUADS);
glTexCoord2f(0.0f, 0.0f); glVertex3f(-0.25f, 0, -0.25f );
@@ -1222,18 +1213,18 @@
PopCoords();
}
-void StgModel::DataVisualize( void )
+void StgModel::DataVisualize( StgCamera* cam )
{
// do nothing
}
-void StgModel::DataVisualizeTree( void )
+void StgModel::DataVisualizeTree( StgCamera* cam )
{
PushLocalCoords();
- DataVisualize(); // virtual function overridden by most model types
+ DataVisualize( cam ); // virtual function overridden by most model types
// and draw the children
- LISTMETHOD( children, StgModel*, DataVisualizeTree );
+ LISTMETHODARG( children, StgModel*, DataVisualizeTree, cam );
PopCoords();
}
Modified: code/stage/trunk/libstage/model_blinkenlight.cc
===================================================================
--- code/stage/trunk/libstage/model_blinkenlight.cc 2008-07-25 21:53:39 UTC
(rev 6928)
+++ code/stage/trunk/libstage/model_blinkenlight.cc 2008-07-25 23:17:00 UTC
(rev 6929)
@@ -106,7 +106,7 @@
}
-void StgModelBlinkenlight::DataVisualize()
+void StgModelBlinkenlight::DataVisualize( StgCamera* cam )
{
if( on && showBlinkenData )
{
Modified: code/stage/trunk/libstage/model_blobfinder.cc
===================================================================
--- code/stage/trunk/libstage/model_blobfinder.cc 2008-07-25 21:53:39 UTC
(rev 6928)
+++ code/stage/trunk/libstage/model_blobfinder.cc 2008-07-25 23:17:00 UTC
(rev 6929)
@@ -295,7 +295,7 @@
StgModel::Shutdown();
}
-void StgModelBlobfinder::DataVisualize( void )
+void StgModelBlobfinder::DataVisualize( StgCamera* cam )
{
if ( !showBlobData )
return;
@@ -330,8 +330,16 @@
glRotatef( rtod(-gpose.a),0,0,1 );
// place the "screen" a little away from the robot
- glTranslatef( -3.0, -2.0, 1.0 );
-
+ glTranslatef( -2.5, -1.5, 0.5 );
+
+ // rotate to face screen
+ float yaw, pitch;
+ pitch = - cam->pitch();
+ yaw = - cam->yaw();
+ float robotAngle = -rtod(pose.a);
+ glRotatef( robotAngle - yaw, 0,0,1 );
+ glRotatef( -pitch, 1,0,0 );
+
// convert blob pixels to meters scale - arbitrary
glScalef( 0.025, 0.025, 1 );
Modified: code/stage/trunk/libstage/model_camera.cc
===================================================================
--- code/stage/trunk/libstage/model_camera.cc 2008-07-25 21:53:39 UTC (rev
6928)
+++ code/stage/trunk/libstage/model_camera.cc 2008-07-25 23:17:00 UTC (rev
6929)
@@ -235,7 +235,7 @@
}
//TODO create lines outlining camera frustrum, then iterate over each depth
measurement and create a square
-void StgModelCamera::DataVisualize( void )
+void StgModelCamera::DataVisualize( StgCamera* cam )
{
if( _frame_data == NULL || !showCameraData )
Modified: code/stage/trunk/libstage/model_fiducial.cc
===================================================================
--- code/stage/trunk/libstage/model_fiducial.cc 2008-07-25 21:53:39 UTC (rev
6928)
+++ code/stage/trunk/libstage/model_fiducial.cc 2008-07-25 23:17:00 UTC (rev
6929)
@@ -248,7 +248,7 @@
}
-void StgModelFiducial::DataVisualize()
+void StgModelFiducial::DataVisualize( StgCamera* cam )
{
if ( !showFiducialData )
return;
Modified: code/stage/trunk/libstage/model_laser.cc
===================================================================
--- code/stage/trunk/libstage/model_laser.cc 2008-07-25 21:53:39 UTC (rev
6928)
+++ code/stage/trunk/libstage/model_laser.cc 2008-07-25 23:17:00 UTC (rev
6929)
@@ -301,7 +301,7 @@
}
-void StgModelLaser::DataVisualize( void )
+void StgModelLaser::DataVisualize( StgCamera* cam )
{
if( ! (samples && sample_count) )
return;
Modified: code/stage/trunk/libstage/model_ranger.cc
===================================================================
--- code/stage/trunk/libstage/model_ranger.cc 2008-07-25 21:53:39 UTC (rev
6928)
+++ code/stage/trunk/libstage/model_ranger.cc 2008-07-25 23:17:00 UTC (rev
6929)
@@ -321,7 +321,7 @@
puts( " ]" );
}
-void StgModelRanger::DataVisualize( void )
+void StgModelRanger::DataVisualize( StgCamera* cam )
{
if( ! (samples && sensors && sensor_count) )
return;
Modified: code/stage/trunk/libstage/stage.hh
===================================================================
--- code/stage/trunk/libstage/stage.hh 2008-07-25 21:53:39 UTC (rev 6928)
+++ code/stage/trunk/libstage/stage.hh 2008-07-25 23:17:00 UTC (rev 6929)
@@ -79,6 +79,7 @@
class StgModel;
class FileManager;
class OptionsDlg;
+ class StgCamera;
/** Initialize the Stage library */
void Init( int* argc, char** argv[] );
@@ -1296,8 +1297,8 @@
void DrawBlocksTree();
virtual void DrawBlocks();
- virtual void DrawStatus( StgCanvas* canvas );
- void DrawStatusTree( StgCanvas* canvas );
+ virtual void DrawStatus( StgCamera* cam );
+ void DrawStatusTree( StgCamera* cam );
void DrawOriginTree();
void DrawOrigin();
@@ -1306,7 +1307,7 @@
void PopCoords();
///Draw the image stored in texture_id above the model
- void DrawImage( uint32_t texture_id, Stg::StgCanvas* canvas, float
alpha );
+ void DrawImage( uint32_t texture_id, Stg::StgCamera* cam, float alpha );
// static wrapper for DrawBlocks()
@@ -1315,7 +1316,7 @@
void* arg );
virtual void DrawPicker();
- virtual void DataVisualize();
+ virtual void DataVisualize( StgCamera* cam );
virtual void DrawSelected(void);
@@ -1348,7 +1349,7 @@
stg_model_type_t type;
static const char* typestr;
- void DataVisualizeTree();
+ void DataVisualizeTree( StgCamera* cam );
virtual void PushColor( stg_color_t col )
{ world->PushColor( col ); }
@@ -2071,7 +2072,7 @@
static Option showBlobData;
- virtual void DataVisualize();
+ virtual void DataVisualize( StgCamera* cam );
public:
unsigned int scan_width;
@@ -2203,7 +2204,7 @@
virtual void Update();
virtual void Load();
virtual void Print( char* prefix );
- virtual void DataVisualize();
+ virtual void DataVisualize( StgCamera* cam );
uint32_t GetSampleCount(){ return sample_count; }
@@ -2352,10 +2353,10 @@
// static wrapper function can be used as a function pointer
static int AddModelIfVisibleStatic( StgModel* him,
StgModelFiducial* me )
- { if( him != me ) me->AddModelIfVisible( him ); };
+ { if( him != me ) me->AddModelIfVisible( him ); return
0; }
virtual void Update();
- virtual void DataVisualize();
+ virtual void DataVisualize( StgCamera* cam );
GArray* data;
@@ -2403,7 +2404,7 @@
virtual void Startup();
virtual void Shutdown();
virtual void Update();
- virtual void DataVisualize();
+ virtual void DataVisualize( StgCamera* cam );
public:
static const char* typestr;
@@ -2446,7 +2447,7 @@
virtual void Load();
virtual void Update();
- virtual void DataVisualize();
+ virtual void DataVisualize( StgCamera* cam );
};
// CAMERA MODEL ----------------------------------------------------
@@ -2499,7 +2500,7 @@
//virtual void Draw( uint32_t flags, StgCanvas* canvas );
///Draw camera visualization
- virtual void DataVisualize();
+ virtual void DataVisualize( StgCamera* cam );
///width of captured image
inline int getWidth( void ) const { return _width; }
Modified: code/stage/trunk/libstageplugin/p_driver.cc
===================================================================
--- code/stage/trunk/libstageplugin/p_driver.cc 2008-07-25 21:53:39 UTC (rev
6928)
+++ code/stage/trunk/libstageplugin/p_driver.cc 2008-07-25 23:17:00 UTC (rev
6929)
@@ -333,8 +333,21 @@
case PLAYER_SPEECH_CODE:
ifsrc = new InterfaceSpeech( player_addr, this, cf, section );
- break;
+ break;
+ // case PLAYER_CAMERA_CODE:
+ // ifsrc = new InterfaceCamera( player_addr, this, cf, section
);
+ // break;
+
+ // case PLAYER_GRAPHICS2D_CODE:
+ // ifsrc = new InterfaceGraphics2d( player_addr, this, cf,
section );
+ // break;
+
+ // case PLAYER_GRAPHICS3D_CODE:
+ // ifsrc = new InterfaceGraphics3d( player_addr, this,
cf, section );
+ // break;
+
+
// case PLAYER_LOCALIZE_CODE:
// ifsrc = new InterfaceLocalize( player_addr, this, cf, section );
@@ -343,15 +356,7 @@
// case PLAYER_MAP_CODE:
// ifsrc = new InterfaceMap( player_addr, this, cf, section );
// break;
-
-// case PLAYER_GRAPHICS2D_CODE:
-// ifsrc = new InterfaceGraphics2d( player_addr, this, cf, section );
-// break;
-
-// case PLAYER_GRAPHICS3D_CODE:
- // ifsrc = new InterfaceGraphics3d( player_addr, this, cf, section
);
- //break;
-
+
// case PLAYER_GRIPPER_CODE:
// ifsrc = new InterfaceGripper( player_addr, this, cf, section );
// break;
@@ -359,10 +364,6 @@
// case PLAYER_WIFI_CODE:
// ifsrc = new InterfaceWifi( player_addr, this, cf, section );
// break;
-
-// case PLAYER_CAMERA_CODE:
-// ifsrc = new InterfaceCamera( player_addr, this, cf, section );
-// break;
// case PLAYER_POWER_CODE:
// ifsrc = new InterfacePower( player_addr, this, cf, section );
This was sent by the SourceForge.net collaborative development platform, the
world's largest Open Source development site.
-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
Playerstage-commit mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/playerstage-commit