Revision: 6915 http://playerstage.svn.sourceforge.net/playerstage/?rev=6915&view=rev Author: natepak Date: 2008-07-23 16:52:14 +0000 (Wed, 23 Jul 2008)
Log Message: ----------- Output entity name, pos, and rot when selected Modified Paths: -------------- code/gazebo/trunk/server/Simulator.cc code/gazebo/trunk/server/Simulator.hh code/gazebo/trunk/server/gui/GLWindow.cc code/gazebo/trunk/server/gui/Gui.cc code/gazebo/trunk/server/gui/StatusBar.cc code/gazebo/trunk/server/gui/StatusBar.hh code/gazebo/trunk/server/gui/Toolbar.cc code/gazebo/trunk/server/gui/Toolbar.hh code/gazebo/trunk/worlds/pioneer2dx.world code/gazebo/trunk/worlds/trimesh.world Modified: code/gazebo/trunk/server/Simulator.cc =================================================================== --- code/gazebo/trunk/server/Simulator.cc 2008-07-23 07:20:46 UTC (rev 6914) +++ code/gazebo/trunk/server/Simulator.cc 2008-07-23 16:52:14 UTC (rev 6915) @@ -65,7 +65,6 @@ checkpoint(0.0), renderUpdates(0), userPause(false), - userStep(false), userStepInc(false), userQuit(false), guiEnabled(true), @@ -260,8 +259,8 @@ this->simTime += step; // Update the physics engine - if (!this->GetUserPause() && !this->GetUserStep() || - (this->GetUserStep() && this->GetUserStepInc())) + if (!this->GetUserPause() || + (this->GetUserPause() && this->GetUserStepInc())) { this->iterations++; this->pause=false; @@ -386,37 +385,25 @@ //////////////////////////////////////////////////////////////////////////////// bool Simulator::GetUserPause() const { - return userPause; + return this->userPause; } //////////////////////////////////////////////////////////////////////////////// void Simulator::SetUserPause(bool pause) { - userPause = pause; + this->userPause = pause; } //////////////////////////////////////////////////////////////////////////////// -bool Simulator::GetUserStep() const -{ - return userStep; -} - -//////////////////////////////////////////////////////////////////////////////// -void Simulator::SetUserStep( bool step ) -{ - userStep = step; -} - -//////////////////////////////////////////////////////////////////////////////// bool Simulator::GetUserStepInc() const { - return userStepInc; + return this->userStepInc; } //////////////////////////////////////////////////////////////////////////////// void Simulator::SetUserStepInc(bool step) { - userStepInc = step; + this->userStepInc = step; } Modified: code/gazebo/trunk/server/Simulator.hh =================================================================== --- code/gazebo/trunk/server/Simulator.hh 2008-07-23 07:20:46 UTC (rev 6914) +++ code/gazebo/trunk/server/Simulator.hh 2008-07-23 16:52:14 UTC (rev 6915) @@ -131,12 +131,6 @@ /// \brief Set whether the user has paused public: void SetUserPause(bool pause); - /// \brief Return true if the user has stepped the simulation - public: bool GetUserStep() const; - - /// \brief Set whether the user has stepped the simulation - public: void SetUserStep( bool step ); - /// \brief Return true if the step has incremented public: bool GetUserStepInc() const; @@ -201,11 +195,8 @@ /// \brief Set to true to pause the simulation private: bool userPause; - /// Set to true to step through the simulation - private: bool userStep; - /// Set to true to increment the simulation once. This is only - /// valid when userStep is true. + /// valid when paused. private: bool userStepInc; //The user has somewhat signaled the end of the program Modified: code/gazebo/trunk/server/gui/GLWindow.cc =================================================================== --- code/gazebo/trunk/server/gui/GLWindow.cc 2008-07-23 07:20:46 UTC (rev 6914) +++ code/gazebo/trunk/server/gui/GLWindow.cc 2008-07-23 16:52:14 UTC (rev 6915) @@ -321,23 +321,6 @@ // Handle all toggle keys switch (keyNum) { - case 't': - if (sim->GetUserPause()) - sim->SetUserPause(false); - sim->SetUserStep( !sim->GetUserStep() ); - sim->SetUserStepInc( false ); - break; - - case ' ': - - if (sim->GetUserStep()) - { - sim->SetUserStepInc( true ); - } - else - sim->SetUserPause( !sim->GetUserPause() ); - break; - case FL_Escape: Simulator::Instance()->SetUserQuit(); break; Modified: code/gazebo/trunk/server/gui/Gui.cc =================================================================== --- code/gazebo/trunk/server/gui/Gui.cc 2008-07-23 07:20:46 UTC (rev 6914) +++ code/gazebo/trunk/server/gui/Gui.cc 2008-07-23 16:52:14 UTC (rev 6915) @@ -68,7 +68,7 @@ // Create the status bar this->statusbar = new StatusBar(0, height-30, - width-toolbarWidth, 30); + width, 30); this->statusbar->gui = this; } Modified: code/gazebo/trunk/server/gui/StatusBar.cc =================================================================== --- code/gazebo/trunk/server/gui/StatusBar.cc 2008-07-23 07:20:46 UTC (rev 6914) +++ code/gazebo/trunk/server/gui/StatusBar.cc 2008-07-23 16:52:14 UTC (rev 6915) @@ -27,6 +27,7 @@ #include <stdio.h> #include <FL/Fl_Value_Output.H> #include <FL/Fl_Output.H> +#include <FL/Fl_Button.H> #include "Gui.hh" #include "Simulator.hh" @@ -57,14 +58,14 @@ this->pauseTime = new Fl_Value_Output(x,y,55,20,"Pause Time"); this->pauseTime->precision(2); - //x = this->pauseTime->x() + this->pauseTime->w() + 80; - //this->iterations = new Fl_Value_Output(x,y,65,20,"Iterations"); - //this->iterations->precision(0); + x = this->pauseTime->x() + this->pauseTime->w() + 30; + this->playButton = new Fl_Button(x, y, 30, 20, "@||"); + this->playButton->callback( &gazebo::StatusBar::PlayPauseButtonCB, this ); - x = this->w() - 80; - this->statusString = new Fl_Output(x,y,80,20,""); - this->statusString->value("Running"); - this->statusString->color(FL_GREEN); + x = this->playButton->x() + this->playButton->w() + 15; + this->stepButton = new Fl_Button(x, y, 30, 20, "@>|"); + this->stepButton->callback( &gazebo::StatusBar::StepButtonCB, this ); + this->stepButton->deactivate(); this->resizable(NULL); this->end(); @@ -91,24 +92,37 @@ { this->realTime->value(Simulator::Instance()->GetRealTime()); } + this->simTime->value(Simulator::Instance()->GetSimTime()); this->pauseTime->value(Simulator::Instance()->GetPauseTime()); +} - if (Simulator::Instance()->GetUserPause()) +//////////////////////////////////////////////////////////////////////////////// +// Play pause button callback +void StatusBar::PlayPauseButtonCB( Fl_Widget *w, void *data ) +{ + StatusBar *sb = (StatusBar*)(data); + + if (strcmp(w->label(), "@||") == 0) { - this->statusString->value("PAUSED"); - this->statusString->color(FL_RED); + Simulator::Instance()->SetUserPause(true); + + sb->stepButton->activate(); + w->label("@>"); } - else if (Simulator::Instance()->GetUserStep()) - { - this->statusString->value("STEP"); - this->statusString->color(FL_RED); - } else { - this->statusString->value("RUNNING"); - this->statusString->color(FL_GREEN); + Simulator::Instance()->SetUserPause(false); + sb->stepButton->deactivate(); + w->label("@||"); } - //this->redraw(); + w->clear_visible_focus(); } + +//////////////////////////////////////////////////////////////////////////////// +/// Set button callback +void StatusBar::StepButtonCB( Fl_Widget * /*w*/, void * /*data*/ ) +{ + Simulator::Instance()->SetUserStepInc( true ); +} Modified: code/gazebo/trunk/server/gui/StatusBar.hh =================================================================== --- code/gazebo/trunk/server/gui/StatusBar.hh 2008-07-23 07:20:46 UTC (rev 6914) +++ code/gazebo/trunk/server/gui/StatusBar.hh 2008-07-23 16:52:14 UTC (rev 6915) @@ -30,6 +30,7 @@ class Fl_Value_Output; class Fl_Output; +class Fl_Button; namespace gazebo { @@ -45,14 +46,21 @@ /// \brief Update the toolbar data public: void Update(); - + + /// \brief Play Pause button callback + public: static void PlayPauseButtonCB( Fl_Widget *w, void *data ); + + /// \brief Set button callback + public: static void StepButtonCB( Fl_Widget *w, void *data ); + private: Fl_Value_Output *iterations; private: Fl_Value_Output *fps; private: Fl_Value_Output *realTime; private: Fl_Value_Output *pauseTime; private: Fl_Value_Output *simTime; - private: Fl_Output *statusString; + private: Fl_Button *playButton; + private: Fl_Button *stepButton; public: Gui *gui; }; Modified: code/gazebo/trunk/server/gui/Toolbar.cc =================================================================== --- code/gazebo/trunk/server/gui/Toolbar.cc 2008-07-23 07:20:46 UTC (rev 6914) +++ code/gazebo/trunk/server/gui/Toolbar.cc 2008-07-23 16:52:14 UTC (rev 6915) @@ -30,6 +30,7 @@ #include <FL/Fl_Button.H> #include "Entity.hh" +#include "Model.hh" #include "Simulator.hh" #include "CameraManager.hh" #include "OgreCamera.hh" @@ -45,21 +46,8 @@ this->box(FL_UP_BOX); - //OgreCamera *camera = CameraManager::Instance()->GetActiveCamera(); + this->entityInfoGrp = new Fl_Group(x+10,y+20,w-20,25*3, "Entity"); - /*if (camera) - { - sprintf(buffer,"%s [%d x %d]", camera->GetName().c_str(), camera->GetImageWidth(), camera->GetImageHeight()); - - } - else - { - sprintf(buffer,"Camera"); - } - */ - - this->entityInfoGrp = new Fl_Group(x+10,y+20,w-20,25*5, "Entity"); - // Camera Info Group this->entityInfoGrp->box(FL_BORDER_BOX); @@ -68,61 +56,12 @@ y = this->entityInfoGrp->y()+2; this->entityName = new Fl_Output(x,y, this->entityInfoGrp->w()-55,20, "Name: "); - /*// Prev camera button - x = this->cameraInfoGrp->x()+2; - y = this->cameraInfoGrp->y()+2; - this->prevCameraButton = new Fl_Button(x,y,16,20,"<"); - this->prevCameraButton->callback( &gazebo::Toolbar::PrevCameraButtonCB, this ); + y = this->entityName->y() + this->entityName->h() + 5; + this->entityPos = new Fl_Output(x,y, this->entityInfoGrp->w()-55,20, "XYZ: "); - // Next camera button - x = this->cameraInfoGrp->x() + this->cameraInfoGrp->w()-22; - y = this->cameraInfoGrp->y()+2; - this->nextCameraButton = new Fl_Button(x,y,16,20,">"); - this->nextCameraButton->callback( &gazebo::Toolbar::NextCameraButtonCB, this ); + y = this->entityPos->y() + this->entityPos->h() + 5; + this->entityRot = new Fl_Output(x,y, this->entityInfoGrp->w()-55,20, "RPY: "); - // Camera dimensions - x = this->cameraInfoGrp->x() + 40; - y = this->cameraName->y()+this->cameraName->h()+5; - this->cameraDimensions = new Fl_Output(x,y,this->cameraName->w()-20,20,"WxH"); - - - // Camera X output - x = this->cameraInfoGrp->x() + 20; - y = this->cameraDimensions->y() + this->cameraDimensions->h()+5; - this->outputX = new Fl_Value_Output(x,y,60,20,"X"); - this->outputX->precision(2); - - // Camera Y output - x = this->outputX->x(); - y = this->outputX->y() + this->outputX->h()+5; - this->outputY = new Fl_Value_Output(x,y,60,20,"Y"); - this->outputY->precision(2); - - // Camera Z output - x = this->outputY->x(); - y = this->outputY->y() + this->outputX->h()+5; - this->outputZ = new Fl_Value_Output(x,y,60,20,"Z"); - this->outputZ->precision(2); - - // Camera ROLL output - x = this->outputX->x() + this->outputX->w()+20; - y = this->outputX->y(); - this->outputRoll = new Fl_Value_Output(x,y,60,20,"R"); - this->outputRoll->precision(2); - - // Camera Pitch output - x = this->outputRoll->x(); - y = this->outputRoll->y() + this->outputRoll->h() + 5; - this->outputPitch = new Fl_Value_Output(x,y,60,20,"P"); - this->outputPitch->precision(2); - - // Camera Yaw output - x = this->outputPitch->x(); - y = this->outputPitch->y() + this->outputPitch->h() + 5; - this->outputYaw = new Fl_Value_Output(x,y,60,20,"Y"); - this->outputYaw->precision(2); - */ - this->entityInfoGrp->end(); this->end(); @@ -145,49 +84,31 @@ if (entity) { + Model *model = dynamic_cast<Model *>(entity); + sprintf(buffer,"%s", entity->GetName().c_str()); if (strcmp(buffer, this->entityName->value()) != 0) - { this->entityName->value(buffer); - } - } - /*char *buffer = new char[256]; - OgreCamera *camera = CameraManager::Instance()->GetActiveCamera(); - - if (camera != NULL) - { - sprintf(buffer,"%s", camera->GetName().c_str()); - if (strcmp(buffer,this->cameraName->value()) != 0) + if (model) { - this->cameraName->value(buffer); - } + Pose3d pose = model->GetPose(); + Vector3 rpy = pose.rot.GetAsEuler(); - sprintf(buffer,"%d x %d", camera->GetImageWidth(), camera->GetImageHeight()); - if (strcmp(buffer,this->cameraDimensions->value()) != 0) - { - this->cameraDimensions->value(buffer); - } + sprintf(buffer,"%4.2f, %4.2f, %4.2f",pose.pos.x, pose.pos.y, pose.pos.z); + if (strcmp( buffer, this->entityPos->value()) != 0) + this->entityPos->value(buffer); + sprintf(buffer,"%4.2f, %4.2f, %4.2f",rpy.x, rpy.y, rpy.z); + if (strcmp( buffer, this->entityRot->value()) != 0) + this->entityRot->value(buffer); - Pose3d pose = camera->GetWorldPose(); - - this->outputX->value(pose.pos.x); - this->outputY->value(pose.pos.y); - this->outputZ->value(pose.pos.z); - this->outputRoll->value(RTOD(pose.rot.GetRoll())); - this->outputPitch->value(RTOD(pose.rot.GetPitch())); - this->outputYaw->value(RTOD(pose.rot.GetYaw())); + } } - */ + else + { + this->entityName->value(""); + this->entityPos->value(""); + this->entityRot->value(""); + } } - -//void Toolbar::PrevCameraButtonCB(Fl_Widget * /*w*/, void *data) -//{ - //CameraManager::Instance()->DecActiveCamera(); -//} - -//void Toolbar::NextCameraButtonCB(Fl_Widget * /*w*/, void *data) -//{ - //CameraManager::Instance()->IncActiveCamera(); -//} Modified: code/gazebo/trunk/server/gui/Toolbar.hh =================================================================== --- code/gazebo/trunk/server/gui/Toolbar.hh 2008-07-23 07:20:46 UTC (rev 6914) +++ code/gazebo/trunk/server/gui/Toolbar.hh 2008-07-23 16:52:14 UTC (rev 6915) @@ -48,24 +48,12 @@ /// \brief Update the toolbar data public: void Update(); -// public: static void PrevCameraButtonCB(Fl_Widget * /*w*/, void *data); - //public: static void NextCameraButtonCB(Fl_Widget * /*w*/, void *data); - private: Fl_Group *entityInfoGrp; - /*private: Fl_Button *prevCameraButton; - private: Fl_Button *nextCameraButton; - */ + private: Fl_Output *entityName; - /*private: Fl_Output *cameraDimensions; - private: Fl_Value_Output *outputX; - private: Fl_Value_Output *outputY; - private: Fl_Value_Output *outputZ; + private: Fl_Output *entityPos; + private: Fl_Output *entityRot; - private: Fl_Value_Output *outputRoll; - private: Fl_Value_Output *outputPitch; - private: Fl_Value_Output *outputYaw; - */ - }; } Modified: code/gazebo/trunk/worlds/pioneer2dx.world =================================================================== --- code/gazebo/trunk/worlds/pioneer2dx.world 2008-07-23 07:20:46 UTC (rev 6914) +++ code/gazebo/trunk/worlds/pioneer2dx.world 2008-07-23 16:52:14 UTC (rev 6915) @@ -22,8 +22,7 @@ <stepTime>0.03</stepTime> <gravity>0 0 -9.8</gravity> <cfm>10e-5</cfm> - <erp>0.8</erp> - <maxUpdateRate>0</maxUpdateRate> + <erp>0.3</erp> </physics:ode> <rendering:gui> @@ -67,7 +66,7 @@ <model:physical name="sphere1_model"> <xyz>2.15 -1.68 .7</xyz> <rpy>0.0 0.0 0.0</rpy> - <static>true</static> + <static>false</static> <body:sphere name="sphere1_body"> <geom:sphere name="sphere1_geom"> Modified: code/gazebo/trunk/worlds/trimesh.world =================================================================== --- code/gazebo/trunk/worlds/trimesh.world 2008-07-23 07:20:46 UTC (rev 6914) +++ code/gazebo/trunk/worlds/trimesh.world 2008-07-23 16:52:14 UTC (rev 6915) @@ -58,14 +58,14 @@ <static>false</static> <body:trimesh name="pallet_body"> <geom:trimesh name="pallet_geom"> - <mesh>WoodPallet.mesh</mesh> + <mesh>Mesh.mesh</mesh> <scale>.2 .2 .2</scale> <mass>0.1</mass> <visual> <scale>.2 .2 .2</scale> <rpy>0 0 0</rpy> - <mesh>WoodPallet.mesh</mesh> + <mesh>Mesh.mesh</mesh> <material>Gazebo/WoodPallet</material> </visual> </geom:trimesh> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. ------------------------------------------------------------------------- This SF.Net email is sponsored by the Moblin Your Move Developer's challenge Build the coolest Linux based applications with Moblin SDK & win great prizes Grand prize is a trip for two to an Open Source event anywhere in the world http://moblin-contest.org/redirect.php?banner_id=100&url=/ _______________________________________________ Playerstage-commit mailing list Playerstage-commit@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/playerstage-commit