Commits

Nathan Koenig  committed 7cd3fab Merge

Merged in view_collisions (pull request #168)

  • Participants
  • Parent commits f9e9157, 736c88f

Comments (0)

Files changed (22)

File gazebo/gui/Actions.cc

 QAction *gazebo::gui::g_spotLghtCreateAct = 0;
 QAction *gazebo::gui::g_dirLghtCreateAct = 0;
 
-QAction *gazebo::gui::g_viewGridAct = 0;
-QAction *gazebo::gui::g_viewContactsAct = 0;
-QAction *gazebo::gui::g_viewResetAct = 0;
-QAction *gazebo::gui::g_viewFullScreenAct = 0;
-QAction *gazebo::gui::g_viewFPSAct = 0;
-QAction *gazebo::gui::g_viewOrbitAct = 0;
+QAction *gazebo::gui::g_showCollisionsAct = 0;
+QAction *gazebo::gui::g_showGridAct = 0;
+QAction *gazebo::gui::g_showContactsAct = 0;
+QAction *gazebo::gui::g_showJointsAct = 0;
+QAction *gazebo::gui::g_showCOMAct = 0;
+QAction *gazebo::gui::g_transparentAct = 0;
+
+QAction *gazebo::gui::g_resetAct = 0;
+QAction *gazebo::gui::g_fullScreenAct = 0;
+QAction *gazebo::gui::g_fpsAct = 0;
+QAction *gazebo::gui::g_orbitAct = 0;
 
 gazebo::gui::DeleteAction *gazebo::gui::g_deleteAct = 0;

File gazebo/gui/Actions.hh

     extern QAction *g_spotLghtCreateAct;
     extern QAction *g_dirLghtCreateAct;
 
-    extern QAction *g_viewGridAct;
-    extern QAction *g_viewContactsAct;
-    extern QAction *g_viewResetAct;
-    extern QAction *g_viewFullScreenAct;
-    extern QAction *g_viewFPSAct;
-    extern QAction *g_viewOrbitAct;
+    extern QAction *g_showCollisionsAct;
+    extern QAction *g_showGridAct;
+    extern QAction *g_showContactsAct;
+    extern QAction *g_showJointsAct;
+    extern QAction *g_showCOMAct;
+    extern QAction *g_transparentAct;
+
+    extern QAction *g_resetAct;
+    extern QAction *g_fullScreenAct;
+    extern QAction *g_fpsAct;
+    extern QAction *g_orbitAct;
 
     extern QAction *g_arrowAct;
     extern QAction *g_translateAct;

File gazebo/gui/JointControlWidget.cc

     this->jointPub = this->node->Advertise<msgs::JointCmd>(
         std::string("~/") + _modelName + "/joint_cmd");
 
-    this->requestMsg = msgs::CreateRequest("entity_info");
-    this->requestMsg->set_data(_modelName);
+    boost::shared_ptr<msgs::Response> response = transport::request("default",
+        "entity_info", _modelName);
 
-    msgs::Response response = transport::request("default", *this->requestMsg);
-
-    if (response.response() != "error" &&
-        response.type() == modelMsg.GetTypeName())
+    if (response->response() != "error" &&
+        response->type() == modelMsg.GetTypeName())
     {
-      modelMsg.ParseFromString(response.serialized_data());
+      modelMsg.ParseFromString(response->serialized_data());
     }
   }
 

File gazebo/gui/JointControlWidget.hh

       /// \brief Publisher for joint messages.
       private: transport::PublisherPtr jointPub;
 
-      /// \brief Holds out request for model information.
-      private: msgs::Request *requestMsg;
-
       /// \brief Sliders for force control
       private: std::map<std::string, JointForceControl*> sliders;
 

File gazebo/gui/MainWindow.cc

 }
 
 /////////////////////////////////////////////////
-void MainWindow::ViewReset()
+void MainWindow::Reset()
 {
   rendering::UserCameraPtr cam = gui::get_active_camera();
   cam->SetWorldPose(math::Pose(5, -5, 2, 0, GZ_DTOR(11.31), GZ_DTOR(135)));
 }
 
 /////////////////////////////////////////////////
-void MainWindow::ViewGrid()
+void MainWindow::ShowCollisions()
+{
+  if (g_showCollisionsAct->isChecked())
+    transport::requestNoReply(this->node->GetTopicNamespace(),
+        "show_collision", "all");
+  else
+    transport::requestNoReply(this->node->GetTopicNamespace(),
+        "hide_collision", "all");
+}
+
+/////////////////////////////////////////////////
+void MainWindow::ShowGrid()
 {
   msgs::Scene msg;
   msg.set_name("default");
-  msg.set_grid(g_viewGridAct->isChecked());
+  msg.set_grid(g_showGridAct->isChecked());
   this->scenePub->Publish(msg);
 }
 
 /////////////////////////////////////////////////
-void MainWindow::ViewContacts()
+void MainWindow::ShowJoints()
 {
-  gazebo::rendering::Events::viewContacts(g_viewContactsAct->isChecked());
+  if (g_showJointsAct->isChecked())
+    transport::requestNoReply(this->node->GetTopicNamespace(),
+        "show_joints", "all");
+  else
+    transport::requestNoReply(this->node->GetTopicNamespace(),
+        "hide_joints", "all");
 }
 
 /////////////////////////////////////////////////
-void MainWindow::ViewFullScreen()
+void MainWindow::SetTransparent()
+{
+  if (g_transparentAct->isChecked())
+    transport::requestNoReply(this->node->GetTopicNamespace(),
+        "set_transparent", "all");
+  else
+    transport::requestNoReply(this->node->GetTopicNamespace(),
+        "set_opaque", "all");
+}
+
+/////////////////////////////////////////////////
+void MainWindow::ShowCOM()
+{
+  if (g_showCOMAct->isChecked())
+    transport::requestNoReply(this->node->GetTopicNamespace(),
+        "show_com", "all");
+  else
+    transport::requestNoReply(this->node->GetTopicNamespace(),
+        "hide_com", "all");
+}
+
+/////////////////////////////////////////////////
+void MainWindow::ShowContacts()
+{
+  if (g_showContactsAct->isChecked())
+    transport::requestNoReply(this->node->GetTopicNamespace(),
+        "show_contact", "all");
+  else
+    transport::requestNoReply(this->node->GetTopicNamespace(),
+        "hide_contact", "all");
+}
+
+/////////////////////////////////////////////////
+void MainWindow::FullScreen()
 {
   g_fullscreen = !g_fullscreen;
   gui::Events::fullScreen(g_fullscreen);
 }
 
 /////////////////////////////////////////////////
-void MainWindow::ViewFPS()
+void MainWindow::FPS()
 {
   gui::Events::fps();
 }
 
 /////////////////////////////////////////////////
-void MainWindow::ViewOrbit()
+void MainWindow::Orbit()
 {
   gui::Events::orbit();
 }
   connect(g_dirLghtCreateAct, SIGNAL(triggered()), this,
       SLOT(CreateDirectionalLight()));
 
-  g_viewResetAct = new QAction(tr("Reset View"), this);
-  g_viewResetAct->setStatusTip(tr("Move camera to pose"));
-  connect(g_viewResetAct, SIGNAL(triggered()), this,
-      SLOT(ViewReset()));
+  g_resetAct = new QAction(tr("Reset Camera"), this);
+  g_resetAct->setStatusTip(tr("Move camera to pose"));
+  connect(g_resetAct, SIGNAL(triggered()), this,
+      SLOT(Reset()));
 
-  g_viewGridAct = new QAction(tr("Grid"), this);
-  g_viewGridAct->setStatusTip(tr("View Grid"));
-  g_viewGridAct->setCheckable(true);
-  g_viewGridAct->setChecked(true);
-  connect(g_viewGridAct, SIGNAL(triggered()), this,
-          SLOT(ViewGrid()));
+  g_showCollisionsAct = new QAction(tr("Collisions"), this);
+  g_showCollisionsAct->setStatusTip(tr("Show Collisions"));
+  g_showCollisionsAct->setCheckable(true);
+  g_showCollisionsAct->setChecked(false);
+  connect(g_showCollisionsAct, SIGNAL(triggered()), this,
+          SLOT(ShowCollisions()));
 
-  g_viewContactsAct = new QAction(tr("Contacts"), this);
-  g_viewContactsAct->setStatusTip(tr("View Contacts"));
-  g_viewContactsAct->setCheckable(true);
-  g_viewContactsAct->setChecked(false);
-  connect(g_viewContactsAct, SIGNAL(triggered()), this,
-          SLOT(ViewContacts()));
+  g_showGridAct = new QAction(tr("Grid"), this);
+  g_showGridAct->setStatusTip(tr("Show Grid"));
+  g_showGridAct->setCheckable(true);
+  g_showGridAct->setChecked(true);
+  connect(g_showGridAct, SIGNAL(triggered()), this,
+          SLOT(ShowGrid()));
 
-  g_viewFullScreenAct = new QAction(tr("Full Screen"), this);
-  g_viewFullScreenAct->setStatusTip(tr("View Full Screen(F-11 to exit)"));
-  connect(g_viewFullScreenAct, SIGNAL(triggered()), this,
-      SLOT(ViewFullScreen()));
+  g_transparentAct = new QAction(tr("Transparent"), this);
+  g_transparentAct->setStatusTip(tr("Transparent"));
+  g_transparentAct->setCheckable(true);
+  g_transparentAct->setChecked(false);
+  connect(g_transparentAct, SIGNAL(triggered()), this,
+          SLOT(SetTransparent()));
 
-  // g_viewFPSAct = new QAction(tr("FPS View Control"), this);
-  // g_viewFPSAct->setStatusTip(tr("First Person Shooter View Style"));
-  // connect(g_viewFPSAct, SIGNAL(triggered()), this, SLOT(ViewFPS()));
+  g_showCOMAct = new QAction(tr("Center of Mass"), this);
+  g_showCOMAct->setStatusTip(tr("Show COM"));
+  g_showCOMAct->setCheckable(true);
+  g_showCOMAct->setChecked(false);
+  connect(g_showCOMAct, SIGNAL(triggered()), this,
+          SLOT(ShowCOM()));
 
-  g_viewOrbitAct = new QAction(tr("Orbit View Control"), this);
-  g_viewOrbitAct->setStatusTip(tr("Orbit View Style"));
-  connect(g_viewOrbitAct, SIGNAL(triggered()), this, SLOT(ViewOrbit()));
+  g_showContactsAct = new QAction(tr("Contacts"), this);
+  g_showContactsAct->setStatusTip(tr("Show Contacts"));
+  g_showContactsAct->setCheckable(true);
+  g_showContactsAct->setChecked(false);
+  connect(g_showContactsAct, SIGNAL(triggered()), this,
+          SLOT(ShowContacts()));
+
+  g_showJointsAct = new QAction(tr("Joints"), this);
+  g_showJointsAct->setStatusTip(tr("Show Joints"));
+  g_showJointsAct->setCheckable(true);
+  g_showJointsAct->setChecked(false);
+  connect(g_showJointsAct, SIGNAL(triggered()), this,
+          SLOT(ShowJoints()));
+
+
+  g_fullScreenAct = new QAction(tr("Full Screen"), this);
+  g_fullScreenAct->setStatusTip(tr("Full Screen(F-11 to exit)"));
+  connect(g_fullScreenAct, SIGNAL(triggered()), this,
+      SLOT(FullScreen()));
+
+  // g_fpsAct = new QAction(tr("FPS View Control"), this);
+  // g_fpsAct->setStatusTip(tr("First Person Shooter View Style"));
+  // connect(g_fpsAct, SIGNAL(triggered()), this, SLOT(FPS()));
+
+  g_orbitAct = new QAction(tr("Orbit View Control"), this);
+  g_orbitAct->setStatusTip(tr("Orbit View Style"));
+  connect(g_orbitAct, SIGNAL(triggered()), this, SLOT(Orbit()));
 }
 
 /////////////////////////////////////////////////
   this->editMenu->addAction(g_resetWorldAct);
 
   this->viewMenu = this->menuBar->addMenu(tr("&View"));
-  this->viewMenu->addAction(g_viewGridAct);
-  this->viewMenu->addAction(g_viewContactsAct);
+  this->viewMenu->addAction(g_showGridAct);
   this->viewMenu->addSeparator();
-  this->viewMenu->addAction(g_viewResetAct);
-  this->viewMenu->addAction(g_viewFullScreenAct);
+
+  this->viewMenu->addAction(g_transparentAct);
+  this->viewMenu->addAction(g_showCollisionsAct);
+  this->viewMenu->addAction(g_showJointsAct);
+  this->viewMenu->addAction(g_showCOMAct);
+  this->viewMenu->addAction(g_showContactsAct);
   this->viewMenu->addSeparator();
-  // this->viewMenu->addAction(g_viewFPSAct);
-  this->viewMenu->addAction(g_viewOrbitAct);
+
+  this->viewMenu->addAction(g_resetAct);
+  this->viewMenu->addAction(g_fullScreenAct);
+  this->viewMenu->addSeparator();
+  // this->viewMenu->addAction(g_fpsAct);
+  this->viewMenu->addAction(g_orbitAct);
 
   this->menuBar->addSeparator();
 
 {
   if (_msg->has_fullscreen() && _msg->fullscreen())
   {
-    ViewFullScreen();
+    this->FullScreen();
   }
 
   if (_msg->has_camera())

File gazebo/gui/MainWindow.hh

       private slots: void CreateSpotLight();
       private slots: void CreateDirectionalLight();
       private slots: void InsertModel();
-      private slots: void ViewGrid();
-      private slots: void ViewContacts();
-      private slots: void ViewReset();
-      private slots: void ViewFullScreen();
-      private slots: void ViewFPS();
-      private slots: void ViewOrbit();
+      private slots: void ShowGrid();
+      private slots: void ShowCollisions();
+      private slots: void ShowJoints();
+      private slots: void ShowContacts();
+      private slots: void ShowCOM();
+      private slots: void Reset();
+      private slots: void FullScreen();
+      private slots: void FPS();
+      private slots: void Orbit();
       private slots: void OnResetModelOnly();
       private slots: void OnResetWorld();
+      private slots: void SetTransparent();
 
       private: void OnFullScreen(bool _value);
       private: void OnMoveMode(bool _mode);

File gazebo/gui/ModelRightMenu.cc

  *
 */
 
-#include "transport/transport.hh"
-#include "rendering/UserCamera.hh"
-#include "rendering/Scene.hh"
-#include "rendering/Visual.hh"
+#include "gazebo/transport/transport.hh"
+#include "gazebo/rendering/UserCamera.hh"
+#include "gazebo/rendering/Scene.hh"
+#include "gazebo/rendering/Visual.hh"
 
-#include "gui/Actions.hh"
-#include "gui/Gui.hh"
-#include "gui/ModelRightMenu.hh"
+#include "gazebo/gui/Actions.hh"
+#include "gazebo/gui/Gui.hh"
+#include "gazebo/gui/ModelRightMenu.hh"
 
 using namespace gazebo;
 using namespace gui;
 
+/////////////////////////////////////////////////
 ModelRightMenu::ModelRightMenu()
 {
   this->node = transport::NodePtr(new transport::Node());
   this->node->Init();
-  this->requestPub = this->node->Advertise<msgs::Request>("~/request", 5, true);
+  this->requestSub = this->node->Subscribe("~/request",
+      &ModelRightMenu::OnRequest, this);
 
-  // this->snapBelowAction = new QAction(tr("Snap"), this);
-  // this->snapBelowAction->setStatusTip(tr("Snap to object below"));
-  // connect(this->snapBelowAction, SIGNAL(triggered()), this,
-  //         SLOT(OnSnapBelow()));
+  this->moveToAct = new QAction(tr("Move To"), this);
+  this->moveToAct->setStatusTip(tr("Move camera to the selection"));
+  connect(this->moveToAct, SIGNAL(triggered()), this, SLOT(OnMoveTo()));
 
-  // this->followAction = new QAction(tr("Follow"), this);
-  // this->followAction->setStatusTip(tr("Follow the selection"));
-  // connect(this->followAction, SIGNAL(triggered()), this, SLOT(OnFollow()));
-
-  this->moveToAction = new QAction(tr("Move To"), this);
-  this->moveToAction->setStatusTip(tr("Move camera to the selection"));
-  connect(this->moveToAction, SIGNAL(triggered()), this, SLOT(OnMoveTo()));
-
-  this->transparentAct = new QAction(tr("Transparent"), this);
-  this->transparentAct->setStatusTip(tr("Make model transparent"));
-  this->transparentAct->setCheckable(true);
-  connect(this->transparentAct, SIGNAL(triggered()), this,
-          SLOT(OnTransparent()));
+  // \todo Reimplement
+  // this->snapBelowAct = new QAction(tr("Snap"), this);
+  // this->snapBelowAct->setStatusTip(tr("Snap to object below"));
+  // connect(this->snapBelowAct, SIGNAL(triggered()), this,
+  //          SLOT(OnSnapBelow()));
 
   // Create the delete action
   g_deleteAct = new DeleteAction(tr("Delete"), this);
   connect(g_deleteAct, SIGNAL(triggered()), this,
           SLOT(OnDelete()));
 
-  // this->showCollisionAction = new QAction(tr("Show Collision"), this);
-  // this->showCollisionAction->setStatusTip(tr("Show Collision Entity"));
-  // this->showCollisionAction->setCheckable(true);
-  // connect(this->showCollisionAction, SIGNAL(triggered()), this,
-  //         SLOT(OnShowCollision()));
+  ViewState *state = new ViewState(this, "set_transparent", "set_opaque");
+  state->action = new QAction(tr("Transparent"), this);
+  state->action->setStatusTip(tr("Make model transparent"));
+  state->action->setCheckable(true);
+  connect(state->action, SIGNAL(triggered()), state, SLOT(Callback()));
+  this->viewStates.push_back(state);
+
+  state = new ViewState(this, "show_collision", "hide_collision");
+  state->action = new QAction(tr("Collisions"), this);
+  state->action->setStatusTip(tr("Show collision objects"));
+  state->action->setCheckable(true);
+  connect(state->action, SIGNAL(triggered()), state, SLOT(Callback()));
+  this->viewStates.push_back(state);
+
+  state = new ViewState(this, "show_joints", "hide_joints");
+  state->action = new QAction(tr("Joints"), this);
+  state->action->setStatusTip(tr("Show joints"));
+  state->action->setCheckable(true);
+  connect(state->action, SIGNAL(triggered()), state, SLOT(Callback()));
+  this->viewStates.push_back(state);
+
+  state = new ViewState(this, "show_com", "hide_com");
+  state->action = new QAction(tr("Center of mass"), this);
+  state->action->setStatusTip(tr("Show center of mass"));
+  state->action->setCheckable(true);
+  connect(state->action, SIGNAL(triggered()), state, SLOT(Callback()));
+  this->viewStates.push_back(state);
+
+  // \todo Reimplement
+  // this->followAction = new QAction(tr("Follow"), this);
+  // this->followAction->setStatusTip(tr("Follow the selection"));
+  // connect(this->followAction, SIGNAL(triggered()), this, SLOT(OnFollow()));
 
   // this->skeletonAction = new QAction(tr("Skeleton"), this);
   // this->skeletonAction->setStatusTip(tr("Show model skeleton"));
   // this->skeletonAction->setCheckable(true);
   // connect(this->skeletonAction, SIGNAL(triggered()), this,
   //         SLOT(OnSkeleton()));
-
-
-  // this->showJointsAction = new QAction(tr("Joints"), this);
-  // this->showJointsAction->setStatusTip(tr("Show joints"));
-  // this->showJointsAction->setCheckable(true);
-  // connect(this->showJointsAction, SIGNAL(triggered()), this,
-  //         SLOT(OnShowJoints()));
-
-  // this->showCOMAction = new QAction(tr("Center of Mass"), this);
-  // this->showCOMAction->setStatusTip(tr("Show Center of Mass"));
-  // this->showCOMAction->setCheckable(true);
-  // connect(this->showCOMAction, SIGNAL(triggered()), this,
-  //         SLOT(OnShowCOM()));
 }
 
 /////////////////////////////////////////////////
   this->modelName = _modelName.substr(0, _modelName.find("::"));
 
   QMenu menu;
-  // menu.addAction(this->snapBelowAction);
-  menu.addAction(this->moveToAction);
-  menu.addAction(this->transparentAct);
+  menu.addAction(this->moveToAct);
+  // menu.addAction(this->snapBelowAct);
+
+  // Create the view menu
+  QMenu *viewMenu = menu.addMenu(tr("View"));
+  for (std::vector<ViewState*>::iterator iter = this->viewStates.begin();
+       iter != this->viewStates.end(); ++iter)
+  {
+    viewMenu->addAction((*iter)->action);
+
+    std::map<std::string, bool>::iterator modelIter =
+      (*iter)->modelStates.find(this->modelName);
+
+    if (modelIter == (*iter)->modelStates.end())
+      (*iter)->action->setChecked((*iter)->globalEnable);
+    else
+      (*iter)->action->setChecked(modelIter->second);
+  }
+
   menu.addSeparator();
   menu.addAction(g_deleteAct);
 
+  // \todo Reimplement these features.
   // menu.addAction(this->followAction);
-  // menu.addAction(this->showCollisionAction);
-  // menu.addAction(this->showJointsAction);
-  // menu.addAction(this->showCOMAction);
   // menu.addAction(this->skeletonAction);
 
-  if (this->transparentActionState[this->modelName])
-    this->transparentAct->setChecked(true);
-  else
-    this->transparentAct->setChecked(false);
-
-  // if (this->skeletonActionState[this->modelName])
-  //   this->skeletonAction->setChecked(true);
-  // else
-  //   this->skeletonAction->setChecked(false);
-
-  // if (this->showCollisionsActionState[this->modelName])
-  //   this->showCollisionAction->setChecked(true);
-  // else
-  //   this->showCollisionAction->setChecked(false);
-
   menu.exec(_pt);
 }
 
 /////////////////////////////////////////////////
-void ModelRightMenu::OnSnapBelow()
-{
-  rendering::UserCameraPtr cam = gui::get_active_camera();
-  cam->GetScene()->SnapVisualToNearestBelow(this->modelName);
-}
-
-/////////////////////////////////////////////////
 void ModelRightMenu::OnMoveTo()
 {
   rendering::UserCameraPtr cam = gui::get_active_camera();
 }
 
 /////////////////////////////////////////////////
-void ModelRightMenu::OnShowCollision()
-{
-  this->showCollisionsActionState[this->modelName] =
-    this->showCollisionAction->isChecked();
-
-  if (this->showCollisionAction->isChecked())
-    this->requestMsg = msgs::CreateRequest("show_collision", this->modelName);
-  else
-    this->requestMsg = msgs::CreateRequest("hide_collision", this->modelName);
-
-  this->requestPub->Publish(*this->requestMsg);
-}
-
-/////////////////////////////////////////////////
-void ModelRightMenu::OnShowJoints()
-{
-  this->showJointsActionState[this->modelName] =
-    this->showJointsAction->isChecked();
-
-  if (this->showJointsAction->isChecked())
-    this->requestMsg = msgs::CreateRequest("show_joints", this->modelName);
-  else
-    this->requestMsg = msgs::CreateRequest("hide_joints", this->modelName);
-
-  this->requestPub->Publish(*this->requestMsg);
-}
-
-/////////////////////////////////////////////////
-void ModelRightMenu::OnShowCOM()
-{
-  this->showCOMActionState[this->modelName] =
-    this->showCOMAction->isChecked();
-
-  if (this->showCOMAction->isChecked())
-    this->requestMsg = msgs::CreateRequest("show_com", this->modelName);
-  else
-    this->requestMsg = msgs::CreateRequest("hide_com", this->modelName);
-
-  this->requestPub->Publish(*this->requestMsg);
-}
-
-/////////////////////////////////////////////////
-void ModelRightMenu::OnTransparent()
-{
-  this->transparentActionState[this->modelName] =
-    this->transparentAct->isChecked();
-
-  if (this->transparentAct->isChecked())
-  {
-    this->requestMsg = msgs::CreateRequest("set_transparency", this->modelName);
-    this->requestMsg->set_dbl_data(0.5);
-  }
-  else
-  {
-    this->requestMsg = msgs::CreateRequest("set_transparency", this->modelName);
-    this->requestMsg->set_dbl_data(0.0);
-  }
-
-  this->requestPub->Publish(*this->requestMsg);
-}
-
-/////////////////////////////////////////////////
-void ModelRightMenu::OnSkeleton()
-{
-  this->skeletonActionState[this->modelName] =
-    this->skeletonAction->isChecked();
-
-  if (this->skeletonAction->isChecked())
-  {
-    this->requestMsg = msgs::CreateRequest("show_skeleton", this->modelName);
-    this->requestMsg->set_dbl_data(1.0);
-  }
-  else
-  {
-    this->requestMsg = msgs::CreateRequest("show_skeleton", this->modelName);
-    this->requestMsg->set_dbl_data(0.0);
-  }
-
-  this->requestPub->Publish(*this->requestMsg);
-}
-
-/////////////////////////////////////////////////
-void ModelRightMenu::OnFollow()
-{
-  rendering::UserCameraPtr cam = gui::get_active_camera();
-  cam->TrackVisual(this->modelName);
-}
+// void ModelRightMenu::OnSnapBelow()
+// {
+//   rendering::UserCameraPtr cam = gui::get_active_camera();
+//   if (!cam)
+//     gzerr << "Invalid user camera\n";
+//
+//   if (!cam->GetScene())
+//     gzerr << "Invalid user camera scene\n";
+//
+//   // cam->GetScene()->SnapVisualToNearestBelow(this->modelName);
+// }
 
 /////////////////////////////////////////////////
 void ModelRightMenu::OnDelete(const std::string &_name)
   if (name.empty())
     name = this->modelName;
 
+  // Delete the entity
   if (!name.empty())
+    transport::requestNoReply(this->node, "entity_delete", name);
+}
+
+/////////////////////////////////////////////////
+void ModelRightMenu::OnRequest(ConstRequestPtr &_msg)
+{
+  // Process the request by looking at all the view states.
+  for (std::vector<ViewState*>::iterator iter = this->viewStates.begin();
+       iter != this->viewStates.end(); ++iter)
   {
-    this->requestMsg = msgs::CreateRequest("entity_delete", name);
-    this->requestPub->Publish(*this->requestMsg);
+    // Only proceed if the request matches one of the check or uncheck
+    // requests of the view state
+    if (_msg->request() == (*iter)->checkRequest ||
+        _msg->request() == (*iter)->uncheckRequest)
+    {
+      // Determine the value(state) of the view states
+      bool value = _msg->request() == (*iter)->checkRequest ? true : false;
+
+      // If the request is for all objects...
+      if (_msg->data() == "all")
+      {
+        // Set all model states within the view state to the value.
+        for (std::map<std::string, bool>::iterator modelIter =
+            (*iter)->modelStates.begin();
+            modelIter != (*iter)->modelStates.end(); ++modelIter)
+        {
+          modelIter->second = value;
+        }
+
+        // Use a globalEnable to handle the case when new models are added
+        (*iter)->globalEnable = value;
+      }
+      // Otherwise the request is for a single model...
+      else
+      {
+        // Set the state of the given model
+        (*iter)->modelStates[_msg->data()] = value;
+      }
+    }
   }
 }
+
+/////////////////////////////////////////////////
+ViewState::ViewState(ModelRightMenu *_parent,
+                     const std::string &_checkRequest,
+                     const std::string &_uncheckRequest)
+  : QObject(_parent)
+{
+  this->globalEnable = false;
+  this->action = NULL;
+  this->parent = _parent;
+  this->checkRequest = _checkRequest;
+  this->uncheckRequest = _uncheckRequest;
+}
+
+/////////////////////////////////////////////////
+void ViewState::Callback()
+{
+  // Store the check state for the model
+  this->modelStates[this->parent->modelName] = this->action->isChecked();
+
+  // Send a message with the new check state. The Scene listens to these
+  // messages and updates the visualizations accordingly.
+  if (this->action->isChecked())
+  {
+    transport::requestNoReply(this->parent->node, this->checkRequest,
+                              this->parent->modelName);
+  }
+  else
+  {
+    transport::requestNoReply(this->parent->node, this->uncheckRequest,
+                              this->parent->modelName);
+  }
+}
+
+/// \todo Reimplement these functions.
+/////////////////////////////////////////////////
+// void ModelRightMenu::OnSkeleton()
+// {
+//   this->skeletonActionState[this->modelName] =
+//     this->skeletonAction->isChecked();
+//
+//   if (this->skeletonAction->isChecked())
+//   {
+//     this->requestMsg = msgs::CreateRequest("show_skeleton", this->modelName);
+//     this->requestMsg->set_dbl_data(1.0);
+//   }
+//   else
+//   {
+//     this->requestMsg = msgs::CreateRequest("show_skeleton", this->modelName);
+//     this->requestMsg->set_dbl_data(0.0);
+//   }
+//
+//   this->requestPub->Publish(*this->requestMsg);
+// }
+
+/////////////////////////////////////////////////
+// void ModelRightMenu::OnFollow()
+// {
+//   rendering::UserCameraPtr cam = gui::get_active_camera();
+//   cam->TrackVisual(this->modelName);
+// }

File gazebo/gui/ModelRightMenu.hh

 #define _MODELRIGHTMENU_HH_
 
 #include <map>
+#include <vector>
 #include <string>
-#include "gui/qt.h"
-#include "msgs/msgs.hh"
-#include "transport/TransportTypes.hh"
+
+#include "gazebo/gui/qt.h"
+#include "gazebo/msgs/msgs.hh"
+#include "gazebo/transport/TransportTypes.hh"
 
 namespace gazebo
 {
   namespace gui
   {
+    class ViewState;
+
+    /// \class ModelRightMenu ModelRightMenu.hh gui/gui.hh
+    /// \brief Displays a menu when the right mouse button has been pressed.
     class ModelRightMenu : public QObject
     {
       Q_OBJECT
+
+      /// \brief Constructor
       public: ModelRightMenu();
+
+      /// \brief Destructor
       public: virtual ~ModelRightMenu();
 
+      /// \brief Show the right menu.
+      /// \param[in] _modelName Name of the model that is active.
+      /// \param[in] _pt Point on the GUI that has received the right-click
+      /// request.
       public: void Run(const std::string &_modelName, const QPoint &_pt);
 
-      private slots: void OnSnapBelow();
+      /// \brief QT callback when move to has been selected.
       private slots: void OnMoveTo();
+
+      /// \brief QT callback when delete has been selected.
+      /// \param[in] _name Name of the model to delete.
       private slots: void OnDelete(const std::string &_name="");
-      private slots: void OnFollow();
-      private slots: void OnShowCollision();
-      private slots: void OnShowJoints();
-      private slots: void OnShowCOM();
-      private slots: void OnTransparent();
-      private slots: void OnSkeleton();
 
+      /// \brief QT callback when snap below has been selected.
+      // private slots: void OnSnapBelow();
+
+      // private slots: void OnFollow();
+      // private slots: void OnSkeleton();
+
+      /// \brief Request callback.
+      /// \param[in] _msg Request message to process.
+      private: void OnRequest(ConstRequestPtr &_msg);
+
+      /// \brief Node for communication.
+      private: transport::NodePtr node;
+
+      /// \brief Subscriber to request messages.
+      private: transport::SubscriberPtr requestSub;
+
+      /// \brief Name of the active model.
       private: std::string modelName;
 
-      private: QAction *moveToAction;
-      private: QAction *transparentAct;
+      /// \brief Action for moving the camera to an object.
+      private: QAction *moveToAct;
 
-      private: QAction *snapBelowAction;
-      private: QAction *followAction;
-      private: QAction *showCollisionAction;
-      private: QAction *skeletonAction;
-      private: QAction *showJointsAction;
-      private: QAction *showCOMAction;
+      /// \brief Action for snapping an object to another object below the
+      /// first.
+      // private: QAction *snapBelowAct;
+      // private: QAction *followAct;
+      // private: QAction *skeletonAct;
 
-      private: transport::NodePtr node;
-      private: transport::PublisherPtr requestPub;
-      private: msgs::Request *requestMsg;
+      /// \brief The various view states
+      private: std::vector<ViewState*> viewStates;
 
-      private: std::map<std::string, bool> showCollisionsActionState;
-      private: std::map<std::string, bool> showJointsActionState;
-      private: std::map<std::string, bool> showCOMActionState;
-      private: std::map<std::string, bool> transparentActionState;
-      private: std::map<std::string, bool> skeletonActionState;
+      // The view state class is a friend for convenience
+      private: friend class ViewState;
+    };
+
+    /// \class ViewState ViewState.hh gui/gui.hh
+    /// \brief A class for managing view visualization states.
+    /// Used by ModelRightMenu.
+    class ViewState : public QObject
+    {
+      Q_OBJECT
+
+      /// \brief Constructor
+      /// \param[in] _parent Pointer to the MOdelRightMenu
+      /// \param[in] _checkRequest Name of the request to send when checked.
+      /// \param[in] _uncheckRequest Name of the request to send when unchecked.
+      public: ViewState(ModelRightMenu *_parent,
+                  const std::string &_checkRequest,
+                  const std::string &_uncheckRequest);
+
+      /// \brief State of all the models for this view.
+      public: std::map<std::string, bool> modelStates;
+
+      /// \brief Action for this view.
+      public: QAction *action;
+
+      /// \brief True if the view visualization is enabled globally.
+      public: bool globalEnable;
+
+      /// \brief Pointer to the ModelRightMenu.
+      public: ModelRightMenu *parent;
+
+      /// \brief Name of the request to send when checked.
+      public: std::string checkRequest;
+
+      /// \brief Name of the request to send when unchecked.
+      public: std::string uncheckRequest;
+
+      /// \brief QT callback for the QAction.
+      public slots: void Callback();
     };
   }
 }

File gazebo/physics/Base.hh

 
       /// \brief True if selected.
       private: bool selected;
+
+      protected: friend class Entity;
     };
     /// \}
   }

File gazebo/physics/Collision.cc

File contents unchanged.

File gazebo/physics/Entity.cc

 //////////////////////////////////////////////////
 math::Pose Entity::GetRelativePose() const
 {
-  if (this->IsCanonicalLink())
+  // We return the initialRelativePose for COLLISION objects because they
+  // cannot move relative to their parent link.
+  // \todo Look into storing relative poses for all objects instead of world
+  // poses. It may simplify pose updating.
+  if (this->IsCanonicalLink() || this->HasType(COLLISION))
   {
     return this->initialRelativePose;
   }
 
   // force an update of all children
   // update all children pose, moving them with the model.
+  // The outer loop updates all the links.
   for (Base_V::iterator iter = this->children.begin();
-       iter != this->childrenEnd; ++iter)
+      iter != this->childrenEnd; ++iter)
   {
     if ((*iter)->HasType(ENTITY))
     {
       EntityPtr entity = boost::shared_static_cast<Entity>(*iter);
 
       if (entity->IsCanonicalLink())
-      {
         entity->worldPose = (entity->initialRelativePose + _pose);
-      }
       else
       {
         entity->worldPose = ((entity->worldPose - oldModelWorldPose) + _pose);
 //
 void Entity::SetWorldPose(const math::Pose &_pose, bool _notify, bool _publish)
 {
-  this->GetWorld()->GetSetWorldPoseMutex()->lock();
+  boost::mutex::scoped_lock lock(*this->GetWorld()->GetSetWorldPoseMutex());
 
+  math::Pose oldPose = this->worldPose;
   (*this.*setWorldPoseFunc)(_pose, _notify, _publish);
 
-  this->GetWorld()->GetSetWorldPoseMutex()->unlock();
-
   if (_publish)
     this->PublishPose();
 }

File gazebo/physics/Model.cc

File contents unchanged.

File gazebo/rendering/OrbitViewController.cc

 
   this->focalPoint = _focalPoint;
   this->distance = this->camera->GetWorldPosition().Distance(this->focalPoint);
-  if (this->distance <= 1.0)
-    std::cout << "Distance[" << this->distance << "]\n";
 }
 
 //////////////////////////////////////////////////

File gazebo/rendering/RenderEvents.cc

 
 event::EventT<void (const std::string &)> Events::createScene;
 event::EventT<void (const std::string &)> Events::removeScene;
-event::EventT<void (bool)> Events::viewContacts;

File gazebo/rendering/RenderEvents.hh

                   event::ConnectionPtr _connection)
               {removeScene.Disconnect(_connection);}
 
-      /// \brief Connect to a view contacts event.
-      /// \param[in] _subscriber Callback to trigger when event occurs.
-      /// \return Pointer the connection. This must stay in scope.
-      public: template<typename T>
-              static event::ConnectionPtr ConnectViewContacts(T _subscriber)
-              {return viewContacts.Connect(_subscriber);}
-
-      /// \brief Disconnect from a view contacts event.
-      /// \param[in] _connection The connection to disconnect.
-      public: static void DisconnectViewContacts(
-                  event::ConnectionPtr _connection)
-              {viewContacts.Disconnect(_connection);}
-
       /// \brief The event used to trigger a create scene event.
       public: static event::EventT<void (const std::string &)> createScene;
 
       /// \brief The event used to trigger a remve scene event.
       public: static event::EventT<void (const std::string &)> removeScene;
-
-      /// \brief The event used to toggle contact visualization.
-      public: static event::EventT<void (bool)> viewContacts;
     };
     /// \}
   }

File gazebo/rendering/Scene.cc

  *
 */
 #include <boost/lexical_cast.hpp>
+
 #include "gazebo/rendering/skyx/include/SkyX.h"
+#include "gazebo/rendering/ogre_gazebo.h"
 
-#include "rendering/ogre_gazebo.h"
-#include "msgs/msgs.hh"
-#include "sdf/sdf.hh"
+#include "gazebo/msgs/msgs.hh"
+#include "gazebo/sdf/sdf.hh"
 
-#include "common/Exception.hh"
-#include "common/Console.hh"
+#include "gazebo/common/Exception.hh"
+#include "gazebo/common/Console.hh"
 
 #include "gazebo/rendering/Road2d.hh"
 #include "gazebo/rendering/Projector.hh"
 //////////////////////////////////////////////////
 Scene::Scene(const std::string &_name, bool _enableVisualizations)
 {
+  this->showCOMs = false;
+  this->showCollisions = false;
+  this->showJoints = false;
+  this->transparent = false;
+
   this->requestMsg = NULL;
   this->enableVisualizations = _enableVisualizations;
   this->node = transport::NodePtr(new transport::Node());
   this->connections.push_back(
       event::Events::ConnectPreRender(boost::bind(&Scene::PreRender, this)));
 
-  this->connections.push_back(
-      Events::ConnectViewContacts(boost::bind(&Scene::ViewContacts, this, _1)));
-
   this->sensorSub = this->node->Subscribe("~/sensor",
                                           &Scene::OnSensorMsg, this);
   this->visSub = this->node->Subscribe("~/visual", &Scene::OnVisualMsg, this);
   if (this->terrain)
   {
     double terrainHeight = this->terrain->GetHeight(_pt.x, _pt.y, _pt.z);
-    std::cout << "Terrain Heihgt[" << terrainHeight << "]\n";
     if (terrainHeight <= _pt.z)
       height = std::max(height, terrainHeight);
   }
   JointVisualPtr jointVis(new JointVisual(
           _msg->name() + "_JOINT_VISUAL__", childVis));
   jointVis->Load(_msg);
-  jointVis->SetVisible(false);
+  jointVis->SetVisible(this->showJoints);
 
   this->visuals[jointVis->GetName()] = jointVis;
   return true;
         this->RemoveVisual(iter->second);
     }
   }
+  else if (_msg->request() == "show_contact")
+  {
+    this->ShowContacts(true);
+  }
+  else if (_msg->request() == "hide_contact")
+  {
+    this->ShowContacts(false);
+  }
   else if (_msg->request() == "show_collision")
   {
-    VisualPtr vis = this->GetVisual(_msg->data());
-    if (vis)
-      vis->ShowCollision(true);
+    if (_msg->data() == "all")
+      this->ShowCollisions(true);
     else
-      gzerr << "Unable to find visual[" << _msg->data() << "]\n";
+    {
+      VisualPtr vis = this->GetVisual(_msg->data());
+      if (vis)
+        vis->ShowCollision(true);
+      else
+        gzerr << "Unable to find visual[" << _msg->data() << "]\n";
+    }
   }
   else if (_msg->request() == "hide_collision")
   {
-    VisualPtr vis = this->GetVisual(_msg->data());
-    if (vis)
-      vis->ShowCollision(false);
+    if (_msg->data() == "all")
+      this->ShowCollisions(false);
+    else
+    {
+      VisualPtr vis = this->GetVisual(_msg->data());
+      if (vis)
+        vis->ShowCollision(false);
+    }
   }
   else if (_msg->request() == "show_joints")
   {
-    VisualPtr vis = this->GetVisual(_msg->data());
-    if (vis)
-      vis->ShowJoints(true);
+    if (_msg->data() == "all")
+      this->ShowJoints(true);
     else
-      gzerr << "Unable to find joint visual[" << _msg->data() << "]\n";
+    {
+      VisualPtr vis = this->GetVisual(_msg->data());
+      if (vis)
+        vis->ShowJoints(true);
+      else
+        gzerr << "Unable to find joint visual[" << _msg->data() << "]\n";
+    }
   }
   else if (_msg->request() == "hide_joints")
   {
-    VisualPtr vis = this->GetVisual(_msg->data());
-    if (vis)
-      vis->ShowJoints(false);
+    if (_msg->data() == "all")
+      this->ShowJoints(false);
+    else
+    {
+      VisualPtr vis = this->GetVisual(_msg->data());
+      if (vis)
+        vis->ShowJoints(false);
+    }
   }
   else if (_msg->request() == "show_com")
   {
-    VisualPtr vis = this->GetVisual(_msg->data());
-    if (vis)
-      vis->ShowCOM(true);
+    if (_msg->data() == "all")
+      this->ShowCOMs(true);
     else
-      gzerr << "Unable to find joint visual[" << _msg->data() << "]\n";
+    {
+      VisualPtr vis = this->GetVisual(_msg->data());
+      if (vis)
+        vis->ShowCOM(true);
+      else
+        gzerr << "Unable to find joint visual[" << _msg->data() << "]\n";
+    }
   }
   else if (_msg->request() == "hide_com")
   {
-    VisualPtr vis = this->GetVisual(_msg->data());
-    if (vis)
-      vis->ShowCOM(false);
+    if (_msg->data() == "all")
+      this->ShowCOMs(false);
+    else
+    {
+      VisualPtr vis = this->GetVisual(_msg->data());
+      if (vis)
+        vis->ShowCOM(false);
+    }
   }
-  else if (_msg->request() == "set_transparency")
+  else if (_msg->request() == "set_transparent")
   {
-    VisualPtr vis = this->GetVisual(_msg->data());
-    if (vis)
-      vis->SetTransparency(_msg->dbl_data());
+    if (_msg->data() == "all")
+      this->SetTransparent(true);
+    else
+    {
+      VisualPtr vis = this->GetVisual(_msg->data());
+      if (vis)
+        vis->SetTransparency(0.5);
+    }
+  }
+  else if (_msg->request() == "set_opaque")
+  {
+    if (_msg->data() == "all")
+      this->SetTransparent(false);
+    else
+    {
+      VisualPtr vis = this->GetVisual(_msg->data());
+      if (vis)
+        vis->SetTransparency(0.0);
+    }
   }
   else if (_msg->request() == "show_skeleton")
   {
       {
         visual->SetVisible(false);
       }
+
+      visual->ShowCOM(this->showCOMs);
+      visual->ShowCollision(this->showCollisions);
+      visual->ShowJoints(this->showJoints);
+      visual->SetTransparency(this->transparent ? 0.5 : 0.0);
     }
   }
 
 }
 
 /////////////////////////////////////////////////
-void Scene::ViewContacts(bool _view)
+void Scene::SetTransparent(bool _show)
+{
+  this->transparent = _show;
+  for (Visual_M::iterator iter = this->visuals.begin();
+       iter != this->visuals.end(); ++iter)
+  {
+    iter->second->SetTransparency(_show ? 0.5 : 0.0);
+  }
+}
+
+/////////////////////////////////////////////////
+void Scene::ShowCOMs(bool _show)
+{
+  this->showCOMs = _show;
+  for (Visual_M::iterator iter = this->visuals.begin();
+       iter != this->visuals.end(); ++iter)
+  {
+    iter->second->ShowCOM(_show);
+  }
+}
+
+/////////////////////////////////////////////////
+void Scene::ShowCollisions(bool _show)
+{
+  this->showCollisions = _show;
+  for (Visual_M::iterator iter = this->visuals.begin();
+       iter != this->visuals.end(); ++iter)
+  {
+    iter->second->ShowCollision(_show);
+  }
+}
+
+/////////////////////////////////////////////////
+void Scene::ShowJoints(bool _show)
+{
+  this->showJoints = _show;
+  for (Visual_M::iterator iter = this->visuals.begin();
+       iter != this->visuals.end(); ++iter)
+  {
+    iter->second->ShowJoints(_show);
+  }
+}
+
+/////////////////////////////////////////////////
+void Scene::ShowContacts(bool _show)
 {
   ContactVisualPtr vis = boost::shared_dynamic_cast<ContactVisual>(
       this->visuals["__GUIONLY_CONTACT_VISUAL__"]);
 
-  if (!vis && _view)
+  if (!vis && _show)
   {
     vis.reset(new ContactVisual("__GUIONLY_CONTACT_VISUAL__",
               this->worldVisual, "~/physics/contacts"));
-    vis->SetEnabled(_view);
+    vis->SetEnabled(_show);
     this->visuals[vis->GetName()] = vis;
   }
 
   if (vis)
-    vis->SetEnabled(_view);
+    vis->SetEnabled(_show);
   else
     gzerr << "Unable to get contact visualization. This should never happen.\n";
 }

File gazebo/rendering/Scene.hh

       /// nothing is selected.
       public: VisualPtr GetSelectedVisual() const;
 
+      /// \brief Enable or disable transparency for all visuals.
+      /// \param[in] _show True to enable transparency for all visuals.
+      public: void SetTransparent(bool _show);
+
+      /// \brief Enable or disable center of mass visualization.
+      /// \param[in] _show True to enable center of mass visualization.
+      public: void ShowCOMs(bool _show);
+
+      /// \brief Enable or disable joint visualization.
+      /// \param[in] _show True to enable joint visualization.
+      public: void ShowJoints(bool _show);
+
+      /// \brief Enable or disable collision visualization.
+      /// \param[in] _show True to enable collision visualization.
+      public: void ShowCollisions(bool _show);
+
       /// \brief Enable or disable contact visualization.
-      /// \param[in] _view True to enable contact visualization.
-      public: void ViewContacts(bool _view);
+      /// \param[in] _show True to enable contact visualization.
+      public: void ShowContacts(bool _show);
 
       /// \brief Helper function to setup the sky.
       private: void SetSky();
 
       /// \brief Controls the sky.
       private: SkyX::BasicController *skyxController;
+
+      /// \brief True when all COMs should be visualized.
+      private: bool showCOMs;
+
+      /// \brief True when all collisions should be visualized.
+      private: bool showCollisions;
+
+      /// \brief True when all joints should be visualized.
+      private: bool showJoints;
+
+      /// \brief True when all objects should be transparent.
+      private: bool transparent;
     };
     /// \}
   }

File gazebo/rendering/Visual.cc

File contents unchanged.

File gazebo/sensors/RaySensor.cc

       this->parentName);
   this->laserCollision->SetName("ray_sensor_collision");
   this->laserCollision->SetRelativePose(this->pose);
+  this->laserCollision->SetInitialRelativePose(this->pose);
 
   this->laserShape = boost::dynamic_pointer_cast<physics::MultiRayShape>(
                      this->laserCollision->GetShape());

File gazebo/transport/Transport.cc

 boost::mutex requestMutex;
 bool g_stopped = true;
 
-const msgs::Request *g_request = NULL;
-msgs::Response *g_response = NULL;
+std::list<msgs::Request *> g_requests;
+std::list<boost::shared_ptr<msgs::Response> > g_responses;
 
 /////////////////////////////////////////////////
 bool transport::get_master_uri(std::string &master_host,
 /////////////////////////////////////////////////
 void on_response(ConstResponsePtr &_msg)
 {
-  if (!g_request || _msg->id() != g_request->id())
+  if (g_requests.size() <= 0)
     return;
 
-  if (!g_response)
-    g_response = new msgs::Response;
+  std::list<msgs::Request *>::iterator iter;
+  for (iter = g_requests.begin(); iter != g_requests.end(); ++iter)
+  {
+    if (_msg->id() == (*iter)->id())
+      break;
+  }
 
-  g_response->CopyFrom(*_msg);
-  g_responseCondition.notify_one();
+  // Stop if the response is not for any of the request messages.
+  if (iter == g_requests.end())
+    return;
+
+  boost::shared_ptr<msgs::Response> response(new msgs::Response);
+  response->CopyFrom(*_msg);
+  g_responses.push_back(response);
+
+  g_responseCondition.notify_all();
 }
 
 /////////////////////////////////////////////////
-msgs::Response transport::request(const std::string &_worldName,
-                                  const msgs::Request &_request)
+void transport::get_topic_namespaces(std::list<std::string> &_namespaces)
 {
-  boost::unique_lock<boost::mutex> lock(requestMutex);
-  g_response = NULL;
-  g_request = &_request;
+  TopicManager::Instance()->GetTopicNamespaces(_namespaces);
+}
+
+/////////////////////////////////////////////////
+boost::shared_ptr<msgs::Response> transport::request(
+    const std::string &_worldName, const std::string &_request,
+    const std::string &_data)
+{
+  boost::mutex::scoped_lock lock(requestMutex);
+
+  msgs::Request *request = msgs::CreateRequest(_request, _data);
+
+  g_requests.push_back(request);
 
   NodePtr node = NodePtr(new Node());
   node->Init(_worldName);
   PublisherPtr requestPub = node->Advertise<msgs::Request>("~/request");
   SubscriberPtr responseSub = node->Subscribe("~/response", &on_response);
 
-  requestPub->Publish(_request);
+  requestPub->Publish(*request);
 
-  g_responseCondition.wait(lock);
+  boost::shared_ptr<msgs::Response> response;
+  std::list<boost::shared_ptr<msgs::Response> >::iterator iter;
+
+  bool valid = false;
+  while (!valid)
+  {
+    // Wait for a response
+    g_responseCondition.wait(lock);
+
+    for (iter = g_responses.begin(); iter != g_responses.end(); ++iter)
+    {
+      if ((*iter)->id() == request->id())
+      {
+        response = *iter;
+        g_responses.erase(iter);
+        valid = true;
+        break;
+      }
+    }
+  }
 
   requestPub.reset();
   responseSub.reset();
   node.reset();
 
-  if (g_response != NULL)
-    return *g_response;
-  else
-    return msgs::Response();
+  delete request;
+  return response;
 }
 
 /////////////////////////////////////////////////
-void transport::get_topic_namespaces(std::list<std::string> &_namespaces)
+void transport::requestNoReply(const std::string &_worldName,
+                               const std::string &_request,
+                               const std::string &_data)
 {
-  TopicManager::Instance()->GetTopicNamespaces(_namespaces);
+  // Create a node for communication.
+  NodePtr node = NodePtr(new Node());
+
+  // Initialize the node, use the world name for the topic namespace.
+  node->Init(_worldName);
+
+  // Process the request.
+  requestNoReply(node, _request, _data);
+
+  // Cleanup the node.
+  node.reset();
 }
+
+/////////////////////////////////////////////////
+void transport::requestNoReply(NodePtr _node, const std::string &_request,
+                               const std::string &_data)
+{
+  // Create a publisher on the request topic.
+  PublisherPtr requestPub = _node->Advertise<msgs::Request>("~/request");
+
+  // Create a new request message
+  msgs::Request *request = msgs::CreateRequest(_request, _data);
+
+  // Publish the request message
+  requestPub->Publish(*request);
+
+  // Cleanup the request
+  delete request;
+
+  // Clean up the publisher.
+  requestPub.reset();
+}

File gazebo/transport/Transport.hh

     /// until a response is received.
     /// \param[in] _worldName The name of the world to which the request
     /// should be sent
-    /// \param[in] _request The request itself
+    /// \param[in] _request The type request.
+    /// \param[in] _data Optional data string.
     /// \return The response to the request.  Can be empty.
-    msgs::Response request(const std::string &_worldName,
-                           const msgs::Request &_request);
+    boost::shared_ptr<msgs::Response> request(const std::string &_worldName,
+                                              const std::string &_request,
+                                              const std::string &_data = "");
+
+    /// \brief Send a request and don't wait for a response. This is
+    /// non-blocking.
+    /// \param[in] _worldName The name of the world to which the request
+    /// should be sent.
+    /// \param[in] _request The type request.
+    /// \param[in] _data Optional data string.
+    void requestNoReply(const std::string &_worldName,
+                        const std::string &_request,
+                        const std::string &_data = "");
+
+    /// \brief Send a request and don't wait for a response. This is
+    /// non-blocking.
+    /// \param[in] _node Pointer to a node that provides communication.
+    /// \param[in] _request The type request.
+    /// \param[in] _data Optional data string.
+    void requestNoReply(NodePtr _node, const std::string &_request,
+                        const std::string &_data = "");
     /// \}
   }
 }

File sdf/worlds/shapes.world

         </visual>
       </link>
     </model>
+    <!--
     <model name="sphere">
       <pose>0 1.5 0.5 0 0 0</pose>
       <link name="link">
         </visual>
       </link>
     </model>
+-->
   </world>
 </sdf>