From: <jer...@us...> - 2008-07-02 15:14:05
|
Revision: 6743 http://playerstage.svn.sourceforge.net/playerstage/?rev=6743&view=rev Author: jeremy_asher Date: 2008-07-02 15:14:14 -0700 (Wed, 02 Jul 2008) Log Message: ----------- Returned perspective cam option, reorganized view hotkeys Modified Paths: -------------- code/stage/trunk/libstage/canvas.cc code/stage/trunk/libstage/stage.hh Modified: code/stage/trunk/libstage/canvas.cc =================================================================== --- code/stage/trunk/libstage/canvas.cc 2008-07-02 21:41:39 UTC (rev 6742) +++ code/stage/trunk/libstage/canvas.cc 2008-07-02 22:14:14 UTC (rev 6743) @@ -40,18 +40,19 @@ showBlocks( "Blocks", "show_blocks", "b", true ), showClock( "Clock", "show_clock", "c", true ), showData( "Data", "show_data", "d", false ), - showFlags( "Flags", "show_flags", "f", true ), - showFollow( "Follow", "show_follow", "F", false ), - showFootprints( "Footprints", "show_footprints", "f", false ), + showFlags( "Flags", "show_flags", "l", true ), + showFollow( "Follow", "show_follow", "f", false ), + showFootprints( "Footprints", "show_footprints", "o", false ), showGrid( "Grid", "show_grid", "g", true ), - showOccupancy( "Debug/Occupancy", "show_occupancy", "#O", false ), + showOccupancy( "Debug/Occupancy", "show_occupancy", "^o", false ), showScreenshots( "Save screenshots", "screenshots", "", false ), - showStatus( "Status", "show_status", "", true ), - showTrailArrows( "Trails/Rising Arrows", "show_trailarrows", "#a", false ), - showTrailRise( "Trails/Rising blocks", "show_trailrise", "#r", false ), - showTrails( "Trails/Fast", "show_trailfast", "t", false ), - showTree( "Debug/Tree", "show_tree", "#T", false ), - visualizeAll( "Visualize All", "vis_all", "", true ) + showStatus( "Status", "show_status", "s", true ), + showTrailArrows( "Trails/Rising Arrows", "show_trailarrows", "^a", false ), + showTrailRise( "Trails/Rising blocks", "show_trailrise", "^r", false ), + showTrails( "Trails/Fast", "show_trailfast", "^f", false ), + showTree( "Debug/Tree", "show_tree", "^t", false ), + perspectiveCam( "Perspective camera", "show_perspective", "r", false ), + visualizeAll( "Visualize All", "vis_all", "^v", true ) { end(); @@ -62,7 +63,6 @@ selected_models = NULL; last_selection = NULL; - use_perspective_camera = false; perspective_camera.setPose( -3.0, 0.0, 1.0 ); perspective_camera.setPitch( 70.0 ); //look down @@ -217,7 +217,7 @@ } else { - if( use_perspective_camera == true ) { + if( perspectiveCam == true ) { perspective_camera.scroll( Fl::event_dy() / 10.0 ); } else { camera.scale( Fl::event_dy(), Fl::event_x(), w(), Fl::event_y(), h() ); @@ -233,7 +233,7 @@ int dx = Fl::event_x() - startx; int dy = Fl::event_y() - starty; - if( use_perspective_camera == true ) { + if( perspectiveCam == true ) { perspective_camera.addYaw( -dx ); perspective_camera.addPitch( -dy ); } else { @@ -249,7 +249,7 @@ int dx = Fl::event_x() - startx; int dy = Fl::event_y() - starty; - if( use_perspective_camera == true ) { + if( perspectiveCam == true ) { perspective_camera.move( -dx, dy, 0.0 ); } else { camera.move( -dx, dy ); @@ -372,16 +372,16 @@ redraw(); break; case FL_Left: - if( use_perspective_camera == false ) { camera.move( -10, 0 ); } + if( perspectiveCam == false ) { camera.move( -10, 0 ); } else { perspective_camera.strafe( -0.5 ); } break; case FL_Right: - if( use_perspective_camera == false ) {camera.move( 10, 0 ); } + if( perspectiveCam == false ) {camera.move( 10, 0 ); } else { perspective_camera.strafe( 0.5 ); } break; case FL_Down: - if( use_perspective_camera == false ) {camera.move( 0, -10 ); } + if( perspectiveCam == false ) {camera.move( 0, -10 ); } else { perspective_camera.forward( -0.5 ); } break; case FL_Up: - if( use_perspective_camera == false ) {camera.move( 0, 10 ); } + if( perspectiveCam == false ) {camera.move( 0, 10 ); } else { perspective_camera.forward( 0.5 ); } break; default: return 0; // keypress unhandled @@ -744,6 +744,7 @@ showFootprints.CreateMenuItem( menu, path ); showGrid.CreateMenuItem( menu, path ); showStatus.CreateMenuItem( menu, path ); + perspectiveCam.CreateMenuItem( menu, path ); showOccupancy.CreateMenuItem( menu, path ); showTrailArrows.CreateMenuItem( menu, path ); showTrails.CreateMenuItem( menu, path ); @@ -817,7 +818,7 @@ static bool loaded_texture = false; //Enable the following to debug camera model - // if( loaded_texture == true && use_perspective_camera == true ) + // if( loaded_texture == true && perspectiveCam == true ) // return; if (!valid() ) @@ -888,7 +889,7 @@ // install a font gl_font( FL_HELVETICA, 12 ); - if( use_perspective_camera == true ) { + if( perspectiveCam == true ) { perspective_camera.setAspect( static_cast< float >( w() ) / static_cast< float >( h() ) ); perspective_camera.SetProjection(); } else { @@ -905,7 +906,7 @@ } - if( use_perspective_camera == true ) { + if( perspectiveCam == true ) { if( showFollow && last_selection ) { //Follow the selected robot stg_pose_t gpose = last_selection->GetGlobalPose(); Modified: code/stage/trunk/libstage/stage.hh =================================================================== --- code/stage/trunk/libstage/stage.hh 2008-07-02 21:41:39 UTC (rev 6742) +++ code/stage/trunk/libstage/stage.hh 2008-07-02 22:14:14 UTC (rev 6743) @@ -1915,7 +1915,6 @@ StgOrthoCamera camera; StgPerspectiveCamera perspective_camera; - bool use_perspective_camera; int startx, starty; bool dragging; @@ -1949,6 +1948,7 @@ showTrailRise, showTrails, showTree, + perspectiveCam, visualizeAll; public: This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jer...@us...> - 2008-07-02 17:02:24
|
Revision: 6745 http://playerstage.svn.sourceforge.net/playerstage/?rev=6745&view=rev Author: jeremy_asher Date: 2008-07-02 17:02:27 -0700 (Wed, 02 Jul 2008) Log Message: ----------- Fixed warnings Modified Paths: -------------- code/stage/trunk/libstage/model.cc code/stage/trunk/libstage/model_blobfinder.cc code/stage/trunk/libstage/model_camera.cc code/stage/trunk/libstage/model_laser.cc code/stage/trunk/libstage/model_load.cc code/stage/trunk/libstage/stage.hh code/stage/trunk/libstage/world.cc Modified: code/stage/trunk/libstage/model.cc =================================================================== --- code/stage/trunk/libstage/model.cc 2008-07-02 23:42:25 UTC (rev 6744) +++ code/stage/trunk/libstage/model.cc 2008-07-03 00:02:27 UTC (rev 6745) @@ -101,7 +101,9 @@ - friction). */ +#ifndef _GNU_SOURCE #define _GNU_SOURCE +#endif //#define DEBUG 0 #include "stage_internal.hh" Modified: code/stage/trunk/libstage/model_blobfinder.cc =================================================================== --- code/stage/trunk/libstage/model_blobfinder.cc 2008-07-02 23:42:25 UTC (rev 6744) +++ code/stage/trunk/libstage/model_blobfinder.cc 2008-07-03 00:02:27 UTC (rev 6745) @@ -162,7 +162,7 @@ { RemoveAllColors(); // empty the color list to start from scratch - unsigned int count = wf->ReadFloat( wf_entity, "colors_count", 0 ); + unsigned int count = wf->ReadInt( wf_entity, "colors_count", 0 ); for( unsigned int c=0; c<count; c++ ) { Modified: code/stage/trunk/libstage/model_camera.cc =================================================================== --- code/stage/trunk/libstage/model_camera.cc 2008-07-02 23:42:25 UTC (rev 6744) +++ code/stage/trunk/libstage/model_camera.cc 2008-07-03 00:02:27 UTC (rev 6745) @@ -96,9 +96,9 @@ _camera.setClip( wf->ReadLength( wf_entity, "nearclip", _camera.nearClip() ), wf->ReadLength( wf_entity, "farclip", CAMERA_FAR_CLIP ) ); - _yaw_offset = wf->ReadLength( wf_entity, "yaw", _yaw_offset ); - _width = wf->ReadLength( wf_entity, "width", _width ); - _height = wf->ReadLength( wf_entity, "height", _height ); + _yaw_offset = wf->ReadInt( wf_entity, "yaw", _yaw_offset ); + _width = wf->ReadInt( wf_entity, "width", _width ); + _height = wf->ReadInt( wf_entity, "height", _height ); } Modified: code/stage/trunk/libstage/model_laser.cc =================================================================== --- code/stage/trunk/libstage/model_laser.cc 2008-07-02 23:42:25 UTC (rev 6744) +++ code/stage/trunk/libstage/model_laser.cc 2008-07-03 00:02:27 UTC (rev 6745) @@ -83,7 +83,7 @@ id, typestr ); // sensible laser defaults - interval = DEFAULT_INTERVAL_MS * thousand; + interval = DEFAULT_INTERVAL_MS * (int)thousand; laser_return = LaserVisible; stg_geom_t geom; Modified: code/stage/trunk/libstage/model_load.cc =================================================================== --- code/stage/trunk/libstage/model_load.cc 2008-07-02 23:42:25 UTC (rev 6744) +++ code/stage/trunk/libstage/model_load.cc 2008-07-03 00:02:27 UTC (rev 6745) @@ -1,4 +1,6 @@ +#ifndef _GNU_SOURCE #define _GNU_SOURCE +#endif #include <limits.h> #include <libgen.h> // for dirname() #include <string.h> Modified: code/stage/trunk/libstage/stage.hh =================================================================== --- code/stage/trunk/libstage/stage.hh 2008-07-02 23:42:25 UTC (rev 6744) +++ code/stage/trunk/libstage/stage.hh 2008-07-03 00:02:27 UTC (rev 6745) @@ -2451,7 +2451,7 @@ private: double dutycycle; bool enabled; - double period; + stg_msec_t period; bool on; static Option showBlinkenData; Modified: code/stage/trunk/libstage/world.cc =================================================================== --- code/stage/trunk/libstage/world.cc 2008-07-02 23:42:25 UTC (rev 6744) +++ code/stage/trunk/libstage/world.cc 2008-07-03 00:02:27 UTC (rev 6745) @@ -39,7 +39,9 @@ */ +#ifndef _GNU_SOURCE #define _GNU_SOURCE +#endif //#define DEBUG This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <al...@us...> - 2008-07-02 17:26:59
|
Revision: 6746 http://playerstage.svn.sourceforge.net/playerstage/?rev=6746&view=rev Author: alexcb Date: 2008-07-02 17:27:06 -0700 (Wed, 02 Jul 2008) Log Message: ----------- reset camera now centers world and scales to display everything Modified Paths: -------------- code/stage/trunk/libstage/canvas.cc code/stage/trunk/libstage/stage.hh Modified: code/stage/trunk/libstage/canvas.cc =================================================================== --- code/stage/trunk/libstage/canvas.cc 2008-07-03 00:02:27 UTC (rev 6745) +++ code/stage/trunk/libstage/canvas.cc 2008-07-03 00:27:06 UTC (rev 6746) @@ -365,9 +365,7 @@ camera.resetAngle(); //invalidate(); if( Fl::event_state( FL_CTRL ) ) { - //do a complete reset - camera.setPose( 0.0, 0.0 ); - camera.setScale( 10.0 ); + resetCamera(); } redraw(); break; @@ -478,6 +476,36 @@ LISTMETHOD( world->StgWorld::children, StgModel*, DrawBlocksTree ); } +void StgCanvas::resetCamera() +{ + float max_x = 0, max_y = 0, min_x = 0, min_y = 0; + + //TODO take orrientation ( `a' ) and geom.pose offset into consideration + for( GList* it=world->StgWorld::children; it; it=it->next ) { + StgModel* ptr = (StgModel*) it->data; + stg_pose_t pose = ptr->GetPose(); + stg_geom_t geom = ptr->GetGeom(); + + float tmp_min_x = pose.x - geom.size.x / 2.0; + float tmp_max_x = pose.x + geom.size.x / 2.0; + float tmp_min_y = pose.y - geom.size.y / 2.0; + float tmp_max_y = pose.y + geom.size.y / 2.0; + + if( tmp_min_x < min_x ) min_x = tmp_min_x; + if( tmp_max_x > max_x ) max_x = tmp_max_x; + if( tmp_min_y < min_y ) min_y = tmp_min_y; + if( tmp_max_y > max_y ) max_y = tmp_max_y; + } + + //do a complete reset + float x = ( min_x + max_x ) / 2.0; + float y = ( min_y + max_y ) / 2.0; + camera.setPose( x, y ); + float scale_x = w() / (max_x - min_x) * 0.9; + float scale_y = h() / (max_y - min_y) * 0.9; + camera.setScale( scale_x < scale_y ? scale_x : scale_y ); +} + void StgCanvas::renderFrame() { //before drawing, order all models based on distance from camera Modified: code/stage/trunk/libstage/stage.hh =================================================================== --- code/stage/trunk/libstage/stage.hh 2008-07-03 00:02:27 UTC (rev 6745) +++ code/stage/trunk/libstage/stage.hh 2008-07-03 00:27:06 UTC (rev 6746) @@ -1966,6 +1966,7 @@ void FixViewport(int W,int H); void DrawFloor(); //simpler floor compared to grid void DrawBlocks(); + void resetCamera(); virtual void renderFrame(); virtual void draw(); virtual int handle( int event ); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <al...@us...> - 2008-07-03 13:16:09
|
Revision: 6748 http://playerstage.svn.sourceforge.net/playerstage/?rev=6748&view=rev Author: alexcb Date: 2008-07-03 13:16:15 -0700 (Thu, 03 Jul 2008) Log Message: ----------- worked on panning and tilting camera and documentation Modified Paths: -------------- code/stage/trunk/libstage/model_camera.cc code/stage/trunk/libstage/stage.hh Modified: code/stage/trunk/libstage/model_camera.cc =================================================================== --- code/stage/trunk/libstage/model_camera.cc 2008-07-03 02:26:35 UTC (rev 6747) +++ code/stage/trunk/libstage/model_camera.cc 2008-07-03 20:16:15 UTC (rev 6748) @@ -9,6 +9,7 @@ /////////////////////////////////////////////////////////////////////////// #define CAMERA_HEIGHT 0.5 +#define CAMERA_NEAR_CLIP 0.2 #define CAMERA_FAR_CLIP 8.0 //#define DEBUG 1 @@ -18,6 +19,56 @@ Option StgModelCamera::showCameraData( "Show Camera Data", "show_camera", "", true ); +/** + @ingroup model + @defgroup model_camera Camera model + The camera model simulates a camera + + API: Stg::StgModelCamera + + <h2>Worldfile properties</h2> + + @par Summary and default values + + @verbatim + camera + ( + # laser properties + width 32 + height 32 + range_min 0.0 + range_max 8.0 + horizfov 60.0 + vertfov 60.0 + yaw 0.0 + pitch 90.0 + + # model properties + size [0.15 0.15] + color "black" + watts 100.0 # TODO find watts for sony pan-tilt camera + ) + @endverbatim + + @par Details + - width int + - the number of pixel samples + - height int + - the number of pixel samples + - range_min float + - the minimum range reported by the camera, in meters. Objects closer than this will not be displayed. The smaller the number, the less persision in depth - don't set this value too close to 0. + - range_max float + - the maximum range reported by the camera, in meters. Objects farther than this will not be displayed. + - horizfov float + - angle, in degrees, for the horizontal field of view. + - vertfov float + - angle, in degrees, for the vertical field of view. + - yaw float + - angle, in degrees, where the camera is panned to. + - pitch float + - angle, in degrees, where the camera is tilted to. + */ + //caclulate the corss product, and store results in the first vertex void cross( float& x1, float& y1, float& z1, float x2, float y2, float z2 ) { @@ -40,13 +91,14 @@ _frame_color_data( NULL ), _valid_vertexbuf_cache( false ), _vertexbuf_cache( NULL ), -_width( 0 ), -_height( 0 ), +_width( 32 ), +_height( 32 ), _camera_quads_size( 0 ), _camera_quads( NULL ), _camera_colors( NULL ), _camera(), -_yaw_offset( 0 ) +_yaw_offset( 0.0 ), +_pitch_offset( 0.0 ) { PRINT_DEBUG2( "Constructing StgModelCamera %d (%s)\n", @@ -62,7 +114,8 @@ _canvas = world_gui->GetCanvas(); // Set up sensible defaults - + _camera.setPitch( 90.0 ); + SetColor( stg_lookup_color( "green" ) ); stg_geom_t geom; @@ -92,11 +145,11 @@ StgModel::Load(); _camera.setFov( wf->ReadLength( wf_entity, "horizfov", _camera.horizFov() ), wf->ReadLength( wf_entity, "vertfov", _camera.vertFov() ) ); - _camera.setPitch( wf->ReadLength( wf_entity, "pitch", _camera.pitch() ) ); - _camera.setClip( wf->ReadLength( wf_entity, "nearclip", _camera.nearClip() ), wf->ReadLength( wf_entity, "farclip", CAMERA_FAR_CLIP ) ); + _camera.setClip( wf->ReadLength( wf_entity, "range_min", CAMERA_NEAR_CLIP ), wf->ReadLength( wf_entity, "range_max", CAMERA_FAR_CLIP ) ); - _yaw_offset = wf->ReadInt( wf_entity, "yaw", _yaw_offset ); + _yaw_offset = wf->ReadFloat( wf_entity, "yaw", _yaw_offset ); + _pitch_offset = wf->ReadFloat( wf_entity, "pitch", _pitch_offset ); _width = wf->ReadInt( wf_entity, "width", _width ); _height = wf->ReadInt( wf_entity, "height", _height ); } @@ -106,6 +159,10 @@ { GetFrame(); StgModel::Update(); + static float y = 0; + y += 0.1; +// setYaw( y ); + setPitch( y ); } bool StgModelCamera::GetFrame( void ) @@ -148,6 +205,7 @@ //TODO reposition the camera so it isn't inside the model ( or don't draw the parent when calling renderframe ) _camera.setPose( parent->GetGlobalPose().x, parent->GetGlobalPose().y, CAMERA_HEIGHT ); //TODO use something smarter than a #define - make it configurable _camera.setYaw( rtod( parent->GetGlobalPose().a ) - 90.0 - _yaw_offset ); //-90.0 points the camera infront of the robot instead of pointing right + _camera.setPitch( 90.0 - _pitch_offset ); _camera.Draw(); @@ -183,14 +241,14 @@ { if( _frame_data == NULL || !showCameraData ) return; - + // TODO - shift to global CS? float w_fov = _camera.horizFov(); float h_fov = _camera.vertFov(); float center_horiz = - _yaw_offset; - float center_vert = 0; // - _pitch_offset; + float center_vert = - _pitch_offset; float start_fov = center_horiz + w_fov / 2.0 + 180.0; //start at right float start_vert_fov = center_vert + h_fov / 2.0 + 90.0; //start at top @@ -263,6 +321,7 @@ } } + glEnableClientState( GL_VERTEX_ARRAY ); glEnableClientState( GL_COLOR_ARRAY ); @@ -272,23 +331,8 @@ glDrawArrays( GL_QUADS, 0, w * h * 4 ); glDisableClientState( GL_COLOR_ARRAY ); - glDisableClientState( GL_VERTEX_ARRAY ); +// glDisableClientState( GL_VERTEX_ARRAY ); //TODO FIXME - something is using vertex arrays without properly enabling it - -// glEnd(); - glEnable(GL_CULL_FACE); - - - //TODO see if any of this can be used for the new method - //TODO: below this point may no longer be needed if we just draw perfectly square quads based off normal -// //draw then camera data -// glDisable (GL_CULL_FACE); -// glPushClientAttrib( GL_CLIENT_VERTEX_ARRAY_BIT ); -// glPolygonMode( GL_FRONT_AND_BACK, GL_FILL ); //Can also be GL_FILL - but harder to debug -// glInterleavedArrays( GL_C4UB_V3F, 0, vertices ); -// glDrawElements( GL_QUADS, 4 * w * h, GL_UNSIGNED_SHORT, vertices_index ); -// glPopClientAttrib(); -// } void StgModelCamera::Draw( uint32_t flags, StgCanvas* canvas ) Modified: code/stage/trunk/libstage/stage.hh =================================================================== --- code/stage/trunk/libstage/stage.hh 2008-07-03 02:26:35 UTC (rev 6747) +++ code/stage/trunk/libstage/stage.hh 2008-07-03 20:16:15 UTC (rev 6748) @@ -2497,7 +2497,8 @@ static Option showCameraData; StgPerspectiveCamera _camera; - int _yaw_offset; //position camera is mounted at + float _yaw_offset; //position camera is mounted at + float _pitch_offset; ///Take a screenshot from the camera's perspective. return: true for sucess, and data is available via FrameDepth() / FrameColor() bool GetFrame(); @@ -2533,6 +2534,12 @@ ///get a reference to camera color image. 3 bytes (RGB) per pixel inline const GLubyte* FrameColor() const { return _frame_color_data; } + + ///change the pitch + inline void setPitch( float pitch ) { _pitch_offset = pitch; _valid_vertexbuf_cache = false; } + + ///change the yaw + inline void setYaw( float yaw ) { _yaw_offset = yaw; _valid_vertexbuf_cache = false; } }; // POSITION MODEL -------------------------------------------------------- This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jer...@us...> - 2008-07-03 14:09:26
|
Revision: 6750 http://playerstage.svn.sourceforge.net/playerstage/?rev=6750&view=rev Author: jeremy_asher Date: 2008-07-03 14:09:25 -0700 (Thu, 03 Jul 2008) Log Message: ----------- Fixed Option loading not updating menu Modified Paths: -------------- code/stage/trunk/libstage/canvas.cc code/stage/trunk/libstage/option.cc code/stage/trunk/libstage/option.hh code/stage/trunk/libstage/options_dlg.cc code/stage/trunk/libstage/stage.hh code/stage/trunk/libstage/worldgui.cc Modified: code/stage/trunk/libstage/canvas.cc =================================================================== --- code/stage/trunk/libstage/canvas.cc 2008-07-03 20:22:14 UTC (rev 6749) +++ code/stage/trunk/libstage/canvas.cc 2008-07-03 21:09:25 UTC (rev 6750) @@ -760,25 +760,25 @@ } -void StgCanvas::CreateMenuItems( Fl_Menu_Bar* menu, std::string path ) +void StgCanvas::createMenuItems( Fl_Menu_Bar* menu, std::string path ) { - showData.CreateMenuItem( menu, path ); -// visualizeAll.CreateMenuItem( menu, path ); - showBlocks.CreateMenuItem( menu, path ); - showFlags.CreateMenuItem( menu, path ); - showClock.CreateMenuItem( menu, path ); - showFlags.CreateMenuItem( menu, path ); - showFollow.CreateMenuItem( menu, path ); - showFootprints.CreateMenuItem( menu, path ); - showGrid.CreateMenuItem( menu, path ); - showStatus.CreateMenuItem( menu, path ); - perspectiveCam.CreateMenuItem( menu, path ); - showOccupancy.CreateMenuItem( menu, path ); - showTrailArrows.CreateMenuItem( menu, path ); - showTrails.CreateMenuItem( menu, path ); - showTrailRise.CreateMenuItem( menu, path ); - showTree.CreateMenuItem( menu, path ); - showScreenshots.CreateMenuItem( menu, path ); + showData.createMenuItem( menu, path ); +// visualizeAll.createMenuItem( menu, path ); + showBlocks.createMenuItem( menu, path ); + showFlags.createMenuItem( menu, path ); + showClock.createMenuItem( menu, path ); + showFlags.createMenuItem( menu, path ); + showFollow.createMenuItem( menu, path ); + showFootprints.createMenuItem( menu, path ); + showGrid.createMenuItem( menu, path ); + showStatus.createMenuItem( menu, path ); + perspectiveCam.createMenuItem( menu, path ); + showOccupancy.createMenuItem( menu, path ); + showTrailArrows.createMenuItem( menu, path ); + showTrails.createMenuItem( menu, path ); + showTrailRise.createMenuItem( menu, path ); + showTree.createMenuItem( menu, path ); + showScreenshots.createMenuItem( menu, path ); } Modified: code/stage/trunk/libstage/option.cc =================================================================== --- code/stage/trunk/libstage/option.cc 2008-07-03 20:22:14 UTC (rev 6749) +++ code/stage/trunk/libstage/option.cc 2008-07-03 21:09:25 UTC (rev 6750) @@ -8,7 +8,8 @@ value( v ), wf_token( tok ), shortcut( key ), -menu_item( NULL ) +menu( NULL ), +menuIndex( -1 ) { } Option::Option( const Option& o ) : @@ -16,13 +17,14 @@ value( o.value ), wf_token( o.wf_token ), shortcut( o.shortcut ), -menu_item( o.menu_item ) +menu( o.menu ), +menuIndex( o.menuIndex ) { } void Option::Load( Worldfile* wf, int section ) { - Set( (bool)wf->ReadInt(section, wf_token.c_str(), value )); + set( (bool)wf->ReadInt( section, wf_token.c_str(), value )); } void Option::Save( Worldfile* wf, int section ) @@ -30,32 +32,30 @@ wf->WriteInt(section, wf_token.c_str(), value ); } -void Option::CreateMenuItem( Fl_Menu_Bar* menu, std::string path ) +void toggleCb( Fl_Widget* w, void* p ) { - path = path + "/" + optName; - menu->add( path.c_str(), shortcut.c_str(), - (Fl_Callback*)ToggleCb, this, - FL_MENU_TOGGLE | (value ? FL_MENU_VALUE : 0 ) ); - - // find the menu item we just created and store it for later access - menu_item = (Fl_Menu_Item*)menu->find_item( path.c_str() ); -} - -void Option::ToggleCb( Fl_Menu_Bar* menubar, Option* opt ) -{ - opt->Invert(); + //Fl_Menu_* menu = static_cast<Fl_Menu_*>( w ); + Option* opt = static_cast<Option*>( p ); + opt->invert(); } - -void Option::Invert() +void Option::createMenuItem( Fl_Menu_Bar* m, std::string path ) { - Set( !value ); -} + menu = m; + path = path + "/" + optName; + // create a menu item and save its index + menuIndex = menu->add( path.c_str(), shortcut.c_str(), + toggleCb, this, + FL_MENU_TOGGLE | (value ? FL_MENU_VALUE : 0 ) ); +} -void Option::Set( bool val ) +void Option::set( bool val ) { - value = val; + value = val; - if( menu_item ) - value ? menu_item->set() : menu_item->clear(); + if( menu ) { + const Fl_Menu_Item* mArr = menu->menu(); + Fl_Menu_Item* item = const_cast<Fl_Menu_Item*>( &mArr[ menuIndex ] ); + value ? item->set() : item->clear(); + } } Modified: code/stage/trunk/libstage/option.hh =================================================================== --- code/stage/trunk/libstage/option.hh 2008-07-03 20:22:14 UTC (rev 6749) +++ code/stage/trunk/libstage/option.hh 2008-07-03 21:09:25 UTC (rev 6750) @@ -20,38 +20,38 @@ class Option { private: - friend bool compare( const Option* lhs, const Option* rhs ); + friend bool compare( const Option* lhs, const Option* rhs ); - std::string optName; - bool value; - /** worldfile entry string for loading and saving this value */ - std::string wf_token; - std::string shortcut; - Fl_Menu_Item* menu_item; + std::string optName; + bool value; + /** worldfile entry string for loading and saving this value */ + std::string wf_token; + std::string shortcut; + Fl_Menu_* menu; + int menuIndex; public: Option( std::string n, std::string tok, std::string key, bool v ); Option( const Option& o ); - const std::string name() const { return optName; } + const std::string name() const { return optName; } inline bool val() const { return value; } inline operator bool() { return val(); } inline bool operator<( const Option& rhs ) const { return optName<rhs.optName; } - void Set( bool val ); - void Invert(); + void set( bool val ); + void invert() { set( !value ); } - // Comparator to dereference Option pointers and compare their strings - struct optComp { - inline bool operator()( const Option* lhs, const Option* rhs ) const - { return lhs->operator<(*rhs); } - }; - - static void ToggleCb( Fl_Menu_Bar* menubar, Option* opt ); + // Comparator to dereference Option pointers and compare their strings + struct optComp { + inline bool operator()( const Option* lhs, const Option* rhs ) const + { return lhs->operator<(*rhs); } + }; - void Load( Worldfile* wf, int section ); - void Save( Worldfile* wf, int section ); - void CreateMenuItem( Fl_Menu_Bar* menu, std::string path ); + + void createMenuItem( Fl_Menu_Bar* menu, std::string path ); + void Load( Worldfile* wf, int section ); + void Save( Worldfile* wf, int section ); }; } Modified: code/stage/trunk/libstage/options_dlg.cc =================================================================== --- code/stage/trunk/libstage/options_dlg.cc 2008-07-03 20:22:14 UTC (rev 6749) +++ code/stage/trunk/libstage/options_dlg.cc 2008-07-03 21:09:25 UTC (rev 6750) @@ -36,13 +36,13 @@ if ( check == oDlg->showAllCheck && oDlg->showAll ) { oDlg->status = CHANGE_ALL; - oDlg->showAll->Set( check->value() ); + oDlg->showAll->set( check->value() ); oDlg->do_callback(); oDlg->status = NO_EVENT; } else { int item = oDlg->scroll->find( check ); - oDlg->options[ item ]->Set( check->value() ); + oDlg->options[ item ]->set( check->value() ); oDlg->changedItem = oDlg->options[ item ]; oDlg->status = CHANGE; oDlg->do_callback(); Modified: code/stage/trunk/libstage/stage.hh =================================================================== --- code/stage/trunk/libstage/stage.hh 2008-07-03 20:22:14 UTC (rev 6749) +++ code/stage/trunk/libstage/stage.hh 2008-07-03 21:09:25 UTC (rev 6750) @@ -1961,7 +1961,7 @@ void Screenshot(); - void CreateMenuItems( Fl_Menu_Bar* menu, std::string path ); + void createMenuItems( Fl_Menu_Bar* menu, std::string path ); void FixViewport(int W,int H); void DrawFloor(); //simpler floor compared to grid Modified: code/stage/trunk/libstage/worldgui.cc =================================================================== --- code/stage/trunk/libstage/worldgui.cc 2008-07-03 20:22:14 UTC (rev 6749) +++ code/stage/trunk/libstage/worldgui.cc 2008-07-03 21:09:25 UTC (rev 6750) @@ -147,7 +147,7 @@ mbar->add( "&View", 0, 0, 0, FL_SUBMENU ); mbar->add( "View/Filter data...", FL_SHIFT + 'd', StgWorldGui::viewOptionsCb, this ); - canvas->CreateMenuItems( mbar, "View" ); + canvas->createMenuItems( mbar, "View" ); mbar->add( "&Help", 0, 0, 0, FL_SUBMENU ); mbar->add( "Help/&About Stage...", 0, StgWorldGui::helpAboutCb, this ); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jer...@us...> - 2008-07-03 15:21:29
|
Revision: 6752 http://playerstage.svn.sourceforge.net/playerstage/?rev=6752&view=rev Author: jeremy_asher Date: 2008-07-03 15:21:34 -0700 (Thu, 03 Jul 2008) Log Message: ----------- Fixed options dialog redraw error Modified Paths: -------------- code/stage/trunk/libstage/options_dlg.cc code/stage/trunk/libstage/options_dlg.hh code/stage/trunk/libstage/worldgui.cc Modified: code/stage/trunk/libstage/options_dlg.cc =================================================================== --- code/stage/trunk/libstage/options_dlg.cc 2008-07-03 21:28:20 UTC (rev 6751) +++ code/stage/trunk/libstage/options_dlg.cc 2008-07-03 22:21:34 UTC (rev 6752) @@ -80,11 +80,11 @@ check->callback( checkChanged, this ); } scroll->end(); + this->redraw(); } void OptionsDlg::setOptions( const std::vector<Option*>& opts ) { - options.clear(); - options.insert( options.begin(), opts.begin(), opts.end() ); + options.assign( opts.begin(), opts.end() ); updateChecks(); } Modified: code/stage/trunk/libstage/options_dlg.hh =================================================================== --- code/stage/trunk/libstage/options_dlg.hh 2008-07-03 21:28:20 UTC (rev 6751) +++ code/stage/trunk/libstage/options_dlg.hh 2008-07-03 22:21:34 UTC (rev 6752) @@ -16,7 +16,7 @@ //class Option; - class OptionsDlg : protected Fl_Window { + class OptionsDlg : public Fl_Window { public: enum event_t { NO_EVENT, CHANGE, CHANGE_ALL, CLOSE }; @@ -43,9 +43,6 @@ public: OptionsDlg( int x, int y, int w, int h ); virtual ~OptionsDlg(); - void callback( Fl_Callback* cb, void* p ) { Fl_Window::callback( cb, p ); } - void show() { Fl_Window::show(); } - void hide() { Fl_Window::hide(); } void setOptions( const std::vector<Option*>& opts ); void setOptions( const std::set<Option*, Option::optComp>& opts ); Modified: code/stage/trunk/libstage/worldgui.cc =================================================================== --- code/stage/trunk/libstage/worldgui.cc 2008-07-03 21:28:20 UTC (rev 6751) +++ code/stage/trunk/libstage/worldgui.cc 2008-07-03 22:21:34 UTC (rev 6752) @@ -462,7 +462,7 @@ // instance before the dialog is destroyed worldGui->oDlg = NULL; oDlg->hide(); - //Fl::delete_widget( oDlg ); + Fl::delete_widget( oDlg ); return; case OptionsDlg::NO_EVENT: case OptionsDlg::CHANGE_ALL: @@ -609,7 +609,6 @@ } drawOptions.assign( options.begin(), options.end() ); - if ( oDlg ) { oDlg->setOptions( drawOptions ); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jer...@us...> - 2008-07-04 10:44:31
|
Revision: 6758 http://playerstage.svn.sourceforge.net/playerstage/?rev=6758&view=rev Author: jeremy_asher Date: 2008-07-04 10:44:35 -0700 (Fri, 04 Jul 2008) Log Message: ----------- Extended Option class to allow custom callbacks on menu option selection to permit perspective cam mode to invalidate canvas Modified Paths: -------------- code/stage/trunk/libstage/canvas.cc code/stage/trunk/libstage/option.cc code/stage/trunk/libstage/option.hh Modified: code/stage/trunk/libstage/canvas.cc =================================================================== --- code/stage/trunk/libstage/canvas.cc 2008-07-04 17:07:49 UTC (rev 6757) +++ code/stage/trunk/libstage/canvas.cc 2008-07-04 17:44:35 UTC (rev 6758) @@ -201,12 +201,11 @@ int StgCanvas::handle(int event) { - - switch(event) - { - case FL_MOUSEWHEEL: - if( selected_models ) + switch(event) { + case FL_MOUSEWHEEL: + if( selected_models ) + { // rotate all selected models for( GList* it = selected_models; it; it=it->next ) { @@ -214,7 +213,7 @@ mod->AddToPose( 0,0,0, 0.1*(double)Fl::event_dy() ); } redraw(); - } + } else { if( perspectiveCam == true ) { @@ -759,6 +758,11 @@ printf( "Saved %s\n", filename ); } +void perspectiveCb( Fl_Widget* w, void* p ) +{ + StgCanvas* canvas = static_cast<StgCanvas*>( p ); + canvas->invalidate(); +} void StgCanvas::createMenuItems( Fl_Menu_Bar* menu, std::string path ) { @@ -773,6 +777,7 @@ showGrid.createMenuItem( menu, path ); showStatus.createMenuItem( menu, path ); perspectiveCam.createMenuItem( menu, path ); + perspectiveCam.menuCallback( perspectiveCb, this ); showOccupancy.createMenuItem( menu, path ); showTrailArrows.createMenuItem( menu, path ); showTrails.createMenuItem( menu, path ); Modified: code/stage/trunk/libstage/option.cc =================================================================== --- code/stage/trunk/libstage/option.cc 2008-07-04 17:07:49 UTC (rev 6757) +++ code/stage/trunk/libstage/option.cc 2008-07-04 17:44:35 UTC (rev 6758) @@ -9,17 +9,13 @@ wf_token( tok ), shortcut( key ), menu( NULL ), -menuIndex( -1 ) +menuCb( NULL ) { } -Option::Option( const Option& o ) : -optName( o.optName ), -value( o.value ), -wf_token( o.wf_token ), -shortcut( o.shortcut ), -menu( o.menu ), -menuIndex( o.menuIndex ) -{ } +Fl_Menu_Item* getMenuItem( Fl_Menu_* menu, int i ) { + const Fl_Menu_Item* mArr = menu->menu(); + return const_cast<Fl_Menu_Item*>( &mArr[ i ] ); +} void Option::Load( Worldfile* wf, int section ) @@ -32,13 +28,20 @@ wf->WriteInt(section, wf_token.c_str(), value ); } -void toggleCb( Fl_Widget* w, void* p ) +void Option::toggleCb( Fl_Widget* w, void* p ) { //Fl_Menu_* menu = static_cast<Fl_Menu_*>( w ); Option* opt = static_cast<Option*>( p ); opt->invert(); + if ( opt->menuCb ) + opt->menuCb( NULL, opt->menuCbParam ); } +void Option::menuCallback( Fl_Callback* cb, void* p ) { + menuCb = cb; + menuCbParam = p; +} + void Option::createMenuItem( Fl_Menu_Bar* m, std::string path ) { menu = m; @@ -47,15 +50,14 @@ menuIndex = menu->add( path.c_str(), shortcut.c_str(), toggleCb, this, FL_MENU_TOGGLE | (value ? FL_MENU_VALUE : 0 ) ); -} +} void Option::set( bool val ) { value = val; if( menu ) { - const Fl_Menu_Item* mArr = menu->menu(); - Fl_Menu_Item* item = const_cast<Fl_Menu_Item*>( &mArr[ menuIndex ] ); + Fl_Menu_Item* item = getMenuItem( menu, menuIndex ); value ? item->set() : item->clear(); } } Modified: code/stage/trunk/libstage/option.hh =================================================================== --- code/stage/trunk/libstage/option.hh 2008-07-04 17:07:49 UTC (rev 6757) +++ code/stage/trunk/libstage/option.hh 2008-07-04 17:44:35 UTC (rev 6758) @@ -29,10 +29,11 @@ std::string shortcut; Fl_Menu_* menu; int menuIndex; + Fl_Callback* menuCb; + void* menuCbParam; public: Option( std::string n, std::string tok, std::string key, bool v ); - Option( const Option& o ); const std::string name() const { return optName; } inline bool val() const { return value; } @@ -50,6 +51,8 @@ void createMenuItem( Fl_Menu_Bar* menu, std::string path ); + void menuCallback( Fl_Callback* cb, void* p ); + static void toggleCb( Fl_Widget* w, void* p ); void Load( Worldfile* wf, int section ); void Save( Worldfile* wf, int section ); }; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <al...@us...> - 2008-07-04 12:55:25
|
Revision: 6760 http://playerstage.svn.sourceforge.net/playerstage/?rev=6760&view=rev Author: alexcb Date: 2008-07-04 12:55:31 -0700 (Fri, 04 Jul 2008) Log Message: ----------- fixed drawing issue with laser and camera Modified Paths: -------------- code/stage/trunk/libstage/model_camera.cc code/stage/trunk/libstage/model_laser.cc Modified: code/stage/trunk/libstage/model_camera.cc =================================================================== --- code/stage/trunk/libstage/model_camera.cc 2008-07-04 18:18:25 UTC (rev 6759) +++ code/stage/trunk/libstage/model_camera.cc 2008-07-04 19:55:31 UTC (rev 6760) @@ -237,16 +237,17 @@ //TODO create lines outlining camera frustrum, then iterate over each depth measurement and create a square void StgModelCamera::DataVisualize( void ) -{ +{ + if( _frame_data == NULL || !showCameraData ) return; - + float w_fov = _camera.horizFov(); float h_fov = _camera.vertFov(); - + float start_fov = w_fov / 2.0 + 180.0; //start at right float start_vert_fov = h_fov / 2.0 + 90.0; //start at top - + int w = _width; int h = _height; float a_space = w_fov / w; //degrees between each sample @@ -284,7 +285,6 @@ _valid_vertexbuf_cache = true; } - glTranslatef( 0, 0, CAMERA_HEIGHT / 2.0 ); glDisable( GL_CULL_FACE ); glPolygonMode( GL_FRONT_AND_BACK, GL_FILL ); //glBegin( GL_QUADS ); Modified: code/stage/trunk/libstage/model_laser.cc =================================================================== --- code/stage/trunk/libstage/model_laser.cc 2008-07-04 18:18:25 UTC (rev 6759) +++ code/stage/trunk/libstage/model_laser.cc 2008-07-04 19:55:31 UTC (rev 6760) @@ -310,6 +310,8 @@ if ( ! (showLaserData || showLaserStrikes) ) return; + glPushMatrix(); + // we only regenerate the list if there's new data if( data_dirty ) { @@ -383,4 +385,5 @@ glCallList( data_dl ); + glPopMatrix(); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jer...@us...> - 2008-07-04 15:05:49
|
Revision: 6763 http://playerstage.svn.sourceforge.net/playerstage/?rev=6763&view=rev Author: jeremy_asher Date: 2008-07-04 15:05:58 -0700 (Fri, 04 Jul 2008) Log Message: ----------- Rewrote model selection code to mirror standard selection functionality and to fix bugs Modified Paths: -------------- code/stage/trunk/libstage/canvas.cc code/stage/trunk/libstage/stage.hh Modified: code/stage/trunk/libstage/canvas.cc =================================================================== --- code/stage/trunk/libstage/canvas.cc 2008-07-04 22:01:25 UTC (rev 6762) +++ code/stage/trunk/libstage/canvas.cc 2008-07-04 22:05:58 UTC (rev 6763) @@ -73,8 +73,6 @@ interval = 50; //msec between redraws graphics = true; - dragging = false; - rotating = false; // // start the timer that causes regular redraws Fl::add_timeout( ((double)interval/1000), @@ -86,12 +84,8 @@ { } -StgModel* StgCanvas::Select( int x, int y ) +StgModel* StgCanvas::getModel( int x, int y ) { - // TODO XX - //return NULL; - - // render all models in a unique color make_current(); // make sure the GL context is current glClearColor ( 1,1,1,1 ); // white @@ -158,30 +152,47 @@ glEnable(GL_DITHER); glEnable(GL_BLEND); glClearColor ( 0.7, 0.7, 0.8, 1.0); + + return mod; +} - if( mod ) // we clicked on a root model +bool StgCanvas::selected( StgModel* mod ) { + if( g_list_find( selected_models, mod ) ) + return true; + else + return false; +} + +void StgCanvas::select( StgModel* mod ) { + if( mod ) { - // if it's already selected - if( GList* link = g_list_find( selected_models, mod ) ) - { - // remove it from the selected list - selected_models = - g_list_remove_link( selected_models, link ); - mod->Disable(); - } - else - { - last_selection = mod; - selected_models = g_list_prepend( selected_models, mod ); - mod->Enable(); - } - - invalidate(); + last_selection = mod; + selected_models = g_list_prepend( selected_models, mod ); +// mod->Disable(); } +} - return mod; +void StgCanvas::unSelect( StgModel* mod ) { + if( mod ) + { + if ( GList* link = g_list_find( selected_models, mod ) ) + { + // remove it from the selected list + selected_models = + g_list_remove_link( selected_models, link ); +// mod->Enable(); + } + } } +void StgCanvas::unSelectAll() { +// for( GList* it=selected_models; it; it=it->next ) +// ((StgModel*)it->data)->Enable(); + + g_list_free( selected_models ); + selected_models = NULL; +} + // convert from 2d window pixel to 3d world coordinates void StgCanvas::CanvasToWorld( int px, int py, double *wx, double *wy, double* wz ) @@ -207,194 +218,205 @@ case FL_MOUSEWHEEL: if( selected_models ) { - // rotate all selected models - for( GList* it = selected_models; it; it=it->next ) - { - StgModel* mod = (StgModel*)it->data; - mod->AddToPose( 0,0,0, 0.1*(double)Fl::event_dy() ); - } - redraw(); + // rotate all selected models + for( GList* it = selected_models; it; it=it->next ) + { + StgModel* mod = (StgModel*)it->data; + mod->AddToPose( 0,0,0, 0.1*(double)Fl::event_dy() ); + } + redraw(); } - else - { - if( perspectiveCam == true ) { - perspective_camera.scroll( Fl::event_dy() / 10.0 ); - } else { - camera.scale( Fl::event_dy(), Fl::event_x(), w(), Fl::event_y(), h() ); - } - invalidate(); - redraw(); - } - return 1; + else + { + if( perspectiveCam == true ) { + perspective_camera.scroll( Fl::event_dy() / 10.0 ); + } + else { + camera.scale( Fl::event_dy(), Fl::event_x(), w(), Fl::event_y(), h() ); + } + invalidate(); + redraw(); + } + return 1; + + case FL_MOVE: // moused moved while no button was pressed + if( Fl::event_state( FL_CTRL ) ) + { + int dx = Fl::event_x() - startx; + int dy = Fl::event_y() - starty; - case FL_MOVE: // moused moved while no button was pressed - if( Fl::event_state( FL_CTRL ) ) - { - int dx = Fl::event_x() - startx; - int dy = Fl::event_y() - starty; + if( perspectiveCam == true ) { + perspective_camera.addYaw( -dx ); + perspective_camera.addPitch( -dy ); + } + else { + camera.pitch( 0.5 * static_cast<double>( dy ) ); + camera.yaw( 0.5 * static_cast<double>( dx ) ); + } + invalidate(); + redraw(); + } + else if( Fl::event_state( FL_ALT ) ) + { + int dx = Fl::event_x() - startx; + int dy = Fl::event_y() - starty; - if( perspectiveCam == true ) { - perspective_camera.addYaw( -dx ); - perspective_camera.addPitch( -dy ); - } else { - camera.pitch( 0.5 * static_cast<double>( dy ) ); - camera.yaw( 0.5 * static_cast<double>( dx ) ); - } + if( perspectiveCam == true ) { + perspective_camera.move( -dx, dy, 0.0 ); + } + else { + camera.move( -dx, dy ); + } + invalidate(); - invalidate(); - redraw(); - } - else if( Fl::event_state( FL_ALT ) ) - { - int dx = Fl::event_x() - startx; - int dy = Fl::event_y() - starty; + } + startx = Fl::event_x(); + starty = Fl::event_y(); + return 1; - if( perspectiveCam == true ) { - perspective_camera.move( -dx, dy, 0.0 ); - } else { - camera.move( -dx, dy ); + case FL_PUSH: // button pressed + StgModel* mod = getModel( startx, starty ); + startx = Fl::event_x(); + starty = Fl::event_y(); + selectedModel = false; + switch( Fl::event_button() ) + { + case 1: + if( mod ) { + // clicked a model + if ( Fl::event_state( FL_SHIFT ) ) { + // holding shift, toggle selection + if ( selected( mod ) ) + unSelect( mod ); + else { + select( mod ); + selectedModel = true; // selected a model + } + } + else { + if ( !selected( mod ) ) { + // clicked on an unselected model while + // not holding shift, this is the new + // selection + unSelectAll(); + select( mod ); + } + selectedModel = true; // selected a model + } + } + else { + // clicked on empty space, unselect all + unSelectAll(); + } + return 1; + case 3: + { + // leave selections alone + // rotating handled within FL_DRAG + return 1; + } + default: + return 0; + } - } - invalidate(); - - } - - startx = Fl::event_x(); - starty = Fl::event_y(); - - return 1; - - case FL_PUSH: // button pressed - switch( Fl::event_button() ) + case FL_DRAG: // mouse moved while button was pressed { - case 1: - startx = Fl::event_x(); - starty = Fl::event_y(); - if( Select( startx, starty ) ) - dragging = true; - return 1; - case 3: - { - startx = Fl::event_x(); - starty = Fl::event_y(); - if( Select( startx, starty ) ) - rotating = true; - return 1; - } - default: - return 0; - } + int dx = Fl::event_x() - startx; + int dy = Fl::event_y() - starty; - case FL_DRAG: // mouse moved while button was pressed - { - int dx = Fl::event_x() - startx; - int dy = Fl::event_y() - starty; + if ( Fl::event_state( FL_BUTTON1 ) ) { + // Left mouse button drag + if ( selectedModel ) { + // started dragging on a selected model + + double sx,sy,sz; + CanvasToWorld( startx, starty, + &sx, &sy, &sz ); + double x,y,z; + CanvasToWorld( Fl::event_x(), Fl::event_y(), + &x, &y, &z ); + // move all selected models to the mouse pointer + for( GList* it = selected_models; it; it=it->next ) + { + StgModel* mod = (StgModel*)it->data; + mod->AddToPose( x-sx, y-sy, 0, 0 ); + } + } + else { + // started dragging on empty space or an + // unselected model, move the canvas + camera.move( -dx, dy ); + invalidate(); // so the projection gets updated + } + } + else if ( Fl::event_state( FL_BUTTON3 ) ) { + // rotate all selected models + for( GList* it = selected_models; it; it=it->next ) + { + StgModel* mod = (StgModel*)it->data; + mod->AddToPose( 0,0,0, 0.05*dx ); + } + } + + startx = Fl::event_x(); + starty = Fl::event_y(); - switch( Fl::event_button() ) - { - case 1: - if( dragging ) - { - assert(selected_models); + redraw(); + return 1; + } // end case FL_DRAG - double sx,sy,sz; - CanvasToWorld( startx, starty, - &sx, &sy, &sz ); - double x,y,z; - CanvasToWorld( Fl::event_x(), Fl::event_y(), - &x, &y, &z ); + case FL_RELEASE: // mouse button released + + return 1; - // move all selected models to the mouse pointer - for( GList* it = selected_models; it; it=it->next ) - { - StgModel* mod = (StgModel*)it->data; - mod->AddToPose( x-sx, y-sy, 0, 0 ); - } - } - else - { - camera.move( -dx, dy ); - invalidate(); // so the projection gets updated - } - break; - case 3: // right button - if( rotating ) - { - // move all selected models to the mouse pointer - for( GList* it = selected_models; it; it=it->next ) - { - StgModel* mod = (StgModel*)it->data; - mod->AddToPose( 0,0,0, 0.05*dx ); - } - } - break; - } - } - startx = Fl::event_x(); - starty = Fl::event_y(); + case FL_FOCUS: + case FL_UNFOCUS: + //.... Return 1 if you want keyboard events, 0 otherwise + return 1; - redraw(); - return 1; // end case FL_DRAG - - case FL_RELEASE: // mouse button released - // unselect everyone unless shift is pressed - if( ! Fl::event_state( FL_SHIFT ) ) - { - for( GList* it=selected_models; it; it=it->next ) - ((StgModel*)it->data)->Enable(); - - g_list_free( selected_models ); - selected_models = NULL; - dragging = false; - rotating = false; - redraw(); - } - return 1; - - case FL_FOCUS : - case FL_UNFOCUS : - //.... Return 1 if you want keyboard events, 0 otherwise - return 1; - case FL_KEYBOARD: - switch( Fl::event_key() ) - { - case 'p': // pause - world->TogglePause(); - break; - case ' ': // space bar - camera.resetAngle(); - //invalidate(); - if( Fl::event_state( FL_CTRL ) ) { - resetCamera(); - } - redraw(); - break; - case FL_Left: - if( perspectiveCam == false ) { camera.move( -10, 0 ); } - else { perspective_camera.strafe( -0.5 ); } break; - case FL_Right: - if( perspectiveCam == false ) {camera.move( 10, 0 ); } - else { perspective_camera.strafe( 0.5 ); } break; - case FL_Down: - if( perspectiveCam == false ) {camera.move( 0, -10 ); } - else { perspective_camera.forward( -0.5 ); } break; - case FL_Up: - if( perspectiveCam == false ) {camera.move( 0, 10 ); } - else { perspective_camera.forward( 0.5 ); } break; + case FL_KEYBOARD: + switch( Fl::event_key() ) + { + case 'p': // pause + world->TogglePause(); + break; + case ' ': // space bar + camera.resetAngle(); + //invalidate(); + if( Fl::event_state( FL_CTRL ) ) { + resetCamera(); + } + redraw(); + break; + case FL_Left: + if( perspectiveCam == false ) { camera.move( -10, 0 ); } + else { perspective_camera.strafe( -0.5 ); } break; + case FL_Right: + if( perspectiveCam == false ) {camera.move( 10, 0 ); } + else { perspective_camera.strafe( 0.5 ); } break; + case FL_Down: + if( perspectiveCam == false ) {camera.move( 0, -10 ); } + else { perspective_camera.forward( -0.5 ); } break; + case FL_Up: + if( perspectiveCam == false ) {camera.move( 0, 10 ); } + else { perspective_camera.forward( 0.5 ); } break; + default: + return 0; // keypress unhandled + } + + invalidate(); // update projection + return 1; + +// case FL_SHORTCUT: +// //... shortcut, key is in Fl::event_key(), ascii in Fl::event_text() +// //... Return 1 if you understand/use the shortcut event, 0 otherwise... +// return 1; default: - return 0; // keypress unhandled - } - invalidate(); // update projection - return 1; - //case FL_SHORTCUT: - ///... shortcut, key is in Fl::event_key(), ascii in Fl::event_text() - // ... Return 1 if you understand/use the shortcut event, 0 otherwise... - //return 1; - default: - // pass other events to the base class... - //printf( "EVENT %d\n", event ); - return Fl_Gl_Window::handle(event); - } + // pass other events to the base class... + //printf( "EVENT %d\n", event ); + return Fl_Gl_Window::handle(event); + + } // end switch( event ) } void StgCanvas::FixViewport(int W,int H) @@ -595,15 +617,17 @@ // draw the model-specific visualizations if( showData ) { - GList* it; - if ( visualizeAll ) - it = world->StgWorld::children; - else - it = selected_models; - for( ; it; it=it->next ) + if ( visualizeAll ) { + for( GList* it = world->StgWorld::children; it; it=it->next ) ((StgModel*)it->data)->DataVisualizeTree(); - - + } + else if ( selected_models ) { + for( GList* it = selected_models; it; it=it->next ) + ((StgModel*)it->data)->DataVisualizeTree(); + } + else if ( last_selection ) { + last_selection->DataVisualizeTree(); + } } if( showGrid ) Modified: code/stage/trunk/libstage/stage.hh =================================================================== --- code/stage/trunk/libstage/stage.hh 2008-07-04 22:01:25 UTC (rev 6762) +++ code/stage/trunk/libstage/stage.hh 2008-07-04 22:05:58 UTC (rev 6763) @@ -1928,8 +1928,7 @@ StgPerspectiveCamera perspective_camera; int startx, starty; - bool dragging; - bool rotating; + bool selectedModel; GList* selected_models; ///< a list of models that are currently ///selected by the user StgModel* last_selection; ///< the most recently selected model @@ -1986,7 +1985,11 @@ void CanvasToWorld( int px, int py, double *wx, double *wy, double* wz ); - StgModel* Select( int x, int y ); + StgModel* getModel( int x, int y ); + bool selected( StgModel* mod ); + void select( StgModel* mod ); + void unSelect( StgModel* mod ); + void unSelectAll(); inline void PushColor( stg_color_t col ) { colorstack.Push( col ); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <rt...@us...> - 2008-07-04 15:58:16
|
Revision: 6765 http://playerstage.svn.sourceforge.net/playerstage/?rev=6765&view=rev Author: rtv Date: 2008-07-04 15:58:26 -0700 (Fri, 04 Jul 2008) Log Message: ----------- fixed model name prefix and window title bar Modified Paths: -------------- code/stage/trunk/libstage/CMakeLists.txt code/stage/trunk/libstage/ancestor.cc code/stage/trunk/libstage/canvas.cc code/stage/trunk/libstage/model_laser.cc code/stage/trunk/libstage/model_load.cc code/stage/trunk/libstage/model_position.cc code/stage/trunk/libstage/stage.cc code/stage/trunk/libstage/stest.cc code/stage/trunk/libstage/test.cc code/stage/trunk/libstage/world.cc code/stage/trunk/libstage/worldfile.cc code/stage/trunk/libstage/worldfile.hh code/stage/trunk/libstage/worldgui.cc Modified: code/stage/trunk/libstage/CMakeLists.txt =================================================================== --- code/stage/trunk/libstage/CMakeLists.txt 2008-07-04 22:10:13 UTC (rev 6764) +++ code/stage/trunk/libstage/CMakeLists.txt 2008-07-04 22:58:26 UTC (rev 6765) @@ -65,6 +65,9 @@ add_executable( test test.cc ) target_link_libraries( test stage ) +add_executable( stest stest.cc ) +target_link_libraries( stest stage ) + INSTALL(TARGETS stagebinary stage RUNTIME DESTINATION bin LIBRARY DESTINATION lib Modified: code/stage/trunk/libstage/ancestor.cc =================================================================== --- code/stage/trunk/libstage/ancestor.cc 2008-07-04 22:10:13 UTC (rev 6764) +++ code/stage/trunk/libstage/ancestor.cc 2008-07-04 22:58:26 UTC (rev 6765) @@ -28,9 +28,17 @@ // poke a name into the child char* buf = new char[TOKEN_MAX]; - snprintf( buf, TOKEN_MAX, "%s.%s:%d", - token, typetable[mod->type].token, child_type_counts[mod->type] ); - + + if( token ) // if this object has a name, use it + snprintf( buf, TOKEN_MAX, "%s.%s:%d", + token, + typetable[mod->type].token, + child_type_counts[mod->type] ); + else + snprintf( buf, TOKEN_MAX, "%s:%d", + typetable[mod->type].token, + child_type_counts[mod->type] ); + //printf( "%s generated a name for my child %s\n", token, buf ); mod->SetToken( buf ); Modified: code/stage/trunk/libstage/canvas.cc =================================================================== --- code/stage/trunk/libstage/canvas.cc 2008-07-04 22:10:13 UTC (rev 6764) +++ code/stage/trunk/libstage/canvas.cc 2008-07-04 22:58:26 UTC (rev 6765) @@ -275,50 +275,52 @@ return 1; case FL_PUSH: // button pressed - StgModel* mod = getModel( startx, starty ); - startx = Fl::event_x(); - starty = Fl::event_y(); - selectedModel = false; - switch( Fl::event_button() ) + { + StgModel* mod = getModel( startx, starty ); + startx = Fl::event_x(); + starty = Fl::event_y(); + selectedModel = false; + switch( Fl::event_button() ) + { + case 1: + if( mod ) { + // clicked a model + if ( Fl::event_state( FL_SHIFT ) ) { + // holding shift, toggle selection + if ( selected( mod ) ) + unSelect( mod ); + else { + select( mod ); + selectedModel = true; // selected a model + } + } + else { + if ( !selected( mod ) ) { + // clicked on an unselected model while + // not holding shift, this is the new + // selection + unSelectAll(); + select( mod ); + } + selectedModel = true; // selected a model + } + } + else { + // clicked on empty space, unselect all + unSelectAll(); + } + return 1; + case 3: { - case 1: - if( mod ) { - // clicked a model - if ( Fl::event_state( FL_SHIFT ) ) { - // holding shift, toggle selection - if ( selected( mod ) ) - unSelect( mod ); - else { - select( mod ); - selectedModel = true; // selected a model - } - } - else { - if ( !selected( mod ) ) { - // clicked on an unselected model while - // not holding shift, this is the new - // selection - unSelectAll(); - select( mod ); - } - selectedModel = true; // selected a model - } - } - else { - // clicked on empty space, unselect all - unSelectAll(); - } - return 1; - case 3: - { - // leave selections alone - // rotating handled within FL_DRAG - return 1; + // leave selections alone + // rotating handled within FL_DRAG + return 1; } - default: - return 0; - } - + default: + return 0; + } + } + case FL_DRAG: // mouse moved while button was pressed { int dx = Fl::event_x() - startx; @@ -964,7 +966,6 @@ glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT ); } - if( perspectiveCam == true ) { if( showFollow && last_selection ) { Modified: code/stage/trunk/libstage/model_laser.cc =================================================================== --- code/stage/trunk/libstage/model_laser.cc 2008-07-04 22:10:13 UTC (rev 6764) +++ code/stage/trunk/libstage/model_laser.cc 2008-07-04 22:58:26 UTC (rev 6765) @@ -77,11 +77,11 @@ */ StgModelLaser::StgModelLaser( StgWorld* world, - StgModel* parent ) + StgModel* parent ) : StgModel( world, parent, MODEL_TYPE_LASER ) { PRINT_DEBUG2( "Constructing StgModelLaser %d (%s)\n", - id, typestr ); + id, typestr ); // sensible laser defaults interval = DEFAULT_INTERVAL_MS * (int)thousand; @@ -157,8 +157,8 @@ } static bool laser_raytrace_match( StgBlock* testblock, - StgModel* finder, - const void* dummy ) + StgModel* finder, + const void* dummy ) { // Ignore the model that's looking and things that are invisible to // lasers @@ -188,20 +188,20 @@ rayorg.a = bearing; Raytrace( rayorg, - range_max, - laser_raytrace_match, - NULL, - &sample, - true ); // z testing enabled + range_max, + laser_raytrace_match, + NULL, + &sample, + true ); // z testing enabled samples[t].range = sample.range; // if we hit a model and it reflects brightly, we set // reflectance high, else low if( sample.block && ( sample.block->Model()->GetLaserReturn() >= LaserBright ) ) - samples[t].reflectance = 1; + samples[t].reflectance = 1; else - samples[t].reflectance = 0; + samples[t].reflectance = 0; // todo - lower bound on range bearing += sample_incr; @@ -211,22 +211,22 @@ if( resolution > 1 ) { for( unsigned int t=resolution; t<sample_count; t+=resolution ) - for( unsigned int g=1; g<resolution; g++ ) - { - if( t >= sample_count ) - break; + for( unsigned int g=1; g<resolution; g++ ) + { + if( t >= sample_count ) + break; - // copy the rightmost sample data into this point - memcpy( &samples[t-g], - &samples[t-resolution], - sizeof(stg_laser_sample_t)); + // copy the rightmost sample data into this point + memcpy( &samples[t-g], + &samples[t-resolution], + sizeof(stg_laser_sample_t)); - double left = samples[t].range; - double right = samples[t-resolution].range; + double left = samples[t].range; + double right = samples[t-resolution].range; - // linear range interpolation between the left and right samples - samples[t-g].range = (left-g*(left-right)/resolution); - } + // linear range interpolation between the left and right samples + samples[t-g].range = (left-g*(left-right)/resolution); + } } data_dirty = true; @@ -310,7 +310,7 @@ if ( ! (showLaserData || showLaserStrikes) ) return; - glPushMatrix(); + glPushMatrix(); // we only regenerate the list if there's new data if( 1 /* (temp hack) data_dirty*/ ) @@ -318,17 +318,14 @@ data_dirty = false; glNewList( data_dl, GL_COMPILE ); - //glEnableClientState( GL_VERTEX_ARRAY ); + //glEnableClientState( GL_VERTEX_ARRAY ); glTranslatef( 0,0, geom.size.z/2.0 ); // shoot the laser beam out at the right height - - PushColor( 0, 0, 1, 0.5 ); - - glPointSize( 4.0 ); - - // DEBUG - draw the origin of the laser beams - glBegin( GL_POINTS ); - glVertex2f( 0,0 ); - glEnd(); + + // DEBUG - draw the origin of the laser beams + //glPointSize( 4.0 ); + //glBegin( GL_POINTS ); + //glVertex2f( 0,0 ); + //glEnd(); // pack the laser hit points into a vertex array for fast rendering static float* pts = NULL; @@ -337,59 +334,48 @@ pts[0] = 0.0; pts[1] = 0.0; - - glVertexPointer( 2, GL_FLOAT, 0, pts ); - + PushColor( 0, 0, 1, 0.5 ); + for( unsigned int s=0; s<sample_count; s++ ) - { - double ray_angle = (s * (fov / (sample_count-1))) - fov/2.0; - pts[2*s+2] = (float)(samples[s].range * cos(ray_angle) ); - pts[2*s+3] = (float)(samples[s].range * sin(ray_angle) ); + { + double ray_angle = (s * (fov / (sample_count-1))) - fov/2.0; + pts[2*s+2] = (float)(samples[s].range * cos(ray_angle) ); + pts[2*s+3] = (float)(samples[s].range * sin(ray_angle) ); - // if the sample is unusually bright, draw a little blob - if( samples[s].reflectance > 0 ) - { - glBegin( GL_POINTS ); - glVertex2f( pts[2*s+2], pts[2*s+3] ); - glEnd(); - - // why doesn't this work? - //glDrawArrays( GL_POINTS, 2*s+2, 1 ); - } + // if the sample is unusually bright, draw a little blob + if( samples[s].reflectance > 0 ) + { + glBegin( GL_POINTS ); + glVertex2f( pts[2*s+2], pts[2*s+3] ); + glEnd(); + } - } + } PopColor(); - glDepthMask( GL_FALSE ); glPolygonMode( GL_FRONT_AND_BACK, GL_FILL ); // draw the filled polygon in transparent blue - PushColor( 0, 0, 1, 0.1 ); - - + PushColor( 0, 0, 1, 0.1 ); + glVertexPointer( 2, GL_FLOAT, 0, pts ); glDrawArrays( GL_POLYGON, 0, sample_count+1 ); - - // reset PopColor(); - if( showLaserStrikes ) - { - // draw the beam strike points in black - PushColor( 0, 0, 0, 1.0 ); - glPointSize( 1.0 ); - glDrawArrays( GL_POINTS, 0, sample_count+1 ); - PopColor(); - } + if( showLaserStrikes ) + { + // draw the beam strike points in black + PushColor( 0, 0, 0, 1.0 ); + glPointSize( 1.0 ); + glDrawArrays( GL_POINTS, 0, sample_count+1 ); + PopColor(); + } glDepthMask( GL_TRUE ); - - - //glDisableClientState( GL_VERTEX_ARRAY ); glEndList(); } // end if ( data_dirty ) glCallList( data_dl ); - glPopMatrix(); + glPopMatrix(); } Modified: code/stage/trunk/libstage/model_load.cc =================================================================== --- code/stage/trunk/libstage/model_load.cc 2008-07-04 22:10:13 UTC (rev 6764) +++ code/stage/trunk/libstage/model_load.cc 2008-07-04 22:58:26 UTC (rev 6765) @@ -1,19 +1,14 @@ #ifndef _GNU_SOURCE #define _GNU_SOURCE #endif + #include <limits.h> #include <libgen.h> // for dirname() #include <string.h> -#include "stage_internal.hh" - -//#define DEBUG 1 - #include <ltdl.h> -void FooInit( StgModel* ); -void FooUpdate( StgModel* ); +#include "stage_internal.hh" - void StgModel::Load() { assert( wf ); @@ -21,349 +16,349 @@ PRINT_DEBUG1( "Model \"%s\" loading...", token ); - if( wf->PropertyExists( wf_entity, "debug" ) ) + if( wf->PropertyExists( wf_entity, "debug" ) ) + { + PRINT_WARN2( "debug property specified for model %d %s\n", + wf_entity, this->token ); + this->debug = wf->ReadInt( wf_entity, "debug", this->debug ); + } + + if( wf->PropertyExists( wf_entity, "name" ) ) + { + char *name = (char*)wf->ReadString(wf_entity, "name", NULL ); + if( name ) { - PRINT_WARN2( "debug property specified for model %d %s\n", - wf_entity, this->token ); - this->debug = wf->ReadInt( wf_entity, "debug", this->debug ); + //printf( "changed %s to %s\n", this->token, token ); + this->token = strdup( name ); + world->AddModel( this ); // add this name to the world's table } + else + PRINT_ERR1( "Name blank for model %s. Check your worldfile\n", this->token ); - if( wf->PropertyExists( wf_entity, "name" ) ) - { - char *name = (char*)wf->ReadString(wf_entity, "name", NULL ); - if( name ) - { - //printf( "changed %s to %s\n", this->token, token ); - this->token = strdup( name ); - world->AddModel( this ); // add this name to the world's table - } - else - PRINT_ERR1( "Name blank for model %s. Check your worldfile\n", this->token ); + // add this name to the table - // add this name to the table + } - } + //PRINT_WARN1( "%s::Load", token ); - //PRINT_WARN1( "%s::Load", token ); + if( wf->PropertyExists( wf_entity, "origin" ) ) + { + stg_geom_t geom = GetGeom(); + geom.pose.x = wf->ReadTupleLength(wf_entity, "origin", 0, geom.pose.x ); + geom.pose.y = wf->ReadTupleLength(wf_entity, "origin", 1, geom.pose.y ); + geom.pose.a = wf->ReadTupleAngle(wf_entity, "origin", 2, geom.pose.a ); + this->SetGeom( geom ); + } - if( wf->PropertyExists( wf_entity, "origin" ) ) - { - stg_geom_t geom = GetGeom(); - geom.pose.x = wf->ReadTupleLength(wf_entity, "origin", 0, geom.pose.x ); - geom.pose.y = wf->ReadTupleLength(wf_entity, "origin", 1, geom.pose.y ); - geom.pose.a = wf->ReadTupleAngle(wf_entity, "origin", 2, geom.pose.a ); - this->SetGeom( geom ); - } + if( wf->PropertyExists( wf_entity, "origin4" ) ) + { + stg_geom_t geom = GetGeom(); + geom.pose.x = wf->ReadTupleLength(wf_entity, "origin4", 0, geom.pose.x ); + geom.pose.y = wf->ReadTupleLength(wf_entity, "origin4", 1, geom.pose.y ); + geom.pose.z = wf->ReadTupleLength(wf_entity, "origin4", 2, geom.pose.z ); + geom.pose.a = wf->ReadTupleAngle(wf_entity, "origin4", 3, geom.pose.a ); + this->SetGeom( geom ); + } - if( wf->PropertyExists( wf_entity, "origin4" ) ) - { - stg_geom_t geom = GetGeom(); - geom.pose.x = wf->ReadTupleLength(wf_entity, "origin4", 0, geom.pose.x ); - geom.pose.y = wf->ReadTupleLength(wf_entity, "origin4", 1, geom.pose.y ); - geom.pose.z = wf->ReadTupleLength(wf_entity, "origin4", 2, geom.pose.z ); - geom.pose.a = wf->ReadTupleAngle(wf_entity, "origin4", 3, geom.pose.a ); - this->SetGeom( geom ); - } + if( wf->PropertyExists( wf_entity, "size" ) ) + { + stg_geom_t geom = GetGeom(); + geom.size.x = wf->ReadTupleLength(wf_entity, "size", 0, geom.size.x ); + geom.size.y = wf->ReadTupleLength(wf_entity, "size", 1, geom.size.y ); + this->SetGeom( geom ); + } - if( wf->PropertyExists( wf_entity, "size" ) ) - { - stg_geom_t geom = GetGeom(); - geom.size.x = wf->ReadTupleLength(wf_entity, "size", 0, geom.size.x ); - geom.size.y = wf->ReadTupleLength(wf_entity, "size", 1, geom.size.y ); - this->SetGeom( geom ); - } + if( wf->PropertyExists( wf_entity, "size3" ) ) + { + stg_geom_t geom = GetGeom(); + geom.size.x = wf->ReadTupleLength(wf_entity, "size3", 0, geom.size.x ); + geom.size.y = wf->ReadTupleLength(wf_entity, "size3", 1, geom.size.y ); + geom.size.z = wf->ReadTupleLength(wf_entity, "size3", 2, geom.size.z ); + this->SetGeom( geom ); + } - if( wf->PropertyExists( wf_entity, "size3" ) ) - { - stg_geom_t geom = GetGeom(); - geom.size.x = wf->ReadTupleLength(wf_entity, "size3", 0, geom.size.x ); - geom.size.y = wf->ReadTupleLength(wf_entity, "size3", 1, geom.size.y ); - geom.size.z = wf->ReadTupleLength(wf_entity, "size3", 2, geom.size.z ); - this->SetGeom( geom ); - } + if( wf->PropertyExists( wf_entity, "pose" )) + { + stg_pose_t pose = GetPose(); + pose.x = wf->ReadTupleLength(wf_entity, "pose", 0, pose.x ); + pose.y = wf->ReadTupleLength(wf_entity, "pose", 1, pose.y ); + pose.a = wf->ReadTupleAngle(wf_entity, "pose", 2, pose.a ); + this->SetPose( pose ); + } - if( wf->PropertyExists( wf_entity, "pose" )) - { - stg_pose_t pose = GetPose(); - pose.x = wf->ReadTupleLength(wf_entity, "pose", 0, pose.x ); - pose.y = wf->ReadTupleLength(wf_entity, "pose", 1, pose.y ); - pose.a = wf->ReadTupleAngle(wf_entity, "pose", 2, pose.a ); - this->SetPose( pose ); - } + if( wf->PropertyExists( wf_entity, "pose4" )) + { + stg_pose_t pose = GetPose(); + pose.x = wf->ReadTupleLength(wf_entity, "pose4", 0, pose.x ); + pose.y = wf->ReadTupleLength(wf_entity, "pose4", 1, pose.y ); + pose.z = wf->ReadTupleLength(wf_entity, "pose4", 2, pose.z ); + pose.a = wf->ReadTupleAngle( wf_entity, "pose4", 3, pose.a ); - if( wf->PropertyExists( wf_entity, "pose4" )) - { - stg_pose_t pose = GetPose(); - pose.x = wf->ReadTupleLength(wf_entity, "pose4", 0, pose.x ); - pose.y = wf->ReadTupleLength(wf_entity, "pose4", 1, pose.y ); - pose.z = wf->ReadTupleLength(wf_entity, "pose4", 2, pose.z ); - pose.a = wf->ReadTupleAngle( wf_entity, "pose4", 3, pose.a ); + this->SetPose( pose ); + } - this->SetPose( pose ); - } + if( wf->PropertyExists( wf_entity, "velocity" )) + { + stg_velocity_t vel = GetVelocity(); + vel.x = wf->ReadTupleLength(wf_entity, "velocity", 0, vel.x ); + vel.y = wf->ReadTupleLength(wf_entity, "velocity", 1, vel.y ); + vel.a = wf->ReadTupleAngle(wf_entity, "velocity", 3, vel.a ); + this->SetVelocity( vel ); - if( wf->PropertyExists( wf_entity, "velocity" )) - { - stg_velocity_t vel = GetVelocity(); - vel.x = wf->ReadTupleLength(wf_entity, "velocity", 0, vel.x ); - vel.y = wf->ReadTupleLength(wf_entity, "velocity", 1, vel.y ); - vel.a = wf->ReadTupleAngle(wf_entity, "velocity", 3, vel.a ); - this->SetVelocity( vel ); + if( vel.x || vel.y || vel.z || vel.a ) + world->StartUpdatingModel( this ); + } - if( vel.x || vel.y || vel.z || vel.a ) - world->StartUpdatingModel( this ); - } + if( wf->PropertyExists( wf_entity, "velocity4" )) + { + stg_velocity_t vel = GetVelocity(); + vel.x = wf->ReadTupleLength(wf_entity, "velocity4", 0, vel.x ); + vel.y = wf->ReadTupleLength(wf_entity, "velocity4", 1, vel.y ); + vel.z = wf->ReadTupleLength(wf_entity, "velocity4", 2, vel.z ); + vel.a = wf->ReadTupleAngle(wf_entity, "velocity4", 3, vel.a ); + this->SetVelocity( vel ); + } - if( wf->PropertyExists( wf_entity, "velocity4" )) - { - stg_velocity_t vel = GetVelocity(); - vel.x = wf->ReadTupleLength(wf_entity, "velocity4", 0, vel.x ); - vel.y = wf->ReadTupleLength(wf_entity, "velocity4", 1, vel.y ); - vel.z = wf->ReadTupleLength(wf_entity, "velocity4", 2, vel.z ); - vel.a = wf->ReadTupleAngle(wf_entity, "velocity4", 3, vel.a ); - this->SetVelocity( vel ); - } + if( wf->PropertyExists( wf_entity, "boundary" )) + { + this->SetBoundary( wf->ReadInt(wf_entity, "boundary", this->boundary )); + } - if( wf->PropertyExists( wf_entity, "boundary" )) + if( wf->PropertyExists( wf_entity, "color" )) + { + stg_color_t col = 0xFFFF0000; // red; + const char* colorstr = wf->ReadString( wf_entity, "color", NULL ); + if( colorstr ) { - this->SetBoundary( wf->ReadInt(wf_entity, "boundary", this->boundary )); - } + if( strcmp( colorstr, "random" ) == 0 ) + { + col = (uint32_t)random(); + col |= 0xFF000000; // set the alpha channel to max + } + else + col = stg_lookup_color( colorstr ); - if( wf->PropertyExists( wf_entity, "color" )) - { - stg_color_t col = 0xFFFF0000; // red; - const char* colorstr = wf->ReadString( wf_entity, "color", NULL ); - if( colorstr ) - { - if( strcmp( colorstr, "random" ) == 0 ) - { - col = (uint32_t)random(); - col |= 0xFF000000; // set the alpha channel to max - } - else - col = stg_lookup_color( colorstr ); + this->SetColor( col ); + } + } - this->SetColor( col ); - } - } + if( wf->PropertyExists( wf_entity, "color_rgba" )) + { + double red = wf->ReadTupleFloat( wf_entity, "color_rgba", 0, 0); + double green = wf->ReadTupleFloat( wf_entity, "color_rgba", 1, 0); + double blue = wf->ReadTupleFloat( wf_entity, "color_rgba", 2, 0); + double alpha = wf->ReadTupleFloat( wf_entity, "color_rgba", 3, 0); - if( wf->PropertyExists( wf_entity, "color_rgba" )) - { - double red = wf->ReadTupleFloat( wf_entity, "color_rgba", 0, 0); - double green = wf->ReadTupleFloat( wf_entity, "color_rgba", 1, 0); - double blue = wf->ReadTupleFloat( wf_entity, "color_rgba", 2, 0); - double alpha = wf->ReadTupleFloat( wf_entity, "color_rgba", 3, 0); + this->SetColor( stg_color_pack( red, green, blue, alpha )); + } - this->SetColor( stg_color_pack( red, green, blue, alpha )); - } + if( wf->PropertyExists( wf_entity, "bitmap" ) ) + { + const char* bitmapfile = wf->ReadString( wf_entity, "bitmap", NULL ); + assert( bitmapfile ); - if( wf->PropertyExists( wf_entity, "bitmap" ) ) + char full[_POSIX_PATH_MAX]; + + if( bitmapfile[0] == '/' ) + strcpy( full, bitmapfile ); + else { - const char* bitmapfile = wf->ReadString( wf_entity, "bitmap", NULL ); - assert( bitmapfile ); + char *tmp = strdup(wf->filename); + snprintf( full, _POSIX_PATH_MAX, + "%s/%s", dirname(tmp), bitmapfile ); + free(tmp); + } - char full[_POSIX_PATH_MAX]; + PRINT_DEBUG1( "attempting to load image %s", full ); - if( bitmapfile[0] == '/' ) - strcpy( full, bitmapfile ); - else - { - char *tmp = strdup(wf->filename); - snprintf( full, _POSIX_PATH_MAX, - "%s/%s", dirname(tmp), bitmapfile ); - free(tmp); - } - - PRINT_DEBUG1( "attempting to load image %s", full ); - - stg_rotrect_t* rects = NULL; - unsigned int rect_count = 0; - unsigned int width, height; - if( stg_rotrects_from_image_file( full, + stg_rotrect_t* rects = NULL; + unsigned int rect_count = 0; + unsigned int width, height; + if( stg_rotrects_from_image_file( full, &rects, &rect_count, &width, &height ) ) - { - PRINT_ERR1( "failed to load rects from image file \"%s\"", - full ); - return; - } + { + PRINT_ERR1( "failed to load rects from image file \"%s\"", + full ); + return; + } - this->UnMap(); - this->ClearBlocks(); + this->UnMap(); + this->ClearBlocks(); - //printf( "found %d rects\n", rect_count ); + //printf( "found %d rects\n", rect_count ); - if( rects && (rect_count > 0) ) - { - //puts( "loading rects" ); - for( unsigned int r=0; r<rect_count; r++ ) - this->AddBlockRect( rects[r].pose.x, rects[r].pose.y, - rects[r].size.x, rects[r].size.y ); + if( rects && (rect_count > 0) ) + { + //puts( "loading rects" ); + for( unsigned int r=0; r<rect_count; r++ ) + this->AddBlockRect( rects[r].pose.x, rects[r].pose.y, + rects[r].size.x, rects[r].size.y ); - if( this->boundary ) - { - // add thin bounding blocks - double epsilon = 0.01; - this->AddBlockRect(0,0, epsilon, height ); - this->AddBlockRect(0,0, width, epsilon ); - this->AddBlockRect(0, height-epsilon, width, epsilon ); - this->AddBlockRect(width-epsilon,0, epsilon, height ); - } + if( this->boundary ) + { + // add thin bounding blocks + double epsilon = 0.01; + this->AddBlockRect(0,0, epsilon, height ); + this->AddBlockRect(0,0, width, epsilon ); + this->AddBlockRect(0, height-epsilon, width, epsilon ); + this->AddBlockRect(width-epsilon,0, epsilon, height ); + } - StgBlock::ScaleList( this->blocks, &this->geom.size ); - this->Map(); - this->NeedRedraw(); + StgBlock::ScaleList( this->blocks, &this->geom.size ); + this->Map(); + this->NeedRedraw(); - g_free( rects ); - } + g_free( rects ); + } - //printf( "model %s block count %d\n", - // token, g_list_length( blocks )); - } + //printf( "model %s block count %d\n", + // token, g_list_length( blocks )); + } - if( wf->PropertyExists( wf_entity, "blocks" ) ) - { - int blockcount = wf->ReadInt( wf_entity, "blocks", -1 ); + if( wf->PropertyExists( wf_entity, "blocks" ) ) + { + int blockcount = wf->ReadInt( wf_entity, "blocks", -1 ); - this->UnMap(); - this->ClearBlocks(); + this->UnMap(); + this->ClearBlocks(); - //printf( "expecting %d blocks\n", blockcount ); + //printf( "expecting %d blocks\n", blockcount ); - char key[256]; - for( int l=0; l<blockcount; l++ ) - { - snprintf(key, sizeof(key), "block[%d].points", l); - int pointcount = wf->ReadInt(wf_entity,key,0); + char key[256]; + for( int l=0; l<blockcount; l++ ) + { + snprintf(key, sizeof(key), "block[%d].points", l); + int pointcount = wf->ReadInt(wf_entity,key,0); - //printf( "expecting %d points in block %d\n", - //pointcount, l ); + //printf( "expecting %d points in block %d\n", + //pointcount, l ); - stg_point_t* pts = stg_points_create( pointcount ); + stg_point_t* pts = stg_points_create( pointcount ); - int p; - for( p=0; p<pointcount; p++ ) { - snprintf(key, sizeof(key), "block[%d].point[%d]", l, p ); + int p; + for( p=0; p<pointcount; p++ ) { + snprintf(key, sizeof(key), "block[%d].point[%d]", l, p ); - pts[p].x = wf->ReadTupleLength(wf_entity, key, 0, 0); - pts[p].y = wf->ReadTupleLength(wf_entity, key, 1, 0); + pts[p].x = wf->ReadTupleLength(wf_entity, key, 0, 0); + pts[p].y = wf->ReadTupleLength(wf_entity, key, 1, 0); - //printf( "key %s x: %.2f y: %.2f\n", - // key, pt.x, pt.y ); - } + //printf( "key %s x: %.2f y: %.2f\n", + // key, pt.x, pt.y ); + } - // block Z axis - snprintf(key, sizeof(key), "block[%d].z", l); + // block Z axis + snprintf(key, sizeof(key), "block[%d].z", l); - stg_meters_t zmin = - wf->ReadTupleLength(wf_entity, key, 0, 0.0 ); + stg_meters_t zmin = + wf->ReadTupleLength(wf_entity, key, 0, 0.0 ); - stg_meters_t zmax = - wf->ReadTupleLength(wf_entity, key, 1, 1.0 ); + stg_meters_t zmax = + wf->ReadTupleLength(wf_entity, key, 1, 1.0 ); - // block color - stg_color_t blockcol = this->color; - bool inherit_color = true; + // block color + stg_color_t blockcol = this->color; + bool inherit_color = true; - snprintf(key, sizeof(key), "block[%d].color", l); + snprintf(key, sizeof(key), "block[%d].color", l); - const char* colorstr = wf->ReadString( wf_entity, key, NULL ); - if( colorstr ) - { - blockcol = stg_lookup_color( colorstr ); - inherit_color = false; - } + const char* colorstr = wf->ReadString( wf_entity, key, NULL ); + if( colorstr ) + { + blockcol = stg_lookup_color( colorstr ); + inherit_color = false; + } - this->AddBlock( pts, pointcount, zmin, zmax, blockcol, inherit_color ); + this->AddBlock( pts, pointcount, zmin, zmax, blockcol, inherit_color ); - stg_points_destroy( pts ); - } + stg_points_destroy( pts ); + } - StgBlock::ScaleList( this->blocks, &this->geom.size ); + StgBlock::ScaleList( this->blocks, &this->geom.size ); - if( this->boundary ) - { - // add thin bounding blocks - double epsilon = 0.001; - double width = geom.size.x; - double height = geom.size.y; - this->AddBlockRect(-width/2.0, -height/2.0, epsilon, height ); - this->AddBlockRect(-width/2.0, -height/2.0, width, epsilon ); - this->AddBlockRect(-width/2.0, height/2.0-epsilon, width, epsilon ); - this->AddBlockRect(width/2.0-epsilon, -height/2.0, epsilon, height ); - } + if( this->boundary ) + { + // add thin bounding blocks + double epsilon = 0.001; + double width = geom.size.x; + double height = geom.size.y; + this->AddBlockRect(-width/2.0, -height/2.0, epsilon, height ); + this->AddBlockRect(-width/2.0, -height/2.0, width, epsilon ); + this->AddBlockRect(-width/2.0, height/2.0-epsilon, width, epsilon ); + this->AddBlockRect(width/2.0-epsilon, -height/2.0, epsilon, height ); + } - this->Map(); - } + this->Map(); + } - if( wf->PropertyExists( wf_entity, "mass" )) - this->SetMass( wf->ReadFloat(wf_entity, "mass", this->mass )); + if( wf->PropertyExists( wf_entity, "mass" )) + this->SetMass( wf->ReadFloat(wf_entity, "mass", this->mass )); - if( wf->PropertyExists( wf_entity, "fiducial_return" )) - this->SetFiducialReturn( wf->ReadInt( wf_entity, "fiducial_return", this->fiducial_return )); + if( wf->PropertyExists( wf_entity, "fiducial_return" )) + this->SetFiducialReturn( wf->ReadInt( wf_entity, "fiducial_return", this->fiducial_return )); - if( wf->PropertyExists( wf_entity, "fiducial_key" )) - this->SetFiducialKey( wf->ReadInt( wf_entity, "fiducial_key", this->fiducial_key )); + if( wf->PropertyExists( wf_entity, "fiducial_key" )) + this->SetFiducialKey( wf->ReadInt( wf_entity, "fiducial_key", this->fiducial_key )); - if( wf->PropertyExists( wf_entity, "obstacle_return" )) - this->SetObstacleReturn( wf->ReadInt( wf_entity, "obstacle_return", this->obstacle_return )); + if( wf->PropertyExists( wf_entity, "obstacle_return" )) + this->SetObstacleReturn( wf->ReadInt( wf_entity, "obstacle_return", this->obstacle_return )); - if( wf->PropertyExists( wf_entity, "ranger_return" )) - this->SetRangerReturn( wf->ReadInt( wf_entity, "ranger_return", this->ranger_return )); + if( wf->PropertyExists( wf_entity, "ranger_return" )) + this->SetRangerReturn( wf->ReadInt( wf_entity, "ranger_return", this->ranger_return )); - if( wf->PropertyExists( wf_entity, "blob_return" )) - this->SetBlobReturn( wf->ReadInt( wf_entity, "blob_return", this->blob_return )); + if( wf->PropertyExists( wf_entity, "blob_return" )) + this->SetBlobReturn( wf->ReadInt( wf_entity, "blob_return", this->blob_return )); - if( wf->PropertyExists( wf_entity, "laser_return" )) - this->SetLaserReturn( (stg_laser_return_t)wf->ReadInt(wf_entity, "laser_return", this->laser_return )); + if( wf->PropertyExists( wf_entity, "laser_return" )) + this->SetLaserReturn( (stg_laser_return_t)wf->ReadInt(wf_entity, "laser_return", this->laser_return )); - if( wf->PropertyExists( wf_entity, "gripper_return" )) - this->SetGripperReturn( wf->ReadInt( wf_entity, "gripper_return", this->gripper_return )); + if( wf->PropertyExists( wf_entity, "gripper_return" )) + this->SetGripperReturn( wf->ReadInt( wf_entity, "gripper_return", this->gripper_return )); - if( wf->PropertyExists( wf_entity, "gui_nose" )) - this->SetGuiNose( wf->ReadInt(wf_entity, "gui_nose", this->gui_nose )); + if( wf->PropertyExists( wf_entity, "gui_nose" )) + this->SetGuiNose( wf->ReadInt(wf_entity, "gui_nose", this->gui_nose )); - if( wf->PropertyExists( wf_entity, "gui_grid" )) - this->SetGuiGrid( wf->ReadInt(wf_entity, "gui_grid", this->gui_grid )); + if( wf->PropertyExists( wf_entity, "gui_grid" )) + this->SetGuiGrid( wf->ReadInt(wf_entity, "gui_grid", this->gui_grid )); - if( wf->PropertyExists( wf_entity, "gui_outline" )) - this->SetGuiOutline( wf->ReadInt(wf_entity, "gui_outline", this->gui_outline )); + if( wf->PropertyExists( wf_entity, "gui_outline" )) + this->SetGuiOutline( wf->ReadInt(wf_entity, "gui_outline", this->gui_outline )); - if( wf->PropertyExists( wf_entity, "gui_movemask" )) - this->SetGuiMask( wf->ReadInt(wf_entity, "gui_movemask", this->gui_mask )); + if( wf->PropertyExists( wf_entity, "gui_movemask" )) + this->SetGuiMask( wf->ReadInt(wf_entity, "gui_movemask", this->gui_mask )); - if( wf->PropertyExists( wf_entity, "map_resolution" )) - this->SetMapResolution( wf->ReadFloat(wf_entity, "map_resolution", this->map_resolution )); + if( wf->PropertyExists( wf_entity, "map_resolution" )) + this->SetMapResolution( wf->ReadFloat(wf_entity, "map_resolution", this->map_resolution )); - if( wf->PropertyExists( wf_entity, "ctrl" )) - { - char* lib = (char*)wf->ReadString(wf_entity, "ctrl", NULL ); + if( wf->PropertyExists( wf_entity, "ctrl" )) + { + char* lib = (char*)wf->ReadString(wf_entity, "ctrl", NULL ); - if( !lib ) - puts( "Error - NULL library name" ); - else - LoadControllerModule( lib ); - } + if( !lib ) + puts( "Error - NULL library name" ); + else + LoadControllerModule( lib ); + } - if( wf->PropertyExists( wf_entity, "say" )) - this->Say( wf->ReadString(wf_entity, "say", NULL )); + if( wf->PropertyExists( wf_entity, "say" )) + this->Say( wf->ReadString(wf_entity, "say", NULL )); - // call any type-specific load callbacks - this->CallCallbacks( &this->load_hook ); + // call any type-specific load callbacks + this->CallCallbacks( &this->load_hook ); - // MUST BE THE LAST THING LOADED - if( wf->PropertyExists( wf_entity, "alwayson" )) - { - if( wf->ReadInt( wf_entity, "alwayson", 0) > 0 ) - Startup(); - } + // MUST BE THE LAST THING LOADED + if( wf->PropertyExists( wf_entity, "alwayson" )) + { + if( wf->ReadInt( wf_entity, "alwayson", 0) > 0 ) + Startup(); + } - if( this->debug ) - printf( "Model \"%s\" is in debug mode\n", token ); + if( this->debug ) + printf( "Model \"%s\" is in debug mode\n", token ); - PRINT_DEBUG1( "Model \"%s\" loading complete", token ); + PRINT_DEBUG1( "Model \"%s\" loading complete", token ); } @@ -372,70 +367,70 @@ assert( wf ); assert( wf_entity ); - PRINT_DEBUG1( "Model \"%s\" saving...", token ); + PRINT_DEBUG1( "Model \"%s\" saving...", token ); - PRINT_DEBUG4( "saving model %s pose %.2f %.2f %.2f", - this->token, - this->pose.x, - this->pose.y, - this->pose.a ); + PRINT_DEBUG4( "saving model %s pose %.2f %.2f %.2f", + this->token, + this->pose.x, + this->pose.y, + this->pose.a ); - // right now we only save poses - wf->WriteTupleLength( wf_entity, "pose", 0, this->pose.x); - wf->WriteTupleLength( wf_entity, "pose", 1, this->pose.y); - wf->WriteTupleAngle( wf_entity, "pose", 2, this->pose.a); + // right now we only save poses + wf->WriteTupleLength( wf_entity, "pose", 0, this->pose.x); + wf->WriteTupleLength( wf_entity, "pose", 1, this->pose.y); + wf->WriteTupleAngle( wf_entity, "pose", 2, this->pose.a); - wf->WriteTupleLength( wf_entity, "pose3", 0, this->pose.x); - wf->WriteTupleLength( wf_entity, "pose3", 1, this->pose.y); - wf->WriteTupleLength( wf_entity, "pose3", 2, this->pose.z); - wf->WriteTupleAngle( wf_entity, "pose3", 3, this->pose.a); + wf->WriteTupleLength( wf_entity, "pose3", 0, this->pose.x); + wf->WriteTupleLength( wf_entity, "pose3", 1, this->pose.y); + wf->WriteTupleLength( wf_entity, "pose3", 2, this->pose.z); + wf->WriteTupleAngle( wf_entity, "pose3", 3, this->pose.a); - // call any type-specific save callbacks - this->CallCallbacks( &this->save_hook ); + // call any type-specific save callbacks + this->CallCallbacks( &this->save_hook ); - PRINT_DEBUG1( "Model \"%s\" saving complete.", token ); + PRINT_DEBUG1( "Model \"%s\" saving complete.", token ); } void StgModel::LoadControllerModule( char* lib ) { - printf( "[Ctrl \"%s\"", lib ); - fflush(stdout); + printf( "[Ctrl \"%s\"", lib ); + fflush(stdout); - /* Initialise libltdl. */ - int errors = lt_dlinit(); - assert(errors==0); + /* Initialise libltdl. */ + int errors = lt_dlinit(); + assert(errors==0); - char* stagepath = getenv("STAGEPATH"); - if( stagepath == NULL ) - stagepath = "."; + char* stagepath = getenv("STAGEPATH"); + if( stagepath == NULL ) + stagepath = (char*)"."; - lt_dlsetsearchpath( stagepath ); + lt_dlsetsearchpath( stagepath ); - lt_dlhandle handle = NULL; + lt_dlhandle handle = NULL; - if(( handle = lt_dlopenext( lib ) )) - { - printf( "]" ); + if(( handle = lt_dlopenext( lib ) )) + { + printf( "]" ); - this->initfunc = (ctrlinit_t*)lt_dlsym( handle, "Init" ); - if( this->initfunc == NULL ) - { - printf( "Libtool error: %s. Something is wrong with your plugin. Quitting\n", - lt_dlerror() ); // report the error from libtool - exit(-1); - } - } - else + this->initfunc = (ctrlinit_t*)lt_dlsym( handle, "Init" ); + if( this->initfunc == NULL ) { - printf( "Libtool error: %s. Can't open your plugin controller. Quitting\n", - lt_dlerror() ); // report the error from libtool - - PRINT_ERR1( "Failed to open \"%s\". Check that it can be found by searching the directories in your STAGEPATH environment variable, or the current directory if STAGEPATH is not set.]\n", lib ); - exit(-1); + printf( "Libtool error: %s. Something is wrong with your plugin. Quitting\n", + lt_dlerror() ); // report the error from libtool + exit(-1); } + } + else + { + printf( "Libtool error: %s. Can't open your plugin controller. Quitting\n", + lt_dlerror() ); // report the error from libtool - fflush(stdout); + PRINT_ERR1( "Failed to open \"%s\". Check that it can be found by searching the directories in your STAGEPATH environment variable, or the current directory if STAGEPATH is not set.]\n", lib ); + exit(-1); + } + + fflush(stdout); } Modified: code/stage/trunk/libstage/model_position.cc =================================================================== --- code/stage/trunk/libstage/model_position.cc 2008-07-04 22:10:13 UTC (rev 6764) +++ code/stage/trunk/libstage/model_position.cc 2008-07-04 22:58:26 UTC (rev 6765) @@ -170,12 +170,11 @@ // specified est_origin = this->GetGlobalPose(); - keyword = "localization_origin"; if( wf->PropertyExists( wf_entity, keyword ) ) { - est_origin.x = wf->ReadTupleLength( wf_entity, keyword, 0, est_origin.x ); - est_origin.y = wf->ReadTupleLength( wf_entity, keyword, 1, est_origin.y ); - est_origin.a = wf->ReadTupleAngle( wf_entity,keyword, 2, est_origin.a ); + est_origin.x = wf->ReadTupleLength( wf_entity, "localization_origin", 0, est_origin.x ); + est_origin.y = wf->ReadTupleLength( wf_entity, "localization_origin", 1, est_origin.y ); + est_origin.a = wf->ReadTupleAngle( wf_entity, "localization_origin", 2, est_origin.a ); // compute our localization pose based on the origin and true pose stg_pose_t gpose = this->GetGlobalPose(); @@ -195,15 +194,14 @@ } // odometry model parameters - keyword = "odom_error"; if( wf->PropertyExists( wf_entity, keyword ) ) { integration_error.x = - wf->ReadTupleLength( wf_entity, keyword, 0, integration_error.x ); + wf->ReadTupleLength( wf_entity, "odom_error", 0, integration_error.x ); integration_error.y = - wf->ReadTupleLength( wf_entity, keyword, 1, integration_error.y ); + wf->ReadTupleLength( wf_entity, "odom_error", 1, integration_error.y ); integration_error.a - = wf->ReadTupleAngle( wf_entity, keyword, 2, integration_error.a ); + = wf->ReadTupleAngle( wf_entity, "odom_error", 2, integration_error.a ); } // choose a localization model Modified: code/stage/trunk/libstage/stage.cc =================================================================== --- code/stage/trunk/libstage/stage.cc 2008-07-04 22:10:13 UTC (rev 6764) +++ code/stage/trunk/libstage/stage.cc 2008-07-04 22:58:26 UTC (rev 6765) @@ -193,7 +193,7 @@ if( file == NULL ) { - char* searchfiles[] = { + const char* searchfiles[] = { "./rgb.txt", #ifdef RGBFILE RGBFILE, @@ -205,7 +205,7 @@ searchfiles[i]; i++ ) { - char* filename = searchfiles[i]; + const char* filename = searchfiles[i]; PRINT_DEBUG1( "Attempting to open \"%s\"", filename ); if( (file = fopen( filename, "r")) ) break; // opened a file ok - jump out of for loop Modified: code/stage/trunk/libstage/stest.cc =================================================================== --- code/stage/trunk/libstage/stest.cc 2008-07-04 22:10:13 UTC (rev 6764) +++ code/stage/trunk/libstage/stest.cc 2008-07-04 22:58:26 UTC (rev 6765) @@ -25,8 +25,8 @@ StgModelLaser* laser; StgModelPosition* position; StgModelRanger* ranger; - StgModelFiducial* fiducial; - StgModelBlobfinder* blobfinder; + //StgModelFiducial* fiducial; + //StgModelBlobfinder* blobfinder; } robot_t; #define VSPEED 0.4 // meters per second @@ -58,16 +58,16 @@ for( int i=0; i<POPSIZE; i++ ) { - char* base = "r"; + const char* base = "r"; sprintf( namebuf, "%s%d", base, i ); robots[i].position = (StgModelPosition*)world.GetModel( namebuf ); assert(robots[i].position); robots[i].position->Subscribe(); - robots[i].laser = (StgModelLaser*) - robots[i].position->GetUnsubscribedModelOfType( "laser" ); - assert(robots[i].laser); - robots[i].laser->Subscribe(); + // robots[i].laser = (StgModelLaser*) +// robots[i].position->GetUnsubscribedModelOfType( MODEL_TYPE_LASER ); +// assert(robots[i].laser); + //robots[i].laser->Subscribe(); // robots[i].fiducial = (StgModelFiducial*) // robots[i].position->GetUnsubscribedModelOfType( "fiducial" ); @@ -75,7 +75,7 @@ // robots[i].fiducial->Subscribe(); robots[i].ranger = (StgModelRanger*) - robots[i].position->GetUnsubscribedModelOfType( "ranger" ); + robots[i].position->GetUnsubscribedModelOfType( MODEL_TYPE_RANGER ); assert(robots[i].ranger); robots[i].ranger->Subscribe(); @@ -86,11 +86,10 @@ } // start the clock - //world.Start(); - //puts( "done" ); + //world.Start();readltime //puts( "done" ); - while( ! world.TestQuit() ) - if( world.RealTimeUpdate() ) + while( 1 ) + if( world.Update() ) // if( world.Update() ) for( int i=0; i<POPSIZE; i++ ) { Modified: code/stage/trunk/libstage/test.cc =================================================================== --- code/stage/trunk/libstage/test.cc 2008-07-04 22:10:13 UTC (rev 6764) +++ code/stage/trunk/libstage/test.cc 2008-07-04 22:58:26 UTC (rev 6765) @@ -14,13 +14,13 @@ wg->Update(); } -void test( char* str, double a, double b ) +void test( const char* str, double a, double b ) { if( fabs(a-b) > epsilon ) printf( "FAIL %s expected %.3f saw %.3f\n", str, a, b ); } -void test( char* str, stg_pose_t a, stg_pose_t b ) +void test( const char* str, stg_pose_t a, stg_pose_t b ) { if( fabs(a.x-b.x) > epsilon ) printf( "POSE FAIL %s expected pose.x %.3f saw pose.x %.3f\n", str, a.x, b.x ); Modified: code/stage/trunk/libstage/world.cc =================================================================== --- code/stage/trunk/libstage/world.cc 2008-07-04 22:10:13 UTC (rev 6764) +++ code/stage/trunk/libstage/world.cc 2008-07-04 22:58:26 UTC (rev 6765) @@ -449,145 +449,152 @@ stg_raytrace_sample_t* sample, bool ztest ) { + // printf( "raytracing at [ %.2f %.2f %.2f %.2f ] for %.2f \n", +// pose.x, +// pose.y, +// pose.z, +// pose.a, +// range ); + // initialize the sample - memcpy( &sample->pose, &pose, sizeof(stg_pose_t)); // pose stays fixed - sample->range = range; // we might change this below - sample->block = NULL; // we might change this below + sample->pose = pose; + sample->range = range; // we might change this below + sample->block = NULL; // we might change this below + + // find the global integer bitmap address of the ray + int32_t x = (int32_t)(pose.x*ppm); + int32_t y = (int32_t)(pose.y*ppm); + int32_t z = 0; + + int32_t xstart = x; + int32_t ystart = y; + + // and the x and y offsets of the ray + int32_t dx = (int32_t)(ppm*range * cos(pose.a)); + int32_t dy = (int32_t)(ppm*range * sin(pose.a)); + int32_t dz = 0; + + // if( finder->debug ) + // RecordRay( pose.x, + // pose.y, + // pose.x + range.max * cos(pose.a), + // pose.y + range.max * sin(pose.a) ); + + // fast integer line 3d algorithm adapted from Cohen's code from + // Graphics Gems IV + int n, sx, sy, sz, exy, exz, ezy, ax, ay, az, bx, by, bz; + sx = sgn(dx); sy = sgn(dy); sz = sgn(dz); + ax = abs(dx); ay = abs(dy); az = abs(dz); + bx = 2*ax; by = 2*ay; bz = 2*az; + exy = ay-ax; exz = az-ax; ezy = ay-az; + n = ax+ay+az; + + // printf( "Raytracing from (%d,%d,%d) steps (%d,%d,%d) %d\n", + // x,y,z, dx,dy,dz, n ); + + // superregion coords + stg_point_int_t lastsup; + lastsup.x = INT_MAX; // an unlikely first raytrace + lastsup.y = INT_MAX; + + stg_point_int_t lastreg = {0,0}; + lastsup.x = INT_MAX; // an unlikely first raytrace + lastsup.y = INT_MAX; + + SuperRegion* sr = NULL; + Region* r = NULL; + + //puts( "RAYTRACE" ); + + while ( n-- ) + { + // superregion coords + stg_point_int_t sup; + sup.x = x >> SRBITS; + sup.y = y >> SRBITS; + + // printf( "pixel [%d %d]\tS[ %d %d ]\t", + // x, y, sup.x, sup.y ); - // find the global integer bitmap address of the ray - int32_t x = (int32_t)(pose.x*ppm); - int32_t y = (int32_t)(pose.y*ppm); - int32_t z = 0; + if( ! (sup.x == lastsup.x && sup.y == lastsup.y )) + { + sr = (SuperRegion*)g_hash_table_lookup( superregions, (void*)&sup ); + lastsup = sup; // remember these coords + } - int32_t xstart = x; - int32_t ystart = y; + if( sr ) + { + // find the region coords inside this superregion + stg_point_int_t reg; + reg.x = (x - ( sup.x << SRBITS)) >> RBITS; + reg.y = (y - ( sup.y << SRBITS)) >> RBITS; - // and the x and y offsets of the ray - int32_t dx = (int32_t)(ppm*range * cos(pose.a)); - int32_t dy = (int32_t)(ppm*range * sin(pose.a)); - int32_t dz = 0; + // printf( "R[ %d %d ]\t", reg.x, reg.y ); - // if( finder->debug ) - // RecordRay( pose.x, - // pose.y, - // pose.x + range.max * cos(pose.a), - // pose.y + range.max * sin(pose.a) ); + if( ! (reg.x == lastreg.x && reg.y == lastreg.y )) + { + r = sr->GetRegion( reg.x, reg.y ); + lastreg = reg; + } - // fast integer line 3d algorithm adapted from Cohen's code from - // Graphics Gems IV - int n, sx, sy, sz, exy, exz, ezy, ax, ay, az, bx, by, bz; - sx = sgn(dx); sy = sgn(dy); sz = sgn(dz); - ax = abs(dx); ay = abs(dy); az = abs(dz); - bx = 2*ax; by = 2*ay; bz = 2*az; - exy = ay-ax; exz = az-ax; ezy = ay-az; - n = ax+ay+az; + if( r && r->count ) + { + // compute the pixel offset inside this region + stg_point_int_t cell; + cell.x = x - ((sup.x << SRBITS) + (reg.x << RBITS)); + cell.y = y - ((sup.y << SRBITS) + (reg.y << RBITS)); - // printf( "Raytracing from (%d,%d,%d) steps (%d,%d,%d) %d\n", - // x,y,z, dx,dy,dz, n ); + // printf( "C[ %d %d ]\t", cell.x, cell.y ); - // superregion coords - stg_point_int_t lastsup; - lastsup.x = INT_MAX; // an unlikely first raytrace - lastsup.y = INT_MAX; + for( GSList* list = r->GetCell( cell.x, cell.y )->list; + list; + list = list->next ) + { + StgBlock* block = (StgBlock*)list->data; + assert( block ); - stg_point_int_t lastreg = {0,0}; - lastsup.x = INT_MAX; // an unlikely first raytrace - lastsup.y = INT_MAX; - - SuperRegion* sr = NULL; - Region* r = NULL; - - //puts( "RAYTRACE" ); - - while ( n-- ) - { - // superregion coords - stg_point_int_t sup; - sup.x = x >> SRBITS; - sup.y = y >> SRBITS; - - // printf( "pixel [%d %d]\tS[ %d %d ]\t", - // x, y, sup.x, sup.y ); - - if( ! (sup.x == lastsup.x && sup.y == lastsup.y )) - { - sr = (SuperRegion*)g_hash_table_lookup( superregions, (void*)&sup ); - lastsup = sup; // remember these coords + // if this block does not belong to the searching model and it + // matches the predicate and it's in the right z range + if( //block && (block->Model() != finder) && + (ztest ? block->IntersectGlobalZ( pose.z ) : true) && + (*func)( block, mod, arg ) ) + { + // a hit! + sample->block = block; + sample->range = hypot( (x-xstart)/ppm, (y-ystart)/ppm ); + return; + } } + } + } - if( sr ) - { - // find the region coords inside this superregion - stg_point_int_t reg; - reg.x = (x - ( sup.x << SRBITS)) >> RBITS; - reg.y = (y - ( sup.y << SRBITS)) >> RBITS; + // printf( "\t step %d n %d pixel [ %d, %d ] block [ %d %d ] index [ %d %d ] \n", + // //coarse [ %d %d ]\n", + // count++, n, x, y, blockx, blocky, b_dx, b_dy ); - // printf( "R[ %d %d ]\t", reg.x, reg.y ); - - if( ! (reg.x == lastreg.x && reg.y == lastreg.y )) - { - r = sr->GetRegion( reg.x, reg.y ); - lastreg = reg; - } - - if( r && r->count ) - { - // compute the pixel offset inside this region - stg_point_int_t cell; - cell.x = x - ((sup.x << SRBITS) + (reg.x << RBITS)); - cell.y = y - ((sup.y << SRBITS) + (reg.y << RBITS)); - - // printf( "C[ %d %d ]\t", cell.x, cell.y ); - - for( GSList* list = r->GetCell( cell.x, cell.y )->list; - list; - list = list->next ) - { - StgBlock* block = (StgBlock*)list->data; - assert( block ); - - // if this block does not belong to the searching model and it - // matches the predicate and it's in the right z range - if( //block && (block->Model() != finder) && - (ztest ? block->IntersectGlobalZ( pose.z ) : true) && - (*func)( block, mod, arg ) ) - { - // a hit! - sample->block = block; - sample->range = hypot( (x-xstart)/ppm, (y-ystart)/ppm ); - return; - } - } - } - } - - // printf( "\t step %d n %d pixel [ %d, %d ] block [ %d %d ] index [ %d %d ] \n", - // //coarse [ %d %d ]\n", - // count++, n, x, y, blockx, blocky, b_dx, b_dy ); - - // increment our pixel in the correct direction - if ( exy < 0 ) { - if ( exz < 0 ) { - x += sx; exy += by; exz += bz; - } - else { - z += sz; exz -= bx; ezy += by; - } - } - else { - if ( ezy < 0 ) { - z += sz; - exz -= bx; ezy += by; - } - else { - y += sy; exy -= bx; ezy -= bz; - } - } - // puts(""); + // increment our pixel in the correct direction + if ( exy < 0 ) { + if ( exz < 0 ) { + x += sx; exy += by; exz += bz; } + else { + z += sz; exz -= bx; ezy += by; + } + } + else { + if ( ezy < 0 ) { + z += sz; + exz -= bx; ezy += by; + } + else { + y += sy; exy -= bx; ezy -= bz; + } + } + // puts(""); + } - // hit nothing - return; + // hit nothing + return; } static void _save_cb( gpointer key, gpointer data, gpointer user ) Modified: code/stage/trunk/libstage/worldfile.cc =================================================================== --- code/stage/trunk/libstage/worldfile.cc 2008-07-04 22:10:13 UTC (rev 6764) +++ code/stage/trunk/libstage/worldfile.cc 2008-07-04 22:58:26 UTC (rev 6765) @@ -1402,7 +1402,7 @@ } -bool Worldfile::PropertyExists( int section, char* token ) +bool Worldfile::PropertyExists( int section, const char* token ) { return( this->GetProperty( section, token ) ? true : false ); } Modified: code/stage/trunk/libstage/worldfile.hh =================================================================== --- code/stage/trunk/libstage/worldfile.hh 2008-07-04 22:10:13 UTC (rev 6764) +++ code/stage/trunk/libstage/worldfile.hh 2008-07-04 22:58:26 UTC (rev 6765) @@ -268,7 +268,7 @@ // returns true iff the property exists in the file, so that you can // be sure that GetProperty() will work - bool PropertyExists( int section, char* token ); + bool PropertyExists( int section, const char* token ); // Set the value of an property. private: void SetPropertyValue( CProperty* property, int index, const char *value); Modified: code/stage/trunk/libstage/worldgui.cc =================================================================== --- code/stage/trunk/libstage/worldgui.cc 2008-07-04 22:10:13 UTC (rev 6764) +++ code/stage/trunk/libstage/worldgui.cc 2008-07-04 22:58:26 UTC (rev 6765) @@ -115,20 +115,25 @@ #endif StgWorldGui::StgWorldGui(int W,int H,const char* L) : - Fl_Window(W,H,L) + Fl_Window(W,H,L ) { //size_range( 100,100 ); // set minimum window size oDlg = NULL; graphics = true; paused = false; + // improve the title bar to say "Stage: <worldfile name>" + std::string title = "Stage: "; + title += L; + label( title.c_str() ); + interval_real = (stg_usec_t)thousand * DEFAULT_INTERVAL_REAL; for( unsigned int i=0; i<INTERVAL_LOG_LEN; i++ ) this->interval_log[i] = this->interval_real; // build the menus - mbar = new Fl_Menu_Bar(0,0, W, 30);// 640, 30); + mbar = new Fl_Menu_Bar(0,0, W, 30); mbar->textsize(12); canvas = new StgCanvas( this,0,30,W,H-30 ); @@ -166,6 +171,7 @@ delete canvas; } + void StgWorldGui::Load( const char* filename ) { PRINT_DEBUG1( "%s.Load()", token ); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <al...@us...> - 2008-07-04 16:32:57
|
Revision: 6766 http://playerstage.svn.sourceforge.net/playerstage/?rev=6766&view=rev Author: alexcb Date: 2008-07-04 16:33:05 -0700 (Fri, 04 Jul 2008) Log Message: ----------- modified clock string to indicate follow mode Modified Paths: -------------- code/stage/trunk/libstage/canvas.cc code/stage/trunk/libstage/stage.hh code/stage/trunk/libstage/worldgui.cc Modified: code/stage/trunk/libstage/canvas.cc =================================================================== --- code/stage/trunk/libstage/canvas.cc 2008-07-04 22:58:26 UTC (rev 6765) +++ code/stage/trunk/libstage/canvas.cc 2008-07-04 23:33:05 UTC (rev 6766) @@ -696,15 +696,18 @@ glPolygonMode( GL_FRONT_AND_BACK, GL_FILL ); - colorstack.Push( 0.8,0.8,1.0 ); // pale blue - glRectf( -w()/2, -h()/2, -w()/2 +120, -h()/2+20 ); - colorstack.Pop(); + std::string clockstr = world->ClockString(); + if( showFollow == true && last_selection ) + clockstr.append( " --FOLLOW MODE--" ); - char clockstr[50]; - world->ClockString( clockstr, 50 ); - + int width = clockstr.length() * 7; + + colorstack.Push( 0.8,0.8,1.0 ); // pale blue + glRectf( -w()/2, -h()/2, -w()/2 + width, -h()/2+20 ); + colorstack.Pop(); + colorstack.Push( 0,0,0 ); // black - gl_draw_string( -w()/2+4, -h()/2+4, 5, clockstr ); + gl_draw_string( -w()/2+4, -h()/2+4, 5, clockstr.c_str() ); colorstack.Pop(); glEnable( GL_DEPTH_TEST ); Modified: code/stage/trunk/libstage/stage.hh =================================================================== --- code/stage/trunk/libstage/stage.hh 2008-07-04 22:58:26 UTC (rev 6765) +++ code/stage/trunk/libstage/stage.hh 2008-07-04 23:33:05 UTC (rev 6766) @@ -2048,7 +2048,7 @@ /** Get human readable string that describes the current simulation time. */ - void ClockString( char* str, size_t maxlen ); + std::string ClockString( void ); /** Set the minimum real time interval between world updates, in microeconds. */ Modified: code/stage/trunk/libstage/worldgui.cc =================================================================== --- code/stage/trunk/libstage/worldgui.cc 2008-07-04 22:58:26 UTC (rev 6765) +++ code/stage/trunk/libstage/worldgui.cc 2008-07-04 23:33:05 UTC (rev 6766) @@ -108,6 +108,8 @@ #include <FL/Fl_File_Chooser.H> #include <set> +#include <sstream> +#include <iomanip> // this should be set by CMake #ifndef PACKAGE_STRING @@ -271,7 +273,7 @@ } -void StgWorldGui::ClockString( char* str, size_t maxlen ) +std::string StgWorldGui::ClockString() { const uint32_t usec_per_hour = 360000000; const uint32_t usec_per_minute = 60000000; @@ -290,32 +292,27 @@ average_real_interval /= INTERVAL_LOG_LEN; double localratio = (double)interval_sim / (double)average_real_interval; + + std::ostringstream status_stream; + status_stream.fill( '0' ); + if( hours > 0 ) + status_stream << hours << "h"; -#ifdef DEBUG - if( hours > 0 ) - snprintf( str, maxlen, "Time: %uh%02um%02u.%03us\t[%.6f]\tsubs: %d %s", - hours, minutes, seconds, msec, - localratio, - total_subs, - paused ? "--PAUSED--" : "" ); - else - snprintf( str, maxlen, "Time: %02um%02u.%03us\t[%.6f]\tsubs: %d %s", - minutes, seconds, msec, - localratio, - total_subs, - paused ? "--PAUSED--" : "" ); -#else - if( hours > 0 ) - snprintf( str, maxlen, "%uh%02um%02u.%03us\t[%.2f] %s", - hours, minutes, seconds, msec, - localratio, - paused ? "--PAUSED--" : "" ); - else - snprintf( str, maxlen, "%02um%02u.%03us\t[%.2f] %s", - minutes, seconds, msec, - localratio, - paused ? "--PAUSED--" : "" ); -#endif + localratio = 1; + + status_stream << std::setw( 2 ) << minutes << "m" + << std::setw( 2 ) << seconds << "." << std::setprecision( 3 ) << std::setw( 3 ) << msec << "s "; + + char str[ 80 ]; + snprintf( str, 80, "[%.2f]", localratio ); + status_stream << str; + + + if( paused == true ) + status_stream << " --PAUSED--"; + + + return status_stream.str(); } void StgWorldGui::DrawTree( bool drawall ) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <al...@us...> - 2008-07-04 17:10:04
|
Revision: 6768 http://playerstage.svn.sourceforge.net/playerstage/?rev=6768&view=rev Author: alexcb Date: 2008-07-04 17:10:12 -0700 (Fri, 04 Jul 2008) Log Message: ----------- modified deselection to allow moving the world while keeping a selected group selected Modified Paths: -------------- code/stage/trunk/libstage/canvas.cc code/stage/trunk/libstage/stage.hh Modified: code/stage/trunk/libstage/canvas.cc =================================================================== --- code/stage/trunk/libstage/canvas.cc 2008-07-04 23:45:09 UTC (rev 6767) +++ code/stage/trunk/libstage/canvas.cc 2008-07-05 00:10:12 UTC (rev 6768) @@ -225,27 +225,14 @@ switch(event) { case FL_MOUSEWHEEL: - if( selected_models ) - { - // rotate all selected models - for( GList* it = selected_models; it; it=it->next ) - { - StgModel* mod = (StgModel*)it->data; - mod->AddToPose( 0,0,0, 0.1*(double)Fl::event_dy() ); - } - redraw(); + if( perspectiveCam == true ) { + perspective_camera.scroll( Fl::event_dy() / 10.0 ); } - else - { - if( perspectiveCam == true ) { - perspective_camera.scroll( Fl::event_dy() / 10.0 ); - } - else { - camera.scale( Fl::event_dy(), Fl::event_x(), w(), Fl::event_y(), h() ); - } - invalidate(); - redraw(); + else { + camera.scale( Fl::event_dy(), Fl::event_x(), w(), Fl::event_y(), h() ); } + invalidate(); + redraw(); return 1; case FL_MOVE: // moused moved while no button was pressed @@ -291,7 +278,11 @@ selectedModel = false; switch( Fl::event_button() ) { - case 1: + case 1: + clicked_empty_space = ( mod == NULL ); + empty_space_startx = startx; + empty_space_starty = starty; + std::cout << "clicked: " << startx << " " << Fl::event_x() << std::endl; if( mod ) { // clicked a model if ( Fl::event_state( FL_SHIFT ) ) { @@ -314,10 +305,7 @@ selectedModel = true; // selected a model } } - else { - // clicked on empty space, unselect all - unSelectAll(); - } + return 1; case 3: { @@ -377,7 +365,10 @@ } // end case FL_DRAG case FL_RELEASE: // mouse button released - + if( empty_space_startx == Fl::event_x() && empty_space_starty == Fl::event_y() && clicked_empty_space == true ) { + // clicked on empty space, unselect all + unSelectAll(); + } return 1; case FL_FOCUS: Modified: code/stage/trunk/libstage/stage.hh =================================================================== --- code/stage/trunk/libstage/stage.hh 2008-07-04 23:45:09 UTC (rev 6767) +++ code/stage/trunk/libstage/stage.hh 2008-07-05 00:10:12 UTC (rev 6768) @@ -1929,6 +1929,8 @@ int startx, starty; bool selectedModel; + bool clicked_empty_space; + int empty_space_startx, empty_space_starty; GList* selected_models; ///< a list of models that are currently ///selected by the user StgModel* last_selection; ///< the most recently selected model This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <al...@us...> - 2008-07-04 17:59:20
|
Revision: 6772 http://playerstage.svn.sourceforge.net/playerstage/?rev=6772&view=rev Author: alexcb Date: 2008-07-04 17:59:26 -0700 (Fri, 04 Jul 2008) Log Message: ----------- fixed picker bug introduced by camera model Modified Paths: -------------- code/stage/trunk/libstage/camera.cc code/stage/trunk/libstage/canvas.cc code/stage/trunk/libstage/stage.hh Modified: code/stage/trunk/libstage/camera.cc =================================================================== --- code/stage/trunk/libstage/camera.cc 2008-07-05 00:43:45 UTC (rev 6771) +++ code/stage/trunk/libstage/camera.cc 2008-07-05 00:59:26 UTC (rev 6772) @@ -105,18 +105,27 @@ } -void StgOrthoCamera::SetProjection( float pixels_width, float pixels_height, float y_min, float y_max ) const +void StgOrthoCamera::SetProjection( void ) const { glMatrixMode (GL_PROJECTION); glLoadIdentity (); - - glOrtho( -pixels_width/2.0 / _scale, pixels_width/2.0 / _scale, - -pixels_height/2.0 / _scale, pixels_height/2.0 / _scale, - y_min * _scale * 2, y_max * _scale * 2 ); - + + glOrtho( -_pixels_width/2.0 / _scale, _pixels_width/2.0 / _scale, + -_pixels_height/2.0 / _scale, _pixels_height/2.0 / _scale, + _y_min * _scale * 2, _y_max * _scale * 2 ); + glMatrixMode (GL_MODELVIEW); } +void StgOrthoCamera::SetProjection( float pixels_width, float pixels_height, float y_min, float y_max ) +{ + _pixels_width = pixels_width; + _pixels_height = pixels_height; + _y_min = y_min; + _y_max = y_max; + SetProjection(); +} + //TODO re-evaluate the way the camera is shifted when the mouse zooms - it might be possible to simplify void StgOrthoCamera::scale( float scale, float shift_x, float w, float shift_y, float h ) { Modified: code/stage/trunk/libstage/canvas.cc =================================================================== --- code/stage/trunk/libstage/canvas.cc 2008-07-05 00:43:45 UTC (rev 6771) +++ code/stage/trunk/libstage/canvas.cc 2008-07-05 00:59:26 UTC (rev 6772) @@ -93,8 +93,10 @@ glClearColor ( 1,1,1,1 ); // white glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT ); glPolygonMode( GL_FRONT_AND_BACK, GL_FILL ); + glLoadIdentity(); + current_camera->SetProjection(); + current_camera->Draw(); - glDisable(GL_DITHER); glDisable(GL_BLEND); // turns off alpha blending, so we read back // exactly what we write to a pixel @@ -155,6 +157,8 @@ glEnable(GL_BLEND); glClearColor ( 0.7, 0.7, 0.8, 1.0); + Screenshot(); + return mod; } @@ -284,7 +288,6 @@ clicked_empty_space = ( mod == NULL ); empty_space_startx = startx; empty_space_starty = starty; - std::cout << "clicked: " << startx << " " << Fl::event_x() << std::endl; if( mod ) { // clicked a model if ( Fl::event_state( FL_SHIFT ) ) { Modified: code/stage/trunk/libstage/stage.hh =================================================================== --- code/stage/trunk/libstage/stage.hh 2008-07-05 00:43:45 UTC (rev 6771) +++ code/stage/trunk/libstage/stage.hh 2008-07-05 00:59:26 UTC (rev 6772) @@ -1791,6 +1791,7 @@ virtual ~StgCamera() { } virtual void Draw( void ) const = 0; + virtual void SetProjection( void ) const = 0; inline float yaw( void ) const { return _yaw; } inline float pitch( void ) const { return _pitch; } @@ -1857,10 +1858,16 @@ private: float _scale; + float _pixels_width; + float _pixels_height; + float _y_min; + float _y_max; + public: StgOrthoCamera( void ) : _scale( 15 ) { } virtual void Draw() const; - virtual void SetProjection( float pixels_width, float pixels_height, float y_min, float y_max ) const; + virtual void SetProjection( float pixels_width, float pixels_height, float y_min, float y_max ); + virtual void SetProjection( void ) const; inline void move( float x, float y ) { //convert screen points into world points This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <al...@us...> - 2008-07-07 11:12:12
|
Revision: 6783 http://playerstage.svn.sourceforge.net/playerstage/?rev=6783&view=rev Author: alexcb Date: 2008-07-07 11:12:19 -0700 (Mon, 07 Jul 2008) Log Message: ----------- fixed draging models bug created by camera model dirtying the offscreen buffer Modified Paths: -------------- code/stage/trunk/libstage/canvas.cc code/stage/trunk/libstage/model_camera.cc code/stage/trunk/libstage/stage.hh Modified: code/stage/trunk/libstage/canvas.cc =================================================================== --- code/stage/trunk/libstage/canvas.cc 2008-07-07 16:30:32 UTC (rev 6782) +++ code/stage/trunk/libstage/canvas.cc 2008-07-07 18:12:19 UTC (rev 6783) @@ -68,6 +68,7 @@ perspective_camera.setPose( -3.0, 0.0, 1.0 ); perspective_camera.setPitch( 70.0 ); //look down current_camera = &camera; + setDirtyBuffer(); startx = starty = 0; //panx = pany = stheta = sphi = 0.0; @@ -213,6 +214,17 @@ else if( py >= h() ) py = h() - 1; + //redraw the screen only if the camera model isn't active. + //TODO new selection technique will simply use drawfloor to result in z = 0 always and prevent strange behaviours near walls + //TODO refactor, so glReadPixels reads (then caches) the whole screen only when the camera changes. + if( true || dirtyBuffer() ) { + glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT ); + current_camera->SetProjection(); + current_camera->Draw(); + DrawFloor(); //call this rather than renderFrame for speed - this won't give correct z values + dirty_buffer = false; + } + int viewport[4]; glGetIntegerv(GL_VIEWPORT, viewport); @@ -220,11 +232,12 @@ glGetDoublev(GL_MODELVIEW_MATRIX, modelview); GLdouble projection[16]; - glGetDoublev(GL_PROJECTION_MATRIX, projection); + glGetDoublev(GL_PROJECTION_MATRIX, projection); GLfloat pz; glReadPixels( px, h()-py, 1, 1, GL_DEPTH_COMPONENT, GL_FLOAT, &pz ); gluUnProject( px, w()-py, pz, modelview, projection, viewport, wx,wy,wz ); + } int StgCanvas::handle(int event) Modified: code/stage/trunk/libstage/model_camera.cc =================================================================== --- code/stage/trunk/libstage/model_camera.cc 2008-07-07 16:30:32 UTC (rev 6782) +++ code/stage/trunk/libstage/model_camera.cc 2008-07-07 18:12:19 UTC (rev 6783) @@ -232,6 +232,7 @@ glViewport( viewport[0], viewport[1], viewport[2], viewport[3] ); _canvas->invalidate(); + _canvas->setDirtyBuffer(); return true; } Modified: code/stage/trunk/libstage/stage.hh =================================================================== --- code/stage/trunk/libstage/stage.hh 2008-07-07 16:30:32 UTC (rev 6782) +++ code/stage/trunk/libstage/stage.hh 2008-07-07 18:12:19 UTC (rev 6783) @@ -1931,7 +1931,8 @@ StgCamera* current_camera; StgOrthoCamera camera; StgPerspectiveCamera perspective_camera; - + bool dirty_buffer; + int startx, starty; bool selectedModel; bool clicked_empty_space; @@ -1998,6 +1999,9 @@ void unSelect( StgModel* mod ); void unSelectAll(); + inline void setDirtyBuffer( void ) { dirty_buffer = true; } + inline bool dirtyBuffer( void ) const { return dirty_buffer; } + inline void PushColor( stg_color_t col ) { colorstack.Push( col ); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <rt...@us...> - 2008-07-07 19:50:29
|
Revision: 6798 http://playerstage.svn.sourceforge.net/playerstage/?rev=6798&view=rev Author: rtv Date: 2008-07-07 19:50:39 -0700 (Mon, 07 Jul 2008) Log Message: ----------- cleaning up dead files Modified Paths: -------------- code/stage/trunk/libstage/CMakeLists.txt code/stage/trunk/libstage/main.cc Removed Paths: ------------- code/stage/trunk/libstage/Makefile.fl code/stage/trunk/libstage/Makefile.manual code/stage/trunk/libstage/ctrl.cc Modified: code/stage/trunk/libstage/CMakeLists.txt =================================================================== --- code/stage/trunk/libstage/CMakeLists.txt 2008-07-08 01:27:11 UTC (rev 6797) +++ code/stage/trunk/libstage/CMakeLists.txt 2008-07-08 02:50:39 UTC (rev 6798) @@ -78,3 +78,5 @@ INSTALL(FILES stage.hh option.hh worldfile.hh DESTINATION include/${PROJECT_NAME}-${V_MAJOR}.${V_MINOR}) + +ADD_TEST( test1 ${EXECUTABLE_OUTPUT_PATH}stage ../worlds/fasr.world) Deleted: code/stage/trunk/libstage/Makefile.fl =================================================================== --- code/stage/trunk/libstage/Makefile.fl 2008-07-08 01:27:11 UTC (rev 6797) +++ code/stage/trunk/libstage/Makefile.fl 2008-07-08 02:50:39 UTC (rev 6798) @@ -1,40 +0,0 @@ -HEADERS = \ - ../config.h \ - colors.h \ - stage.hh \ - worldfile.hh - -CC = g++ - -OBS = \ - ancestor.o \ - block.o \ - blockgrid.o \ - canvas.o \ - glcolorstack.o \ - model.o \ - model_callbacks.o \ - model_laser.o \ - model_load.o \ - model_position.o \ - model_props.o \ - model_ranger.o \ - stest.o \ - stage.o \ - typetable.o \ - world.o \ - worldfile.o \ - worldgui.o - -CPPFLAGS= -g -Wall -I.. -I../replace -I/System/Library/Frameworks/OpenGL.framework/Headers `fltk-config --use-gl --cflags` `pkg-config --cflags glib-2.0 gdk-pixbuf-2.0` -LIBS= `fltk-config --use-gl --ldflags` `pkg-config --libs gdk-pixbuf-2.0` -framework OpenGL - - -all: stagefl - -stagefl: $(OBS) $(HEADERS) - g++ -o $@ $(CPPFLAGS) $(OBS) $(LIBS) - -clean : - rm -f *.o *.lo - Deleted: code/stage/trunk/libstage/Makefile.manual =================================================================== --- code/stage/trunk/libstage/Makefile.manual 2008-07-08 01:27:11 UTC (rev 6797) +++ code/stage/trunk/libstage/Makefile.manual 2008-07-08 02:50:39 UTC (rev 6798) @@ -1,59 +0,0 @@ - -HDR = \ - ../config.h \ - colors.h \ - stage.hh \ - stage_internalmake.hh \ - worldfile.hh - -SRC = \ - ancestor.cc \ - block.cc \ - canvas.cc \ - gl.cc \ - glcolorstack.cc \ - main.cc \ - model.cc \ - model_callbacks.cc \ - model_ranger.cc \ - model_blobfinder.cc \ - model_laser.cc \ - model_fiducial.cc \ - model_load.cc \ - model_position.cc \ - model_props.cc \ - stage.cc \ - typetable.cc \ - world.cc \ - worldfile.cc \ - worldgui.cc - -# blockgrid.cc -# stest.cc - - - -CXXFLAGS+= -g -Wall -I.. -I../replace `fltk-config --use-gl --use-images --cflags` `pkg-config --cflags glib-2.0 gdk-pixbuf-2.0` -LIBS= `fltk-config --use-gl --use-images --ldflags` `pkg-config --libs gdk-pixbuf-2.0` - -OBJ=$(SRC:.cc=.o) - -all: stage - -.cc.o: - g++ $(CXXFLAGS) -c $< - - -stage: $(OBJ) - g++ $(OBJ) -o $@ $(LIBS) - -clean : - rm -f *.o *.lo stage - -demo: gldemo.cc - g++ gldemo.cc -o $@ $(LIBS) - -ctrl: ctrl.cc - g++ $(CXXFLAGS) -fPIC -c ctrl.cc - g++ -shared -o libctrl.so -fPIC ctrl.o - Deleted: code/stage/trunk/libstage/ctrl.cc =================================================================== --- code/stage/trunk/libstage/ctrl.cc 2008-07-08 01:27:11 UTC (rev 6797) +++ code/stage/trunk/libstage/ctrl.cc 2008-07-08 02:50:39 UTC (rev 6798) @@ -1,121 +0,0 @@ -#include "stage.hh" -using namespace Stg; - -const double cruisespeed = 0.4; -const double avoidspeed = 0.05; -const double avoidturn = 1.0; -const double minfrontdistance = 0.8; -const bool verbose = false; - -typedef struct -{ - StgModelPosition* pos; - StgModelLaser* laser; - int avoidcount, randcount; -} robot_t; - -int LaserUpdate( StgModel* mod, robot_t* robot ); -int PositionUpdate( StgModel* mod, robot_t* robot ); - -// Stage calls this when the model starts up -extern "C" int Init( StgModel* mod ) -{ - robot_t* robot = new robot_t; - - robot->pos = (StgModelPosition*)mod; - robot->laser = (StgModelLaser*)mod->GetModel( "laser:0" ); - robot->avoidcount = 0; - robot->randcount = 0; - - assert( robot->laser ); - robot->laser->Subscribe(); - - robot->laser->AddUpdateCallback( (stg_model_callback_t)LaserUpdate, robot ); - //robot->pos->AddUpdateCallback( (stg_model_callback_t)PositionUpdate, robot ); - return 0; //ok -} - -// inspect the laser data and decide what to do -int LaserUpdate( StgModel* mod, robot_t* robot ) -{ - // get the data - uint32_t sample_count=0; - stg_laser_sample_t* scan = robot->laser->GetSamples( &sample_count ); - assert(scan); - - double newturnrate=0.0, newspeed=0.0; - bool obstruction = false; - - // find the closest distance to the left and right and check if - // there's anything in front - double minleft = 1e6; - double minright = 1e6; - - for (uint32_t i = 0; i < sample_count; i++) - { - if( scan[i].range < minfrontdistance) - obstruction = true; - - if( i > sample_count/2 ) - minleft = MIN( minleft, scan[i].range ); - else - minright = MIN( minright, scan[i].range ); - } - - if( obstruction || robot->avoidcount ) - { - if( verbose ) puts( "Avoid" ); - - robot->pos->SetXSpeed( avoidspeed ); - - /* once we start avoiding, select a turn direction and stick - with it for a few iterations */ - if( robot->avoidcount == 0 ) - { - if( verbose ) puts( "Avoid START" ); - robot->avoidcount = 5; - - if( minleft < minright ) - robot->pos->SetTurnSpeed( -avoidturn ); - else - robot->pos->SetTurnSpeed( +avoidturn ); - } - - robot->avoidcount--; - } - else - { - if( verbose ) puts( "Cruise" ); - - robot->avoidcount = 0; - robot->pos->SetXSpeed( cruisespeed ); - - /* update turnrate every few updates */ - if( robot->randcount == 0 ) - { - if( verbose )puts( "Random turn" ); - - /* make random int tween -30 and 30 */ - //newturnrate = dtor( rand() % 61 - 30 ); - - robot->randcount = 20; - - robot->pos->SetTurnSpeed( dtor( rand() % 11 - 5 ) ); - } - - robot->randcount--; - } - - return 0; -} - -int PositionUpdate( StgModel* mod, robot_t* robot ) -{ - stg_pose_t pose = robot->pos->GetPose(); - - printf( "Pose: [%.2f %.2f %.2f %.2f]\n", - pose.x, pose.y, pose.z, pose.a ); - - return 0; // run again -} - Modified: code/stage/trunk/libstage/main.cc =================================================================== --- code/stage/trunk/libstage/main.cc 2008-07-08 01:27:11 UTC (rev 6797) +++ code/stage/trunk/libstage/main.cc 2008-07-08 02:50:39 UTC (rev 6798) @@ -7,6 +7,7 @@ #include <getopt.h> #include "stage_internal.hh" +#include "config.h" /* options descriptor */ static struct option longopts[] = { @@ -17,7 +18,7 @@ int main( int argc, char* argv[] ) { - //printf( "%s %s ", PROJECT, VERSION ); + printf( "%s %s ", PROJECT, VERSION ); int ch=0, optindex=0; bool usegui = true; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <al...@us...> - 2008-07-08 10:25:50
|
Revision: 6814 http://playerstage.svn.sourceforge.net/playerstage/?rev=6814&view=rev Author: alexcb Date: 2008-07-08 10:25:59 -0700 (Tue, 08 Jul 2008) Log Message: ----------- cleaned up camera class so pitch/yaw is the same sign for both types of camera Modified Paths: -------------- code/stage/trunk/libstage/camera.cc code/stage/trunk/libstage/canvas.cc code/stage/trunk/libstage/model.cc code/stage/trunk/libstage/stage.hh Modified: code/stage/trunk/libstage/camera.cc =================================================================== --- code/stage/trunk/libstage/camera.cc 2008-07-08 16:44:11 UTC (rev 6813) +++ code/stage/trunk/libstage/camera.cc 2008-07-08 17:25:59 UTC (rev 6814) @@ -114,8 +114,8 @@ glMatrixMode (GL_MODELVIEW); glLoadIdentity (); - glRotatef( _pitch, 1.0, 0.0, 0.0 ); - glRotatef( _yaw, 0.0, 0.0, 1.0 ); + glRotatef( - _pitch, 1.0, 0.0, 0.0 ); + glRotatef( - _yaw, 0.0, 0.0, 1.0 ); glTranslatef( - _x, - _y, 0.0 ); //zooming needs to happen in the Projection code (don't use glScale for zoom) Modified: code/stage/trunk/libstage/canvas.cc =================================================================== --- code/stage/trunk/libstage/canvas.cc 2008-07-08 16:44:11 UTC (rev 6813) +++ code/stage/trunk/libstage/canvas.cc 2008-07-08 17:25:59 UTC (rev 6814) @@ -268,8 +268,8 @@ perspective_camera.addPitch( -dy ); } else { - camera.setPitch( 0.5 * static_cast<double>( dy ) ); - camera.setYaw( 0.5 * static_cast<double>( dx ) ); + camera.setPitch( - 0.5 * static_cast<double>( dy ) ); + camera.setYaw( - 0.5 * static_cast<double>( dx ) ); } invalidate(); redraw(); @@ -563,9 +563,9 @@ void StgCanvas::renderFrame() { //before drawing, order all models based on distance from camera - float x = camera.x(); - float y = camera.y(); - float sphi = dtor( camera.yaw() ); + float x = current_camera->x(); + float y = current_camera->y(); + float sphi = -dtor( current_camera->yaw() ); //estimate point of camera location - hard to do with orthogonal mode x += -sin( sphi ) * 100; Modified: code/stage/trunk/libstage/model.cc =================================================================== --- code/stage/trunk/libstage/model.cc 2008-07-08 16:44:11 UTC (rev 6813) +++ code/stage/trunk/libstage/model.cc 2008-07-08 17:25:59 UTC (rev 6814) @@ -944,14 +944,9 @@ if( say_string ) { float yaw, pitch; - pitch = canvas->current_camera->pitch(); - yaw = canvas->current_camera->yaw(); + pitch = - canvas->current_camera->pitch(); + yaw = - canvas->current_camera->yaw(); - if( canvas->perspectiveCam == true ) { - pitch = -pitch; - yaw = -yaw; - } - float robotAngle = -rtod(pose.a); glPushMatrix(); @@ -1015,15 +1010,14 @@ void StgModel::DrawImage( uint32_t texture_id, Stg::StgCanvas* canvas, float alpha ) { - float stheta = -dtor( canvas->current_camera->pitch() ); - float sphi = dtor( canvas->current_camera->yaw() ); + float stheta = dtor( canvas->current_camera->pitch() ); + float sphi = - dtor( canvas->current_camera->yaw() ); if( canvas->perspectiveCam == true ) { sphi = atan2( ( pose.x - canvas->current_camera->x() ) , ( pose.y - canvas->current_camera->y() ) ); - stheta = -stheta; } glEnable(GL_TEXTURE_2D); Modified: code/stage/trunk/libstage/stage.hh =================================================================== --- code/stage/trunk/libstage/stage.hh 2008-07-08 16:44:11 UTC (rev 6813) +++ code/stage/trunk/libstage/stage.hh 2008-07-08 17:25:59 UTC (rev 6814) @@ -1874,9 +1874,9 @@ inline void setYaw( float yaw ) { _yaw += yaw; } inline void setPitch( float pitch ) { _pitch += pitch; - if( _pitch < -90 ) - _pitch = -90; - else if( _pitch > 0 ) + if( _pitch > 90 ) + _pitch = 90; + else if( _pitch < 0 ) _pitch = 0; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <al...@us...> - 2008-07-08 11:22:23
|
Revision: 6817 http://playerstage.svn.sourceforge.net/playerstage/?rev=6817&view=rev Author: alexcb Date: 2008-07-08 11:22:33 -0700 (Tue, 08 Jul 2008) Log Message: ----------- more camera cleanup Modified Paths: -------------- code/stage/trunk/libstage/camera.cc code/stage/trunk/libstage/canvas.cc Modified: code/stage/trunk/libstage/camera.cc =================================================================== --- code/stage/trunk/libstage/camera.cc 2008-07-08 17:58:53 UTC (rev 6816) +++ code/stage/trunk/libstage/camera.cc 2008-07-08 18:22:33 UTC (rev 6817) @@ -190,8 +190,7 @@ if( to_scale > 0 ) { //zoom in _scale *= factor; - move( shift_x * w / _scale * _scale, - - shift_y * h / _scale * _scale ); + move( shift_x * w, - shift_y * h ); } else { //zoom out Modified: code/stage/trunk/libstage/canvas.cc =================================================================== --- code/stage/trunk/libstage/canvas.cc 2008-07-08 17:58:53 UTC (rev 6816) +++ code/stage/trunk/libstage/canvas.cc 2008-07-08 18:22:33 UTC (rev 6817) @@ -1000,7 +1000,6 @@ } else { stg_bounds3d_t extent = world->GetExtent(); camera.SetProjection( w(), h(), extent.y.min, extent.y.max ); - camera.Draw(); current_camera = &camera; } @@ -1010,26 +1009,19 @@ glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT ); } - - if( pCamOn == true ) { - if( showFollow && last_selection ) { - //Follow the selected robot - stg_pose_t gpose = last_selection->GetGlobalPose(); + + //Follow the selected robot + if( showFollow && last_selection ) { + stg_pose_t gpose = last_selection->GetGlobalPose(); + if( pCamOn == true ) { perspective_camera.setPose( gpose.x, gpose.y, 0.2 ); perspective_camera.setYaw( rtod( gpose.a ) - 90.0 ); - + } else { + camera.setPose( gpose.x, gpose.y ); } - perspective_camera.Draw(); - } else if( showFollow && last_selection ) { - //Follow the selected robot - stg_pose_t gpose = last_selection->GetGlobalPose(); - camera.setPose( gpose.x, gpose.y ); - - stg_bounds3d_t extent = world->GetExtent(); - camera.SetProjection( w(), h(), extent.y.min, extent.y.max ); - camera.Draw(); } - + + current_camera->Draw(); renderFrame(); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jer...@us...> - 2008-07-08 16:41:22
|
Revision: 6825 http://playerstage.svn.sourceforge.net/playerstage/?rev=6825&view=rev Author: jeremy_asher Date: 2008-07-08 16:41:30 -0700 (Tue, 08 Jul 2008) Log Message: ----------- Added Id property to files using $ keyword Modified Paths: -------------- code/stage/trunk/libstage/canvas.cc code/stage/trunk/libstage/stage.hh code/stage/trunk/libstage/stage_internal.hh code/stage/trunk/libstage/stagecpp.cc code/stage/trunk/libstage/worldfile.cc code/stage/trunk/libstage/worldfile.hh Property Changed: ---------------- code/stage/trunk/libstage/canvas.cc code/stage/trunk/libstage/option.hh code/stage/trunk/libstage/stage.hh code/stage/trunk/libstage/stage_internal.hh code/stage/trunk/libstage/stagecpp.cc code/stage/trunk/libstage/texture_manager.cc code/stage/trunk/libstage/worldfile.cc code/stage/trunk/libstage/worldfile.hh Modified: code/stage/trunk/libstage/canvas.cc =================================================================== --- code/stage/trunk/libstage/canvas.cc 2008-07-08 23:35:07 UTC (rev 6824) +++ code/stage/trunk/libstage/canvas.cc 2008-07-08 23:41:30 UTC (rev 6825) @@ -3,7 +3,7 @@ Authors: Richard Vaughan (va...@sf...) Alex Couture-Beil (as...@sf...) Jeremy Asher (jr...@sf...) - $Id: canvas.cc,v 1.12 2008-03-03 07:01:12 rtv Exp $ + $Id$ */ #include "stage_internal.hh" Property changes on: code/stage/trunk/libstage/canvas.cc ___________________________________________________________________ Name: svn:keywords + Id Property changes on: code/stage/trunk/libstage/option.hh ___________________________________________________________________ Name: svn:keywords + Id Modified: code/stage/trunk/libstage/stage.hh =================================================================== --- code/stage/trunk/libstage/stage.hh 2008-07-08 23:35:07 UTC (rev 6824) +++ code/stage/trunk/libstage/stage.hh 2008-07-08 23:41:30 UTC (rev 6825) @@ -27,7 +27,7 @@ * Desc: External header file for the Stage library * Author: Richard Vaughan (va...@sf...) * Date: 1 June 2003 - * CVS: $Id: stage.hh,v 1.15 2008-04-01 23:57:41 rtv Exp $ + * CVS: $Id$ */ /*! \file stage.h Property changes on: code/stage/trunk/libstage/stage.hh ___________________________________________________________________ Name: svn:keywords + Id Modified: code/stage/trunk/libstage/stage_internal.hh =================================================================== --- code/stage/trunk/libstage/stage_internal.hh 2008-07-08 23:35:07 UTC (rev 6824) +++ code/stage/trunk/libstage/stage_internal.hh 2008-07-08 23:41:30 UTC (rev 6825) @@ -2,7 +2,7 @@ files include this header Author: Richard Vaughan (va...@sf...) Date: 13 Jan 2008 - $Id: stage_internal.hh,v 1.2 2008-01-15 01:16:49 rtv Exp $ + $Id$ */ #ifndef STG_INTERNAL_H Property changes on: code/stage/trunk/libstage/stage_internal.hh ___________________________________________________________________ Name: svn:keywords + Id Modified: code/stage/trunk/libstage/stagecpp.cc =================================================================== --- code/stage/trunk/libstage/stagecpp.cc 2008-07-08 23:35:07 UTC (rev 6824) +++ code/stage/trunk/libstage/stagecpp.cc 2008-07-08 23:41:30 UTC (rev 6825) @@ -1,6 +1,6 @@ // Thin-as-possible C Wrappers for C++ worldfile calls, using a single static worldfile. // This is a hacky use of the old C++ worldfile code. -// $Id: stagecpp.cc,v 1.2 2008-01-15 01:16:49 rtv Exp $ +// $Id$ #include "stage_internal.h" #include "gui.h" Property changes on: code/stage/trunk/libstage/stagecpp.cc ___________________________________________________________________ Name: svn:keywords + Id Property changes on: code/stage/trunk/libstage/texture_manager.cc ___________________________________________________________________ Name: svn:keywords + Id Modified: code/stage/trunk/libstage/worldfile.cc =================================================================== --- code/stage/trunk/libstage/worldfile.cc 2008-07-08 23:35:07 UTC (rev 6824) +++ code/stage/trunk/libstage/worldfile.cc 2008-07-08 23:41:30 UTC (rev 6825) @@ -24,7 +24,7 @@ * Douglas S. Blank <db...@br...> * * Date: 15 Nov 2001 - * CVS info: $Id: worldfile.cc,v 1.4 2008-04-01 23:57:41 rtv Exp $ + * CVS info: $Id$ */ #include <assert.h> Property changes on: code/stage/trunk/libstage/worldfile.cc ___________________________________________________________________ Name: svn:keywords + Id Modified: code/stage/trunk/libstage/worldfile.hh =================================================================== --- code/stage/trunk/libstage/worldfile.hh 2008-07-08 23:35:07 UTC (rev 6824) +++ code/stage/trunk/libstage/worldfile.hh 2008-07-08 23:41:30 UTC (rev 6825) @@ -21,7 +21,7 @@ * Desc: A class for reading in the world file. * Author: Andrew Howard * Date: 15 Nov 2001 - * CVS info: $Id: worldfile.hh,v 1.2 2008-01-15 01:16:49 rtv Exp $ + * CVS info: $Id$ */ #ifndef WORLDFILE_HH Property changes on: code/stage/trunk/libstage/worldfile.hh ___________________________________________________________________ Name: svn:keywords + Id This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jer...@us...> - 2008-07-09 13:29:34
|
Revision: 6827 http://playerstage.svn.sourceforge.net/playerstage/?rev=6827&view=rev Author: jeremy_asher Date: 2008-07-09 13:29:43 -0700 (Wed, 09 Jul 2008) Log Message: ----------- Documentation work Modified Paths: -------------- code/stage/trunk/libstage/camera.cc code/stage/trunk/libstage/stage.hh code/stage/trunk/libstage/world.cc code/stage/trunk/libstage/worldgui.cc Modified: code/stage/trunk/libstage/camera.cc =================================================================== --- code/stage/trunk/libstage/camera.cc 2008-07-09 01:00:59 UTC (rev 6826) +++ code/stage/trunk/libstage/camera.cc 2008-07-09 20:29:43 UTC (rev 6827) @@ -87,9 +87,9 @@ } void StgPerspectiveCamera::Load( Worldfile* wf, int sec ) { - float x_pos = wf->ReadTupleFloat(sec, "pcam_loc", 0, x() ); - float y_pos = wf->ReadTupleFloat(sec, "pcam_loc", 1, y() ); - float z_pos = wf->ReadTupleFloat(sec, "pcam_loc", 2, z() ); + float x_pos = wf->ReadTupleLength(sec, "pcam_loc", 0, x() ); + float y_pos = wf->ReadTupleLength(sec, "pcam_loc", 1, y() ); + float z_pos = wf->ReadTupleLength(sec, "pcam_loc", 2, z() ); setPose( x_pos, y_pos, z_pos ); setPitch( wf->ReadTupleFloat( sec, "pcam_angle", 0, pitch() ) ); setYaw( wf->ReadTupleFloat( sec, "pcam_angle", 1, yaw() ) ); @@ -206,8 +206,8 @@ } void StgOrthoCamera::Load( Worldfile* wf, int sec ) { - float x_pos = wf->ReadTupleFloat(sec, "center", 0, x() ); - float y_pos = wf->ReadTupleFloat(sec, "center", 1, y() ); + float x_pos = wf->ReadTupleLength(sec, "center", 0, x() ); + float y_pos = wf->ReadTupleLength(sec, "center", 1, y() ); setPose( x_pos, y_pos ); setPitch( wf->ReadTupleFloat( sec, "rotate", 0, pitch() ) ); setYaw( wf->ReadTupleFloat( sec, "rotate", 1, yaw() ) ); Modified: code/stage/trunk/libstage/stage.hh =================================================================== --- code/stage/trunk/libstage/stage.hh 2008-07-09 01:00:59 UTC (rev 6826) +++ code/stage/trunk/libstage/stage.hh 2008-07-09 20:29:43 UTC (rev 6827) @@ -959,7 +959,7 @@ class Region; class SuperRegion; -/// StgWorld class +/// %StgWorld class class StgWorld : public StgAncestor { friend class StgModel; // allow access to private members @@ -1141,7 +1141,7 @@ typedef int ctrlinit_t( StgModel* mod ); //typedef void ctrlupdate_t( StgModel* mod ); -/// StgModel class +/// %StgModel class class StgModel : public StgAncestor { friend class StgAncestor; @@ -2063,7 +2063,7 @@ stg_meters_t range; } stg_blobfinder_blob_t; -/// StgModelBlobfinder class +/// %StgModelBlobfinder class class StgModelBlobfinder : public StgModel { private: @@ -2173,7 +2173,7 @@ stg_radians_t fov; } stg_laser_cfg_t; -/// StgModelLaser class +/// %StgModelLaser class class StgModelLaser : public StgModel { private: @@ -2346,7 +2346,7 @@ } stg_fiducial_t; -/// StgModelFiducial class +/// %StgModelFiducial class class StgModelFiducial : public StgModel { private: @@ -2399,7 +2399,7 @@ int ray_count; } stg_ranger_sensor_t; -/// StgModelRanger class +/// %StgModelRanger class class StgModelRanger : public StgModel { protected: @@ -2459,7 +2459,7 @@ GLfloat x, y, z; } ColoredVertex; -/// StgModelCamera class +/// %StgModelCamera class class StgModelCamera : public StgModel { private: @@ -2549,7 +2549,7 @@ } stg_position_drive_mode_t; -/// StgModelPosition class +/// %StgModelPosition class class StgModelPosition : public StgModel { private: Modified: code/stage/trunk/libstage/world.cc =================================================================== --- code/stage/trunk/libstage/world.cc 2008-07-09 01:00:59 UTC (rev 6826) +++ code/stage/trunk/libstage/world.cc 2008-07-09 20:29:43 UTC (rev 6827) @@ -11,27 +11,21 @@ @verbatim -title "[defaults to worldfile filename]" interval_real 100 interval_sim 100 -gui_interval 100 resolution 0.02 @endverbatim @par Details -- name [string] -- the name of the world, as displayed in the window title bar. Defaults to the worldfile file name. -- interval_sim [milliseconds] -- the length of each simulation update cycle in milliseconds. -- interval_real [milliseconds] -- the amount of real-world (wall-clock) time the siulator will attempt to spend on each simulation cycle. -- gui_interval [milliseconds] -- the amount of real-world time between GUI updates -- resolution [meters] -- specifies the resolution of the underlying bitmap model. Larger values speed up raytracing at the expense of fidelity in collision detection and sensing. -@par More examples +- interval_sim <int>\n +the length of each simulation update cycle in milliseconds. +- interval_real <int>\n +the amount of real-world (wall-clock) time the siulator will attempt to spend on each simulation cycle. +- resolution <float>\n +The resolution (in meters) of the underlying bitmap model. Larger values speed up raytracing at the expense of fidelity in collision detection and sensing. +@par More examples The Stage source distribution contains several example world files in <tt>(stage src)/worlds</tt> along with the worldfile properties described on the manual page for each model type. Modified: code/stage/trunk/libstage/worldgui.cc =================================================================== --- code/stage/trunk/libstage/worldgui.cc 2008-07-09 01:00:59 UTC (rev 6826) +++ code/stage/trunk/libstage/worldgui.cc 2008-07-09 20:29:43 UTC (rev 6827) @@ -27,80 +27,88 @@ @verbatim window ( - # gui properties - center [0 0] - size [700 740] - scale 1.0 + size [ 400 300 ] + + # camera options + center [ 0 0 ] + rotate [ 0 0 ] + scale 1.0 + + # perspective camera options + pcam_loc [ 0 -4 2 ] + pcam_angle [ 70 0 ] + pcam_on 0 - # model properties do not apply to the gui window + # model properties do not apply to the gui window ) @endverbatim @par Details - - title [string] - - the string displayed in the window title bar. Defaults to the worldfile file name. - - size [width:int width:int] - - size of the window in pixels - - center [x:float y:float] - - location of the center of the window in world coordinates (meters) - - scale [?:double] - - ratio of world to pixel coordinates (window zoom) + - size [ <width:int> <height:int> ]\n + size of the window in pixels + - center [ <x:float> <y:float> ]\n + location of the center of the window in world coordinates (meters) + - rotate [ <pitch:float> <yaw:float> ]\n + angle relative to straight up, angle of rotation (degrees) + - scale <float>\n + ratio of world to pixel coordinates (window zoom) + - pcam_loc [ <x:int> <y:int> <z:int> ]\n + location of the perspective camera (meters) + - pcam_angle [ <pitch:float> <yaw:float> ]\n + verticle and horizontal angle of the perspective camera + - pcam_on <int>\n + whether to start with the perspective camera enabled (0/1) <h2>Using the Stage window</h2> + - <h3>Scrolling the view</h3> - <p>Left-click and drag on the background to move your view of the world. <h3>Zooming the view</h3> - - <p>Right-click and drag on the background to zoom your view of the - world. When you press the right mouse button, a circle appears. Moving - the mouse adjusts the size of the circle; the current view is scaled - with the circle. - + <p>Scroll the mouse wheel to zoom in or out on the mouse cursor. + <h3>Saving the world</h3> - <P>You can save the current pose of everything in the world, using the File/Save menu item. <b>Warning: the saved poses overwrite the current world file.</b> Make a copy of your world file before saving if you - want to keep the old poses. - - - <h3>Saving a screenshot</h3> - - <p> The File/Export menu allows you to export a screenshot of the - current world view in JPEG or PNG format. The frame is saved in the - current directory with filename in the format "stage-(frame - number).(jpg/png)". - - You can also save sequences of screen shots. To start saving a - sequence, select the desired time interval from the same menu, then - select File/Export/Sequence of frames. The frames are saved in the - current directory with filenames in the format "stage-(sequence - number)-(frame number).(jpg/png)". - - The frame and sequence numbers are reset to zero every time you run - Stage, so be careful to rename important frames before they are - overwritten. - + want to keep the old poses. Alternatively the File/Save As menu item + can be used to save to a new world file. + <h3>Pausing and resuming the clock</h3> + <p>The simulation can be paused or resumed by pressing the space key. + + <h3>Selecting models</h3> + <p>Models can be selected by clicking on them with the left mouse button. + It is possible to select multiple models by holding the shift key and + clicking on multiple models. Selected models can be moved by dragging or + rotated by right click dragging. Selections can be cleared by clicking on + an empty location in the world. After clearing the selection, the last + single model selected will be saved as the target for several view options + described below which affect a particular model. - <p>The Clock/Pause menu item allows you to stop the simulation clock, - freezing the world. Selecting this item again re-starts the clock. - - <h3>View options</h3> + <p>The View menu provides access to a number of features affecting how + the world is rendered. To the right of each option there is usually + a keyboard hotkey which can be pressed to quickly toggle the relevant + option. + + <p>Sensor data visualizations can be toggled by the "Data" option. + The filter data option opens a dialog which provides the ability + to turn on and off visualizations of particular sensors. The "Visualize All" + option in the dialog toggles whether sensor visualizations are enabled + for all models or only the currently selected ones. + + <p>The "Follow" option keeps the view centered on the last selected model. + + <p>The "Perspective camera" option switches from orthogonal viewing to perspective viewing. + + <h3>Saving a screenshot</h3> + <p> To save a sequence of screenshots of the world, select the "Save + screenshots" option from the view menu to start recording images and + then select the option from the menu again to stop. - <p>The View menu allows you to toggle rendering of a 1m grid, to help - you line up objects (View/Grid). You can control whether polygons are - filled (View/Fill polygons); turning this off slightly improves - graphics performance. The rest of the view menu contains options for - rendering of data and configuration for each type of model, and a - debug menu that enables visualization of some of the innards of Stage. - */ #include <FL/Fl_Image.H> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jer...@us...> - 2008-07-10 11:09:45
|
Revision: 6835 http://playerstage.svn.sourceforge.net/playerstage/?rev=6835&view=rev Author: jeremy_asher Date: 2008-07-10 11:09:53 -0700 (Thu, 10 Jul 2008) Log Message: ----------- Model documentation Modified Paths: -------------- code/stage/trunk/libstage/model.cc code/stage/trunk/libstage/model_load.cc Modified: code/stage/trunk/libstage/model.cc =================================================================== --- code/stage/trunk/libstage/model.cc 2008-07-10 02:09:02 UTC (rev 6834) +++ code/stage/trunk/libstage/model.cc 2008-07-10 18:09:53 UTC (rev 6835) @@ -3,8 +3,8 @@ The basic model simulates an object with basic properties; position, size, velocity, color, visibility to various sensors, etc. The basic model also has a body made up of a list of lines. Internally, the -basic model is used base class for all other model types. You can use -the basic model to simulate environmental objects. +basic model is used as the base class for all other model types. You +can use the basic model to simulate environmental objects. API: Stg::StgModel @@ -15,30 +15,43 @@ @verbatim model ( - pose [ 0 0 ] - size [ 1.0 1.0 ] - origin [ 0 0 0 ] - velocity [ 0 0 0 ] + pose [ 0 0 0 0 ] + size [ 0.1 0.1 0.1 ] + origin [ 0 0 0 0 ] + velocity [ 0 0 0 0 ] - # body color - color "red" + color "red" + color_rgba [ 0 0 0 1 ] + + boundary 0 + blocks -1 + mass 10 # determine how the model appears in various sensors + fiducial_return 0 + fiducial_key 0 obstacle_return 1 - laser_return 1 ranger_return 1 - blobfinder_return 1 - fiducial_return 1 + blob_return 1 + laser_return LaserVisible gripper_return 0 - fiducial_key 0 + # GUI properties gui_nose 0 gui_grid 0 - gui_boundary 0 - gui_movemask ? + gui_outline 1 ( was gui_boundary? ) + gui_movemask 0 top level or (STG_MOVE_TRANS | STG_MOVE_ROT); bitmap "" + + ctrl "" + + map_resolution 0.1 + + say "" + + alwayson 0 ) @endverbatim @@ -104,11 +117,10 @@ //#define DEBUG 0 #include "stage_internal.hh" #include "texture_manager.hh" -#include <limits.h> +//#include <limits.h> //static const members -static const bool DEFAULT_BLOBRETURN = true; static const bool DEFAULT_BOUNDARY = false; static const stg_color_t DEFAULT_COLOR = (0xFFFF0000); // solid red static const stg_joules_t DEFAULT_ENERGY_CAPACITY = 1000.0; @@ -127,6 +139,7 @@ static const stg_kg_t DEFAULT_MASS = 10.0; static const bool DEFAULT_NOSE = false; static const bool DEFAULT_OBSTACLERETURN = true; +static const bool DEFAULT_BLOBRETURN = true; static const bool DEFAULT_OUTLINE = true; static const bool DEFAULT_RANGERRETURN = true; Modified: code/stage/trunk/libstage/model_load.cc =================================================================== --- code/stage/trunk/libstage/model_load.cc 2008-07-10 02:09:02 UTC (rev 6834) +++ code/stage/trunk/libstage/model_load.cc 2008-07-10 18:09:53 UTC (rev 6835) @@ -110,10 +110,10 @@ if( wf->PropertyExists( wf_entity, "color_rgba" )) { - double red = wf->ReadTupleFloat( wf_entity, "color_rgba", 0, 0); - double green = wf->ReadTupleFloat( wf_entity, "color_rgba", 1, 0); - double blue = wf->ReadTupleFloat( wf_entity, "color_rgba", 2, 0); - double alpha = wf->ReadTupleFloat( wf_entity, "color_rgba", 3, 0); + double red = wf->ReadTupleFloat( wf_entity, "color_rgba", 0, 0 ); + double green = wf->ReadTupleFloat( wf_entity, "color_rgba", 1, 0 ); + double blue = wf->ReadTupleFloat( wf_entity, "color_rgba", 2, 0 ); + double alpha = wf->ReadTupleFloat( wf_entity, "color_rgba", 3, 1 ); this->SetColor( stg_color_pack( red, green, blue, alpha )); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jer...@us...> - 2008-07-10 14:49:15
|
Revision: 6837 http://playerstage.svn.sourceforge.net/playerstage/?rev=6837&view=rev Author: jeremy_asher Date: 2008-07-10 14:49:23 -0700 (Thu, 10 Jul 2008) Log Message: ----------- Worldfile documentation updates Modified Paths: -------------- code/stage/trunk/libstage/model.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_position.cc code/stage/trunk/libstage/model_ranger.cc Modified: code/stage/trunk/libstage/model.cc =================================================================== --- code/stage/trunk/libstage/model.cc 2008-07-10 18:32:37 UTC (rev 6836) +++ code/stage/trunk/libstage/model.cc 2008-07-10 21:49:23 UTC (rev 6837) @@ -15,17 +15,13 @@ @verbatim model ( - pose [ 0 0 0 0 ] + pose [ 0.0 0.0 0.0 0.0 ] size [ 0.1 0.1 0.1 ] - origin [ 0 0 0 0 ] - velocity [ 0 0 0 0 ] + origin [ 0.0 0.0 0.0 0.0 ] + velocity [ 0.0 0.0 0.0 0.0 ] color "red" - color_rgba [ 0 0 0 1 ] - - boundary 0 - blocks -1 - mass 10 + color_rgba [ 0.0 0.0 0.0 1.0 ] # determine how the model appears in various sensors fiducial_return 0 @@ -36,21 +32,19 @@ laser_return LaserVisible gripper_return 0 - # GUI properties gui_nose 0 gui_grid 0 gui_outline 1 ( was gui_boundary? ) gui_movemask 0 top level or (STG_MOVE_TRANS | STG_MOVE_ROT); + boundary 0 + blocks -1 + mass 10.0 bitmap "" - ctrl "" - map_resolution 0.1 - say "" - alwayson 0 ) @endverbatim Modified: code/stage/trunk/libstage/model_blobfinder.cc =================================================================== --- code/stage/trunk/libstage/model_blobfinder.cc 2008-07-10 18:32:37 UTC (rev 6836) +++ code/stage/trunk/libstage/model_blobfinder.cc 2008-07-10 21:49:23 UTC (rev 6837) @@ -46,38 +46,32 @@ @par Summary and default values @verbatim -ptz( -# blobfinder MUST be a child of a PTZ model blobfinder ( -# blobfinder properties -colors_count 6 -colors ["red" "green" "blue" "cyan" "yellow" "magenta" ] -range 8.0 -ptz[0 0 60.0] -image[80 60] + # blobfinder properties + colors_count 0 + colors [ ] + image[ 80 60 ] + range 12.0 + fov 3.14159/3.0 + pan 0.0 -# model properties -size3 [0 0 0] + # model properties + size [ 0.0 0.0 0.0 ] ) -) @endverbatim @par Details -- colors_count int -- number of colors being tracked -- colors [ string ... ] -- define the colors detected in each channel, using color names from the X11-style color database -The number of strings should match colors_count. -- image [int int] -- [width height] -- dimensions of the image in pixels. This determines the blobfinder's -resolution -- ptz [float float float] -- [pan_angle tilt_angle zoom_angle] -- control the panning, tilt and fov angle (zoom) of the blobfinder. Tilt angle currently has no effect. -- range float -- maximum range of the sensor in meters. +- colors_count <int>\n + number of colors being tracked +- colors [ col1:<string> col2:<string> ... ]\n + A list of quoted strings defining the colors detected in each channel, using color names from the X11-style color database (ex. "black", "red"). + The number of strings should match colors_count. +- image [ width:<int> height:<int> ]\n + dimensions of the image in pixels. This determines the blobfinder's resolution +- range <float>\n + maximum range of the sensor in meters. + */ Modified: code/stage/trunk/libstage/model_camera.cc =================================================================== --- code/stage/trunk/libstage/model_camera.cc 2008-07-10 18:32:37 UTC (rev 6836) +++ code/stage/trunk/libstage/model_camera.cc 2008-07-10 21:49:23 UTC (rev 6837) @@ -19,59 +19,61 @@ Option StgModelCamera::showCameraData( "Show Camera Data", "show_camera", "", true ); -static const stg_size_t DEFAULT_SIZE = {0.1, 0.07, 0.05 }; +static const stg_size_t DEFAULT_SIZE = { 0.1, 0.07, 0.05 }; static const char DEFAULT_GEOM_COLOR[] = "black"; +static const float DEFAULT_HFOV = 70; +static const float DEFAULT_VFOV = 40; /** - @ingroup model - @defgroup model_camera Camera model - The camera model simulates a camera - - API: Stg::StgModelCamera - - <h2>Worldfile properties</h2> - - @par Summary and default values - - @verbatim - camera - ( - # laser properties - width 32 - height 32 - range_min 0.0 - range_max 8.0 - horizfov 60.0 - vertfov 60.0 - yaw 0.0 - pitch 90.0 - - # model properties - size [0.15 0.15] - color "black" - watts 100.0 # TODO find watts for sony pan-tilt camera - ) - @endverbatim - - @par Details - - width int - - the number of pixel samples - - height int - - the number of pixel samples - - range_min float - - the minimum range reported by the camera, in meters. Objects closer than this will not be displayed. The smaller the number, the less persision in depth - don't set this value too close to 0. - - range_max float - - the maximum range reported by the camera, in meters. Objects farther than this will not be displayed. - - horizfov float - - angle, in degrees, for the horizontal field of view. - - vertfov float - - angle, in degrees, for the vertical field of view. - - yaw float - - angle, in degrees, where the camera is panned to. - - pitch float - - angle, in degrees, where the camera is tilted to. - */ +@ingroup model +@defgroup model_camera Camera model +The camera model simulates a camera +API: Stg::StgModelCamera + +<h2>Worldfile properties</h2> + +@par Summary and default values + +@verbatim +camera +( + # laser properties + width 32 + height 32 + range_min 0.2 + range_max 8.0 + horizfov 70.0 + vertfov 40.0 + yaw 0.0 + pitch 0.0 + + # model properties + size [ 0.1 0.07 0.05 ] + color "black" + watts 100.0 # TODO find watts for sony pan-tilt camera +) +@endverbatim + +@par Details +- width <int>\n + the number of pixel samples +- height <int>\n + the number of pixel samples +- range_min <float>\n + the minimum range reported by the camera, in meters. Objects closer than this will not be displayed. The smaller the number, the less persision in depth - don't set this value too close to 0. +- range_max <float>\n + the maximum range reported by the camera, in meters. Objects farther than this will not be displayed. +- horizfov <float>\n + angle, in degrees, for the horizontal field of view. +- vertfov <float>\n + angle, in degrees, for the vertical field of view. +- yaw <float>\n + angle, in degrees, where the camera is panned to. +- pitch <float>\n + angle, in degrees, where the camera is tilted to. +*/ + //caclulate the corss product, and store results in the first vertex void cross( float& x1, float& y1, float& z1, float x2, float y2, float z2 ) { @@ -146,9 +148,13 @@ { StgModel::Load(); - _camera.setFov( wf->ReadLength( wf_entity, "horizfov", _camera.horizFov() ), wf->ReadLength( wf_entity, "vertfov", _camera.vertFov() ) ); + float horizFov = wf->ReadFloat( wf_entity, "horizfov", DEFAULT_HFOV ); + float vertFov = wf->ReadFloat( wf_entity, "vertfov", DEFAULT_VFOV ); + _camera.setFov( horizFov, vertFov ); - _camera.setClip( wf->ReadLength( wf_entity, "range_min", CAMERA_NEAR_CLIP ), wf->ReadLength( wf_entity, "range_max", CAMERA_FAR_CLIP ) ); + float range_min = wf->ReadLength( wf_entity, "range_min", CAMERA_NEAR_CLIP ); + float range_max = wf->ReadLength( wf_entity, "range_max", CAMERA_FAR_CLIP ); + _camera.setClip( range_min, range_max ); _yaw_offset = wf->ReadFloat( wf_entity, "yaw", _yaw_offset ); _pitch_offset = wf->ReadFloat( wf_entity, "pitch", _pitch_offset ); Modified: code/stage/trunk/libstage/model_fiducial.cc =================================================================== --- code/stage/trunk/libstage/model_fiducial.cc 2008-07-10 18:32:37 UTC (rev 6836) +++ code/stage/trunk/libstage/model_fiducial.cc 2008-07-10 21:49:23 UTC (rev 6837) @@ -40,26 +40,26 @@ @verbatim fiducialfinder ( -# fiducialfinder properties -range_min 0.0 -range_max 8.0 -range_max_id 5.0 -fov 180.0 + # fiducialfinder properties + range_min 0.0 + range_max 8.0 + range_max_id 5.0 + fov 3.14159 -# model properties -size [0 0] + # model properties + size [ 0.1 0.1 0.1 ] ) @endverbatim @par Details -- range_min float -- the minimum range reported by the sensor, in meters. The sensor will detect objects closer than this, but report their range as the minimum. -- range_max float -- the maximum range at which the sensor can detect a fiducial, in meters. The sensor may not be able to uinquely identify the fiducial, depending on the value of range_max_id. -- range_max_id float -- the maximum range at which the sensor can detect the ID of a fiducial, in meters. -- fov float -- the angular field of view of the scanner, in degrees. +- range_min <float>\n + the minimum range reported by the sensor, in meters. The sensor will detect objects closer than this, but report their range as the minimum. +- range_max <float>\n + the maximum range at which the sensor can detect a fiducial, in meters. The sensor may not be able to uinquely identify the fiducial, depending on the value of range_max_id. +- range_max_id <float>\n + the maximum range at which the sensor can detect the ID of a fiducial, in meters. +- fov <float> + the angular field of view of the scanner, in radians. */ Modified: code/stage/trunk/libstage/model_laser.cc =================================================================== --- code/stage/trunk/libstage/model_laser.cc 2008-07-10 18:32:37 UTC (rev 6836) +++ code/stage/trunk/libstage/model_laser.cc 2008-07-10 21:49:23 UTC (rev 6837) @@ -37,43 +37,44 @@ Option StgModelLaser::showLaserStrikes( "Show Laser Data", "show_laser_strikes", "", false ); /** - @ingroup model - @defgroup model_laser Laser model - The laser model simulates a scanning laser rangefinder +@ingroup model +@defgroup model_laser Laser model +The laser model simulates a scanning laser rangefinder - API: Stg::StgModelLaser +API: Stg::StgModelLaser - <h2>Worldfile properties</h2> +<h2>Worldfile properties</h2> - @par Summary and default values +@par Summary and default values - @verbatim - laser - ( - # laser properties - samples 180 - range_min 0.0 - range_max 8.0 - fov 180.0 +@verbatim +laser +( + # laser properties + samples 180 + range_min 0.0 + range_max 8.0 + fov 3.14159 + laser_sample_skip 1 - # model properties - size [0.15 0.15] - color "blue" - watts 17.5 # approximately correct for SICK LMS200 - ) - @endverbatim + # model properties + size [ 0.15 0.15 0.2 ] + color "blue" + watts 17.5 # approximately correct for SICK LMS200 +) +@endverbatim - @par Details - - samples int - - the number of laser samples per scan - - range_min float - - the minimum range reported by the scanner, in meters. The scanner will detect objects closer than this, but report their range as the minimum. - - range_max float - - the maximum range reported by the scanner, in meters. The scanner will not detect objects beyond this range. - - fov float - - the angular field of view of the scanner, in degrees. - - laser_sample_skip - - Only calculate the true range of every nth laser sample. The missing samples are filled in with a linear interpolation. Generally it would be better to use fewer samples, but some (poorly implemented!) programs expect a fixed number of samples. Setting this number > 1 allows you to reduce the amount of computation required for your fixed-size laser vector. +@par Details +- samples <int>\n + the number of laser samples per scan +- range_min <float>\n + the minimum range reported by the scanner, in meters. The scanner will detect objects closer than this, but report their range as the minimum. +- range_max <float>\n + the maximum range reported by the scanner, in meters. The scanner will not detect objects beyond this range. +- fov <float>\n + the angular field of view of the scanner, in radians. +- laser_sample_skip <int>\n + Only calculate the true range of every nth laser sample. The missing samples are filled in with a linear interpolation. Generally it would be better to use fewer samples, but some (poorly implemented!) programs expect a fixed number of samples. Setting this number > 1 allows you to reduce the amount of computation required for your fixed-size laser vector. */ StgModelLaser::StgModelLaser( StgWorld* world, Modified: code/stage/trunk/libstage/model_position.cc =================================================================== --- code/stage/trunk/libstage/model_position.cc 2008-07-10 18:32:37 UTC (rev 6836) +++ code/stage/trunk/libstage/model_position.cc 2008-07-10 21:49:23 UTC (rev 6837) @@ -20,15 +20,15 @@ #include "stage_internal.hh" /** - @ingroup model - @defgroup model_position Position model +@ingroup model +@defgroup model_position Position model - The position model simulates a - mobile robot base. It can drive in one of two modes; either - <i>differential</i>, i.e. able to control its speed and turn rate by - driving left and roght wheels like a Pioneer robot, or - <i>omnidirectional</i>, i.e. able to control each of its three axes - independently. +The position model simulates a +mobile robot base. It can drive in one of two modes; either +<i>differential</i>, i.e. able to control its speed and turn rate by +driving left and roght wheels like a Pioneer robot, or +<i>omnidirectional</i>, i.e. able to control each of its three axes +independently. API: Stg::StgModelPosition @@ -39,16 +39,16 @@ @verbatim position ( -# position properties -drive "diff" -localization "gps" -localization_origin [ <defaults to model's start pose> ] + # position properties + drive "" + localization "" + localization_origin [ <defaults to model's start pose> ] -# odometry error model parameters, -# only used if localization is set to "odom" -odom_error [0.03 0.03 0.05] + # odometry error model parameters, + # only used if localization is set to "odom" + odom_error [0.03 0.03 0.05] -# model properties + # model properties ) @endverbatim @@ -56,10 +56,10 @@ Since Stage-1.6.5 the odom property has been removed. Stage will generate a warning if odom is defined in your worldfile. See localization_origin instead. @par Details -- drive "diff", "omni" or "car" -- select differential-steer mode (like a Pioneer), omnidirectional mode or carlike (velocity and steering angle). -- localization "gps" or "odom" -- if "gps" the position model reports its position with perfect accuracy. If "odom", a simple odometry model is used and position data drifts from the ground truth over time. The odometry model is parameterized by the odom_error property. +- drive "diff", "omni" or "car"\n + select differential-steer model(like a Pioneer), omnidirectional mode or carlike (velocity and steering angle). +- localization "gps" or "odom"\n + if "gps" the position model reports its position with perfect accuracy. If "odom", a simple odometry model is used and position data drifts from the ground truth over time. The odometry model is parameterized by the odom_error property. - localization_origin [x y theta] - set the origin of the localization coordinate system. By default, this is copied from the model's initial pose, so the robot reports its position relative to the place it started out. Tip: If localization_origin is set to [0 0 0] and localization is "gps", the model will return its true global position. This is unrealistic, but useful if you want to abstract away the details of localization. Be prepared to justify the use of this mode in your research! - odom_error [x y theta] Modified: code/stage/trunk/libstage/model_ranger.cc =================================================================== --- code/stage/trunk/libstage/model_ranger.cc 2008-07-10 18:32:37 UTC (rev 6836) +++ code/stage/trunk/libstage/model_ranger.cc 2008-07-10 21:49:23 UTC (rev 6837) @@ -25,30 +25,30 @@ @verbatim ranger ( -# ranger properties -scount 16 -spose[0] [? ? ?] -spose[1] [? ? ?] -spose[2] [? ? ?] -spose[3] [? ? ?] -spose[4] [? ? ?] -spose[5] [? ? ?] -spose[6] [? ? ?] -spose[7] [? ? ?] -spose[8] [? ? ?] -spose[9] [? ? ?] -spose[10] [? ? ?] -spose[11] [? ? ?] -spose[12] [? ? ?] -spose[13] [? ? ?] -spose[14] [? ? ?] -spose[15] [? ? ?] + # ranger properties + scount 16 + spose[0] [? ? ?] + spose[1] [? ? ?] + spose[2] [? ? ?] + spose[3] [? ? ?] + spose[4] [? ? ?] + spose[5] [? ? ?] + spose[6] [? ? ?] + spose[7] [? ? ?] + spose[8] [? ? ?] + spose[9] [? ? ?] + spose[10] [? ? ?] + spose[11] [? ? ?] + spose[12] [? ? ?] + spose[13] [? ? ?] + spose[14] [? ? ?] + spose[15] [? ? ?] -ssize [0.01 0.03] -sview [0.0 5.0 5.0] + ssize [0.01 0.03] + sview [0.0 5.0 5.0] -# model properties -watts 2.0 + # model properties + watts 2.0 ) @endverbatim @@ -57,11 +57,10 @@ The ranger model allows configuration of the pose, size and view parameters of each transducer seperately (using spose[index], ssize[index] and sview[index]). However, most users will set a common size and view (using ssize and sview), and just specify individual transducer poses. @par Details -- scount int -- the number of range transducers -- spose[\<transducer index\>] [float float float] -- [x y theta] -- pose of the transducer relative to its parent. +- scount <int>\n + the number of range transducers +- spose[\<transducer index\>] [ x:<float> y:<float> theta:<float> ]\n + pose of the transducer relative to its parent. - ssize [float float] - [x y] - size in meters. Has no effect on the data, but controls how the sensor looks in the Stage window. This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jer...@us...> - 2008-07-10 15:28:25
|
Revision: 6838 http://playerstage.svn.sourceforge.net/playerstage/?rev=6838&view=rev Author: jeremy_asher Date: 2008-07-10 15:28:34 -0700 (Thu, 10 Jul 2008) Log Message: ----------- Model worldfile documentation Modified Paths: -------------- code/stage/trunk/libstage/model.cc code/stage/trunk/libstage/model_load.cc Modified: code/stage/trunk/libstage/model.cc =================================================================== --- code/stage/trunk/libstage/model.cc 2008-07-10 21:49:23 UTC (rev 6837) +++ code/stage/trunk/libstage/model.cc 2008-07-10 22:28:34 UTC (rev 6838) @@ -22,6 +22,8 @@ color "red" color_rgba [ 0.0 0.0 0.0 1.0 ] + bitmap "" + ctrl "" # determine how the model appears in various sensors fiducial_return 0 @@ -35,14 +37,17 @@ # GUI properties gui_nose 0 gui_grid 0 - gui_outline 1 ( was gui_boundary? ) - gui_movemask 0 top level or (STG_MOVE_TRANS | STG_MOVE_ROT); + gui_outline 1 + gui_movemask <0 if top level or (STG_MOVE_TRANS | STG_MOVE_ROT)>; + blocks 0 + block[0].points 0 + block[0].point[0] [ 0.0 0.0 ] + block[0].z [ 0.0 1.0 ] + block[0].color "<color>" + boundary 0 - blocks -1 mass 10.0 - bitmap "" - ctrl "" map_resolution 0.1 say "" alwayson 0 @@ -50,45 +55,46 @@ @endverbatim @par Details -- pose [x_pos:float y_pos:float heading:float]\n -specify the pose of the model in its parent's coordinate system -- size [x_size:float y_size:float] -- specify the size of the model -- origin [x_pos:float y_pos:float heading:float] -- specify the position of the object's center, relative to its pose -- velocity [x_speed:float y_speed:float rotation_speed:float] -- specify the initial velocity of the model. Not that if the model hits an obstacle, its velocity will be set to zero. -- color [colorname:string] -- specify the color of the object using a color name from the X11 database (rgb.txt) -- line_count [int] -- specify the number of lines that make up the model's body- line[index] [x1:float y1:float x2:float y2:float] -- creates a line from (x1,y1) to (x2,y2). A set of line_count lines defines the robot's body for the purposes of collision detection and rendering in the GUI window. -- bitmap [filename:string} -- alternative way to set the model's line_count and lines. The file must be a bitmap recognized by libgtkpixbuf (most popular formats are supported). The file is opened and parsed into a set of lines. Unless the bitmap_resolution option is used, the lines are scaled to fit inside the rectangle defined by the model's current size. -- gui_nose [bool] -- if 1, draw a nose on the model showing its heading (positive X axis) -- gui_grid [bool] -- if 1, draw a scaling grid over the model -- gui_movemask [int] -- define how the model can be moved by the mouse in the GUI window -- gui_boundary [bool] -- if 1, draw a bounding box around the model, indicating its size -- obstacle_return [bool] -- if 1, this model can collide with other models that have this property set -- blob_return [bool] -- if 1, this model can be detected in the blob_finder (depending on its color) -- ranger_return [bool] -- if 1, this model can be detected by ranger sensors -- laser_return [int] -- if 0, this model is not detected by laser sensors. if 1, the model shows up in a laser sensor with normal (0) reflectance. If 2, it shows up with high (1) reflectance. -- fiducial_return [fiducial_id:int] -- if non-zero, this model is detected by fiducialfinder sensors. The value is used as the fiducial ID. -- fiducial_key [int] -- models are only detected by fiducialfinders if the fiducial_key values of model and fiducialfinder match. This allows you to have several independent types of fiducial in the same environment, each type only showing up in fiducialfinders that are "tuned" for it. -- ranger_return [bool] -- iff 1, this model can be detected by a ranger. -- gripper_return [bool] -- iff 1, this model can be gripped by a gripper and can be pushed around by collisions with anything that has a non-zero obstacle_return. + +- pose [ x:<float> y:<float> z:<float> heading:<float> ] \n + specify the pose of the model in its parent's coordinate system +- size [ x:<float> y:<float> z:<float> ]\n + specify the size of the model in each dimension +- origin [ x:<float> y:<float> z:<float> heading:<float> ]\n + specify the position of the object's center, relative to its pose +- velocity [ x:<float> y:<float> z:<float> heading:<float> omega:<float> ]\n + Specify the initial velocity of the model. Note that if the model hits an obstacle, its velocity will be set to zero. + +- color <string>\n + specify the color of the object using a color name from the X11 database (rgb.txt) +- bitmap filename:<string>\n + Draw the model by interpreting the lines in a bitmap (bmp, jpeg, gif, png supported). The file is opened and parsed into a set of lines. The lines are scaled to fit inside the rectangle defined by the model's current size. +- ctrl <string>\n + specify the controller module for the model + +- fiducial_return fiducial_id:<int>\n + if non-zero, this model is detected by fiducialfinder sensors. The value is used as the fiducial ID. +- fiducial_key <int> + models are only detected by fiducialfinders if the fiducial_key values of model and fiducialfinder match. This allows you to have several independent types of fiducial in the same environment, each type only showing up in fiducialfinders that are "tuned" for it. +- obstacle_return <int>\n + if 1, this model can collide with other models that have this property set +- ranger_return <int>\n + if 1, this model can be detected by ranger sensors +- blob_return <int>\n + if 1, this model can be detected in the blob_finder (depending on its color) +- laser_return <int>\n + if 0, this model is not detected by laser sensors. if 1, the model shows up in a laser sensor with normal (0) reflectance. If 2, it shows up with high (1) reflectance. +- gripper_return <int>\n + iff 1, this model can be gripped by a gripper and can be pushed around by collisions with anything that has a non-zero obstacle_return. + +- gui_nose <int>\n + if 1, draw a nose on the model showing its heading (positive X axis) +- gui_grid <int>\n + if 1, draw a scaling grid over the model +- gui_outline <int>\n + if 1, draw a bounding box around the model, indicating its size +- gui_movemask <int>\n + define how the model can be moved by the mouse in the GUI window */ Modified: code/stage/trunk/libstage/model_load.cc =================================================================== --- code/stage/trunk/libstage/model_load.cc 2008-07-10 21:49:23 UTC (rev 6837) +++ code/stage/trunk/libstage/model_load.cc 2008-07-10 22:28:34 UTC (rev 6838) @@ -185,7 +185,7 @@ if( wf->PropertyExists( wf_entity, "blocks" ) ) { - int blockcount = wf->ReadInt( wf_entity, "blocks", -1 ); + int blockcount = wf->ReadInt( wf_entity, "blocks", 0 ); this->UnMap(); this->ClearBlocks(); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jer...@us...> - 2008-07-10 15:45:33
|
Revision: 6840 http://playerstage.svn.sourceforge.net/playerstage/?rev=6840&view=rev Author: jeremy_asher Date: 2008-07-10 15:45:42 -0700 (Thu, 10 Jul 2008) Log Message: ----------- Spacing fix in docs Modified Paths: -------------- 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_position.cc code/stage/trunk/libstage/model_ranger.cc Modified: code/stage/trunk/libstage/model_blinkenlight.cc =================================================================== --- code/stage/trunk/libstage/model_blinkenlight.cc 2008-07-10 22:32:48 UTC (rev 6839) +++ code/stage/trunk/libstage/model_blinkenlight.cc 2008-07-10 22:45:42 UTC (rev 6840) @@ -38,6 +38,7 @@ @par Notes @par Details + - enabled int - if 0, the light is off, else it is on - period int Modified: code/stage/trunk/libstage/model_blobfinder.cc =================================================================== --- code/stage/trunk/libstage/model_blobfinder.cc 2008-07-10 22:32:48 UTC (rev 6839) +++ code/stage/trunk/libstage/model_blobfinder.cc 2008-07-10 22:45:42 UTC (rev 6840) @@ -62,6 +62,7 @@ @endverbatim @par Details + - colors_count <int>\n number of colors being tracked - colors [ col1:<string> col2:<string> ... ]\n Modified: code/stage/trunk/libstage/model_camera.cc =================================================================== --- code/stage/trunk/libstage/model_camera.cc 2008-07-10 22:32:48 UTC (rev 6839) +++ code/stage/trunk/libstage/model_camera.cc 2008-07-10 22:45:42 UTC (rev 6840) @@ -56,6 +56,7 @@ @endverbatim @par Details + - width <int>\n the number of pixel samples - height <int>\n Modified: code/stage/trunk/libstage/model_fiducial.cc =================================================================== --- code/stage/trunk/libstage/model_fiducial.cc 2008-07-10 22:32:48 UTC (rev 6839) +++ code/stage/trunk/libstage/model_fiducial.cc 2008-07-10 22:45:42 UTC (rev 6840) @@ -52,6 +52,7 @@ @endverbatim @par Details + - range_min <float>\n the minimum range reported by the sensor, in meters. The sensor will detect objects closer than this, but report their range as the minimum. - range_max <float>\n Modified: code/stage/trunk/libstage/model_laser.cc =================================================================== --- code/stage/trunk/libstage/model_laser.cc 2008-07-10 22:32:48 UTC (rev 6839) +++ code/stage/trunk/libstage/model_laser.cc 2008-07-10 22:45:42 UTC (rev 6840) @@ -65,6 +65,7 @@ @endverbatim @par Details + - samples <int>\n the number of laser samples per scan - range_min <float>\n Modified: code/stage/trunk/libstage/model_position.cc =================================================================== --- code/stage/trunk/libstage/model_position.cc 2008-07-10 22:32:48 UTC (rev 6839) +++ code/stage/trunk/libstage/model_position.cc 2008-07-10 22:45:42 UTC (rev 6840) @@ -56,6 +56,7 @@ Since Stage-1.6.5 the odom property has been removed. Stage will generate a warning if odom is defined in your worldfile. See localization_origin instead. @par Details + - drive "diff", "omni" or "car"\n select differential-steer model(like a Pioneer), omnidirectional mode or carlike (velocity and steering angle). - localization "gps" or "odom"\n Modified: code/stage/trunk/libstage/model_ranger.cc =================================================================== --- code/stage/trunk/libstage/model_ranger.cc 2008-07-10 22:32:48 UTC (rev 6839) +++ code/stage/trunk/libstage/model_ranger.cc 2008-07-10 22:45:42 UTC (rev 6840) @@ -57,6 +57,7 @@ The ranger model allows configuration of the pose, size and view parameters of each transducer seperately (using spose[index], ssize[index] and sview[index]). However, most users will set a common size and view (using ssize and sview), and just specify individual transducer poses. @par Details + - scount <int>\n the number of range transducers - spose[\<transducer index\>] [ x:<float> y:<float> theta:<float> ]\n This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |