Anonymous avatar Anonymous committed 9ceedf4

Debuged modebuilder widget. Point ligts work again. Added google tests for factory

Comments (0)

Files changed (59)

-cmake_minimum_required( VERSION 2.4.6 FATAL_ERROR )
+cmake_minimum_required( VERSION 2.8 FATAL_ERROR )
 
 if(COMMAND CMAKE_POLICY)
   CMAKE_POLICY(SET CMP0003 NEW)
 
 set (BUILD_GAZEBO ON CACHE INTERNAL "Build Gazebo" FORCE)
 
+set (INCLUDE_INSTALL_DIR "include/gazebo")
+set (LIB_INSTALL_DIR "lib")
+set (BIN_INSTALL_DIR "bin")
+
 
 # with -fPIC
 if(UNIX AND NOT WIN32)
    endif(CMAKE_SYSTEM_PROCESSOR MATCHES "x86_64")
  endif(CMAKE_UNAME)
 endif(UNIX AND NOT WIN32)
-                             
-set (MIN_OGRE_VERSION 1.6.3 CACHE INTERNAL "Ogre version requirement" FORCE)
+
+
+set (MIN_OGRE_VERSION 1.7.3 CACHE INTERNAL "Ogre version requirement" FORCE)
+set (MIN_ODE_VERSION 0.11.1 CACHE INTERNAL "ODE version requirement" FORCE)
+set (MIN_BOOST_VERSION 1.40.0 CACHE INTERNAL "Boost min version requirement" FORCE)
 
 set (FREEIMAGE_MAJOR_VERSION 3 CACHE INTERNAL "FreeImage major version requirement" FORCE)
 set (FREEIMAGE_MINOR_VERSION 9 CACHE INTERNAL "FreeImage minor version requirement" FORCE)
-set (FREEIMAGE_VERSION ${FREEIMAGE_MAJOR_VERSION}.${FREEIMAGE_MINOR_VERSION}.0 CACHE INTERNAL "FreeImage version requirement" FORCE)
-set (ODE_VERSION 0.10.1 CACHE INTERNAL "ODE version requirement" FORCE)
-set (MIN_BOOST_VERSION 1.35.0 CACHE INTERNAL "Boost min version requirement" FORCE)
+set (MIN_FREEIMAGE_VERSION ${FREEIMAGE_MAJOR_VERSION}.${FREEIMAGE_MINOR_VERSION}.0 CACHE INTERNAL "FreeImage version requirement" FORCE)
 
-#set (ENABLE_BINDINGS OFF CACHE BOOL "Enable libgazebo bindings")
 
 set (gazebo_cmake_dir ${PROJECT_SOURCE_DIR}/cmake CACHE PATH 
      "Location of CMake scripts")
 set (build_warnings "" CACHE INTERNAL "build warnings" FORCE)
 
 MESSAGE (STATUS "\n\n====== Finding 3rd Party Packages ======")
-INCLUDE (${gazebo_cmake_dir}/SearchForStuff.cmake)
+include (${gazebo_cmake_dir}/SearchForStuff.cmake)
 MESSAGE (STATUS "----------------------------------------\n")
 
 if ( build_warnings )
   ########################################
   # Write the config.h file
   configure_file (${PROJECT_SOURCE_DIR}/gazebo_config.h.in ${PROJECT_BINARY_DIR}/gazebo_config.h)
-  install(FILES ${PROJECT_BINARY_DIR}/gazebo_config.h DESTINATION ${CMAKE_INSTALL_PREFIX}/include/gazebo)
+  INSTALL_INCLUDES(${PROJECT_BINARY_DIR}/gazebo_config.h "")
 
   configure_file (${PROJECT_SOURCE_DIR}/gazebo.h.in ${PROJECT_BINARY_DIR}/gazebo.h)
-  install(FILES ${CMAKE_CURRENT_BINARY_DIR}/gazebo.h DESTINATION ${CMAKE_INSTALL_PREFIX}/include/gazebo)
+  INSTALL_INCLUDES(${CMAKE_CURRENT_BINARY_DIR}/gazebo.h "")
   
   ########################################
   # Make the gazebo rc file
   if (BUILD_GAZEBO)
     add_subdirectory(src)
     add_subdirectory(worlds)
+    add_subdirectory(Media)
+    add_subdirectory(test)
     #add_subdirectory(tools)
     #add_subdirectory(benchmarks)
-    add_subdirectory(Media)
-    
+   
     #if (INCLUDE_PLAYER)
     #  add_subdirectory(player)
     #  add_subdirectory(player_cfgs)
   ########################################
   # Make the package config files
   configure_file(${CMAKE_SOURCE_DIR}/cmake/gazebo_transport_pkgconfig.cmake ${CMAKE_CURRENT_BINARY_DIR}/cmake/gazebo_transport.pc @ONLY)
-  install(FILES ${CMAKE_CURRENT_BINARY_DIR}/cmake/gazebo_transport.pc DESTINATION ${CMAKE_INSTALL_PREFIX}/lib/pkgconfig COMPONENT pkgconfig)
+  install(FILES ${CMAKE_CURRENT_BINARY_DIR}/cmake/gazebo_transport.pc DESTINATION lib/pkgconfig COMPONENT pkgconfig)
 
-  # Cpack stuff
-  include (InstallRequiredSystemLibraries)
-  set (CPACK_PACKAGE_NAME "${PROJECT_NAME}")
+  ########################################
+  # Package Creation: 
+  include (${gazebo_cmake_dir}/gazebo_cpack.cmake)
+  set (CPACK_PACKAGE_VERSION "${GAZEBO_VERSION}")
   set (CPACK_PACKAGE_VERSION_MAJOR "${GAZEBO_MAJOR_VERSION}")
   set (CPACK_PACKAGE_VERSION_MINOR "${GAZEBO_MINOR_VERSION}")
   set (CPACK_PACKAGE_VERSION_PATCH "${GAZEBO_PATCH_VERSION}")
-  set (CPACK_PACKAGE_DESCRIPTION_SUMMARY "Gazebo robot simulator")
-  set (CPACK_PACKAGE_FILE_NAME "${PROJECT_NAME_LOWER}-${GAZEBO_VERSION}")
-  set (CPACK_SOURCE_PACKAGE_FILE_NAME "${PROJECT_NAME_LOWER}-${GAZEBO_VERSION}")
-  set (CPACK_RESOURCE_FILE_LICENSE "${PROJECT_SOURCE_DIR}/COPYING")
-  set (CPACK_GENERATOR "TBZ2")
-  set (CPACK_SOURCE_GENERATOR "TBZ2")
-  list (APPEND CPACK_SOURCE_IGNORE_FILES "/.svn/;.swp$;/build/")
-  include (CPack)
+
+  if (CPACK_GENERATOR)
+    message(STATUS "Found CPack generators: ${CPACK_GENERATOR}")
+
+    configure_file("${gazebo_cmake_dir}/cpack_options.cmake.in" ${GAZEBO_CPACK_CFG_FILE} @ONLY)
+    set(CPACK_PROJECT_CONFIG_FILE ${GAZEBO_CPACK_CFG_FILE})
+    include (CPack)
+  endif()
 
   message(STATUS "Configuration successful. Type make to compile gazebo")
-
 endif(build_errors)
 
-
-GAZEBOSERVER_RESET_LISTS()
 
    END OF TERMS AND CONDITIONS
 
-   APPENDIX: How to apply the Apache License to your work.
 
-      To apply the Apache License to your work, attach the following
-      boilerplate notice, with the fields enclosed by brackets "[]"
-      replaced with your own identifying information. (Don't include
-      the brackets!)  The text should be enclosed in the appropriate
-      comment syntax for the file format. We also recommend that a
-      file or class name and description of purpose be included on the
-      same "printed page" as the copyright notice for easier
-      identification within third-party archives.
-
-   Copyright [yyyy] [name of copyright owner]
-
-   Licensed under the Apache License, Version 2.0 (the "License");
-   you may not use this file except in compliance with the License.
-   You may obtain a copy of the License at
-
-       http://www.apache.org/licenses/LICENSE-2.0
-
-   Unless required by applicable law or agreed to in writing, software
-   distributed under the License is distributed on an "AS IS" BASIS,
-   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-   See the License for the specific language governing permissions and
-   limitations under the License.
 This is the Gazebo simulator.  Gazebo simulates multiple robots in a
 3D environment, with extensive dynamic interaction between objects.
 Gazebo was developed at the USC Robotics Research Lab as part of the
-Player/Stage project, and is fully compatible at with the Player robot
-device server.  Gazebo is available under the GNU General Public License (GPL)
-and can be downloaded from the Player/Stage homepage:
+Player/Stage project, and is partially support by Willow Garage (www.willowgarage.com). 
 
-  http://playerstage.sourceforge.net
+  http://gazebosim.org
 
 
 Installation
 ------------
-Read the installation instructions in the online manual for generic instructions.  For most people, the following sequence will suffice:
+Read the installation instructions (http://gazebosim.org/documentation.html) in the online manual for generic instructions.  For most people, the following sequence will suffice:
 
   $ mkdir build (inside the gazebo-trunk directory)
   $ cd build
 
 Uninstallation
 --------------
-Read the installation instructions in the online manual for generic instructions.  For most people, the following sequence will suffice:
+Read the installation instructions (http://gazebosim.org/documentation.html) in the online manual for generic instructions.  For most people, the following sequence will suffice:
 
-  $ make install (inside the gazebo-trunk/build directory)
+  $ make uninstall (inside the gazebo-trunk/build directory)
 
 
-3rd Party Libraries
-------------------
-Gazebo uses the following libraries:
-
-  Geospatial Data Abstraction Library (GDAL) http://www.remotesensing.org/gdal
-  OpenDynamicsEngine (ODE) http://opende.sourceforge.net
-  Ogre3D  http://www.ogre3d.org
-
-ODE and Ogre3D are mandatory. GDAL is required only for specific features
-such as the MapExtruder and Terrain models, but is highly recommended.
-
-
-On-line installation instructions
----------------------------------
-
-The latest installation instructions can be found on-line, at
-
-  http://playerstage.sourceforge.net/doc/
-
-or in these sources under the doc/ directory.
-
-General information (changelog, etc) can be found in the wiki pages, at
-
-  http://playerstage.sourceforge.net/wiki/Gazebo
-
-
-  - Andrew Howard (ahoward@usc.edu), Nate Koenig (nkoenig@usc.edu)
-
+- Nate Koenig

cmake/GazeboUtils.cmake

 endmacro (BUILD_WARNING)
 
 
-###############################################################################
-# Reset lists
-MACRO (GAZEBOSERVER_RESET_LISTS)
-  #SET (gazeboserver_sources "" CACHE INTERNAL 
-  #     ${gazeboserver_sources_desc} FORCE)
-  #SET (gazeboserver_headers "" CACHE INTERNAL 
-  #     ${gazeboserver_sources_desc} FORCE)
-  #SET (gazeboserver_headers_nopath "" CACHE INTERNAL 
-  #     "gazeboserver_headers_nopath" FORCE)
-  #SET (gazeboserver_include_dirs "" CACHE INTERNAL 
-  #     ${gazeboserver_include_dirs_desc} FORCE)
-  #SET (gazeboserver_link_dirs "" CACHE INTERNAL 
-  #     ${gazeboserver_link_dirs_desc} FORCE)
-  #SET (gazeboserver_link_libs "" CACHE INTERNAL 
-  #     ${gazeboserver_link_libs_desc} FORCE)
-  #SET (gazeboserver_ldflags "" CACHE INTERNAL 
-  #     ${gazeboserver_ldflags_desc} FORCE)
-  #SET (gazeboserver_cflags "" CACHE INTERNAL 
-  #     ${gazeboserver_cflags_desc} FORCE)
-  #SET (gazebosensor_sources "" CACHE INTERNAL 
-  #     ${gazebosensor_sources_desc} FORCE)
-  #SET (gazebocontroller_sources "" CACHE INTERNAL 
-  #     ${gazebocontroller_sources_desc} FORCE)
-  #set (bullet_link_libs "" CACHE INTERNAL 
-  #     ${bullet_link_libs_desc} FORCE)
-ENDMACRO (GAZEBOSERVER_RESET_LISTS)
+macro (INSTALL_INCLUDES _subdir)
+  install(FILES ${ARGN} DESTINATION ${INCLUDE_INSTALL_DIR}/${_subdir} COMPONENT headers)
+endmacro(INSTALL_INCLUDES)
+
+macro (INSTALL_LIBRARY _name)
+  install (TARGETS ${_name} DESTINATION ${LIB_INSTALL_DIR})
+endmacro (INSTALL_LIBRARY _name)
+
+macro (INSTALL_EXECUTABLE _name)
+  install (TARGETS ${_name} DESTINATION ${BIN_INSTALL_DIR})
+endmacro (INSTALL_EXECUTABLE _name)
+

cmake/SearchForStuff.cmake

 
   #################################################
   # Find ODE
-  pkg_check_modules(ODE ode>=${ODE_VERSION})
+  pkg_check_modules(ODE ode>=${MIN_ODE_VERSION})
   IF (NOT ODE_FOUND)
     BUILD_ERROR ("Missing: ODE(http://www.ode.org)")
     SET (INCLUDE_ODE FALSE CACHE BOOL "Include support for ODE")
   set (OGRE_INCLUDE_DIRS ${ogre_include_dirs} CACHE INTERNAL "Ogre include path")
 
   #################################################
-  # Find GTK
-  pkg_check_modules(GTK2 gtk+-2.0)
-  if (NOT GTK2_FOUND)
-    BUILD_ERROR("Missing: gtk+-2.0")
-  endif (NOT GTK2_FOUND)
-
-
-  #################################################
   # Find XML
   pkg_check_modules(XML libxml-2.0)
   if (NOT XML_FOUND)

src/CMakeLists.txt

 add_subdirectory(msgs)
 add_subdirectory(transport)
 add_subdirectory(common)
-add_subdirectory(libgazebo)
+#add_subdirectory(libgazebo)
 add_subdirectory(rendering)
 add_subdirectory(gui)
 add_subdirectory(physics)
 add_subdirectory(sensors)
 
+add_dependencies( gazebo_physics gazebo_msgs )
 add_dependencies( gazebo_common gazebo_msgs )
 add_dependencies( gazebo_gui gazebo_msgs )
 add_dependencies( gazebo_rendering gazebo_msgs )
                                 pthread)
                                 
 
-install (TARGETS gzmaster DESTINATION ${CMAKE_INSTALL_PREFIX}/bin)
-install (TARGETS gzserver DESTINATION ${CMAKE_INSTALL_PREFIX}/bin)
-install (TARGETS gzclient DESTINATION ${CMAKE_INSTALL_PREFIX}/bin)
-install (TARGETS gzsensor DESTINATION ${CMAKE_INSTALL_PREFIX}/bin)
-install (TARGETS gzcombined DESTINATION ${CMAKE_INSTALL_PREFIX}/bin)
+INSTALL_EXECUTABLE( gzmaster )
+INSTALL_EXECUTABLE( gzserver )
+INSTALL_EXECUTABLE( gzclient )
+INSTALL_EXECUTABLE( gzsensor )
+INSTALL_EXECUTABLE( gzcombined )
 Combined::Combined()
 {
   this->quit = false;
+  this->runThread = NULL;
 
   // load the configuration options 
   try
 Combined::~Combined()
 {
   delete this->master;
+  delete this->masterThread;
 }
 
 void Combined::Load(const std::string &filename)
     gzthrow("Unable to intialize the rendering engine");
 
   rendering::create_scene("default");
-
-  sensors::SensorPtr sensor1 = sensors::create_sensor("camera");
-  sensors::SensorPtr sensor2 = sensors::create_sensor("camera");
-
 }
 
 void Combined::Init()
     physics::init_world(this->worlds[i]);
 }
 
-void Combined::Run()
+void Combined::Start()
 {
-  this->transportThread = new boost::thread( &transport::run );
+  this->quit = false;
 
   for (int i=0; i < this->worlds.size(); i++)
     physics::run_world(this->worlds[i]);
 
+  this->runThread = new boost::thread(boost::bind(&Combined::RunLoop, this)); 
+}
+
+void Combined::Stop()
+{
+  for (int i=0; i < this->worlds.size(); i++)
+    physics::stop_world(this->worlds[i]);
+
+  this->quit = true;
+  this->master->Quit();
+  if (this->runThread)
+  {
+    this->runThread->join();
+    delete this->runThread;
+    this->runThread = NULL;
+  }
+
+  transport::fini();
+}
+
+void Combined::RunLoop()
+{
+  transport::run();
+
   while (!this->quit)
   {
     sensors::run_once(true);
   }
 
-  for (int i=0; i < this->worlds.size(); i++)
-    physics::stop_world(this->worlds[i]);
-
-  transport::fini();
-
   this->masterThread->join();
 }
 
-void Combined::Quit()
-{
-  this->master->Quit();
-  this->quit = true;
-}
-
 void Combined::SetParams( const common::StrStr_M &params )
 {
   common::StrStr_M::const_iterator iter;
 
     public: void Load(const std::string &filename);
     public: void Init();
-    public: void Run();
-    public: void Quit();
+    public: void Start();
+    public: void Stop();
 
     public: void SetParams( const common::StrStr_M &params );
 
+    private: void RunLoop();
+
     private: std::vector< physics::WorldPtr > worlds;
     private: bool quit;
 
     private: Master *master;
-    private: boost::thread *masterThread, *transportThread;
+    private: boost::thread *masterThread;
+    private: boost::thread *runThread;
   };
 }
 
 
   // Start the transport system by connecting to the master.
   transport::init();
-
-  // TODO: Move this to someplace proper
-  transport::set_topic_namespace("default");
 }
 
 GuiClient::~GuiClient()

src/audio_video/CMakeLists.txt

 
 set_target_properties(gazebo_av PROPERTIES OUTPUT_NAME "gazebo_av" VERSION ${GAZEBO_VERSION})
 
-install (TARGETS gazebo_av DESTINATION ${CMAKE_INSTALL_PREFIX}/lib)
+INSTALL_LIBRARY(gazebo_av)
+INSTALL_INCLUDES("audio_video" ${headers})
 #include <signal.h>
 #include <errno.h>
 #include <iostream>
+#include <boost/interprocess/sync/interprocess_semaphore.hpp>
 
 #include "gazebo_config.h"
 #include "common/CommonTypes.hh"
 std::string config_filename = "";
 gazebo::common::StrStr_M params;
 
+boost::interprocess::interprocess_semaphore sem(0);
+
 ////////////////////////////////////////////////////////////////////////////////
 // TODO: Implement these options
 void PrintUsage()
 // sighandler to shut everything down properly
 void SignalHandler( int )
 {
-  combined->Quit();
+  sem.post();
 }
 
 int main(int argc, char **argv)
   combined->Load(config_filename);
   combined->SetParams( params );
   combined->Init();
-  combined->Run();
+  combined->Start();
 
+  sem.wait();
+
+  combined->Stop();
   delete combined;
   combined = NULL;
 }

src/common/CMakeLists.txt

                                      ${assimp_libraries}
                                      ${freeimage_library})
 
-install ( TARGETS gazebo_common DESTINATION ${CMAKE_INSTALL_PREFIX}/lib )
-install (FILES ${headers} DESTINATION ${CMAKE_INSTALL_PREFIX}/include/gazebo/common COMPONENT headers)
+INSTALL_LIBRARY(gazebo_common)
+INSTALL_INCLUDES("common" ${headers})

src/common/Messages.cc

 
 msgs::Light Message::LightFromXML(XMLConfigNode *node)
 {
+  XMLConfigNode *cnode = NULL;
   msgs::Light result;
 
   std::string type = node->GetString("type","point",1);
   else if (type == "directional")
     result.set_type(msgs::Light::DIRECTIONAL);
 
-  result.mutable_pose()->mutable_position()->CopyFrom( Convert(node->GetVector3("xyz",Vector3(0,0,0))) );  
-  result.mutable_pose()->mutable_orientation()->CopyFrom( Convert(node->GetRotation("rpy", Quatern() )) );
+  if ((cnode = node->GetChild("origin")) != NULL)
+  {
+    result.mutable_pose()->mutable_position()->CopyFrom( Convert(cnode->GetVector3("xyz",Vector3(0,0,0))) );  
+    result.mutable_pose()->mutable_orientation()->CopyFrom( Convert(cnode->GetRotation("rpy", Quatern() )) );
+  }
 
-  result.mutable_diffuse()->CopyFrom( Convert( node->GetColor("diffuse", Color(1,1,1,1)) ) );
-  result.mutable_specular()->CopyFrom( Convert( node->GetColor("specular", Color(0,0,0,1)) ) );
-  result.mutable_attenuation()->CopyFrom( Convert( 
-        node->GetVector3("attenuation",Vector3(.2, 0.1, 0.0)) ) );
-  result.mutable_direction()->CopyFrom( Convert( node->GetVector3("direction",Vector3(0, 0, -1)) ) );
+  if ((cnode = node->GetChild("diffuse")) != NULL)
+  {
+    result.mutable_diffuse()->CopyFrom( 
+        Convert( cnode->GetColor("color", Color(1,1,1,1)) ) );
+  }
+
+  if ((cnode = node->GetChild("specular")) != NULL)
+  {
+    result.mutable_specular()->CopyFrom( 
+        Convert( cnode->GetColor("color", Color(0,0,0,1)) ) );
+  }
+
+  if ((cnode = node->GetChild("attenuation")) != NULL)
+  {
+    result.mutable_attenuation()->set_x(cnode->GetFloat("constant",0.2,1));
+    result.mutable_attenuation()->set_y(cnode->GetFloat("linear",0.1,1));
+    result.mutable_attenuation()->set_z(cnode->GetFloat("quadratic",0.0,1));
+  }
+
+  result.mutable_direction()->CopyFrom( 
+      Convert( node->GetVector3("direction",Vector3(0, 0, -1)) ) );
   result.set_range( node->GetDouble("range",20,1) );
   result.set_cast_shadows( node->GetBool("cast_shadows",false,0) );
 

src/gui/BoxMaker.cc

 {
   this->camera = camera;
 
-  gzdbg << "Start BoxMaker\n";
   std::ostringstream stream;
   stream << "user_box_" << counter++;
   this->visualMsg->mutable_header()->set_str_id( stream.str() );
 
 void BoxMaker::Stop()
 {
-  gzdbg << "Stop BoxMaker\n";
   this->visualMsg->set_action( msgs::Visual::DELETE );
   this->visPub->Publish(*this->visualMsg);
   this->visualMsg->set_action( msgs::Visual::UPDATE );
   if (this->state == 0)
     return;
 
-  gzdbg << "BoxMaker: OnMouseDrag\n";
   common::Vector3 norm(0,0,1);
   common::Vector3 p1, p2;
 
 
 void BoxMaker::CreateTheEntity()
 {
-  gzdbg << "BoxMaker: Create the entity\n";
-  msgs::InsertModel msg;
+  msgs::Factory msg;
   common::Message::Init(msg, "new_box");
 
   std::ostringstream newModelStr;
 
   newModelStr << "<?xml version='1.0'?>";
 
-  newModelStr << "<model type='physical' name='" << this->visualMsg->header().str_id() << "'>\
-    <xyz>" << this->visualMsg->pose().position().x() << " " 
-           << this->visualMsg->pose().position().y() << " " 
-           << this->visualMsg->pose().position().z() << "</xyz>\
-    <body name='body'>\
-    <geom type='box' name='geom'>\
-    <size>" << this->visualMsg->scale().x() << " "
-            << this->visualMsg->scale().y() << " "
-            << this->visualMsg->scale().z() << "</size>\
-    <mass>0.5</mass>\
-    <visual>\
-    <mesh>unit_box_U1V1</mesh>\
-    <scale>" << this->visualMsg->scale().x() << " "
-             << this->visualMsg->scale().y() << " "
-             << this->visualMsg->scale().z() << "</scale>\
-    <material>Gazebo/Grey</material>\
-    <shader>pixel</shader>\
-    </visual>\
-    </geom>\
-    </body>\
-    </model>";
+  newModelStr << "<model name='" << this->visualMsg->header().str_id() << "'>\
+    <static>false</static>\
+    <origin xyz='" << this->visualMsg->pose().position().x() << " " 
+                    << this->visualMsg->pose().position().y() << " " 
+                    << this->visualMsg->pose().position().z() << "'/>\
+    <link name='body'>\
+      <collision name='geom'>\
+        <geometry>\
+          <box size='" << this->visualMsg->scale().x() << " "
+                       << this->visualMsg->scale().y() << " "
+                       << this->visualMsg->scale().z() << "'/>\
+        </geometry>\
+        <mass>0.5</mass>\
+      </collision>\
+      <visual>\
+        <geometry>\
+          <box size='" << this->visualMsg->scale().x() << " "
+                       << this->visualMsg->scale().y() << " "
+                       << this->visualMsg->scale().z() << "'/>\
+        </geometry>\
+        <material name='Gazebo/Grey'/>\
+        <cast_shadows>true</cast_shadows>\
+        <shader>pixel</shader>\
+      </visual>\
+    </link>\
+  </model>";
 
   msg.set_xml( newModelStr.str() );
 
   this->visualMsg->set_action( msgs::Visual::DELETE );
   this->visPub->Publish(*this->visualMsg);
 
-  //Simulator::Instance()->SendMessage( msg );
+  this->makerPub->Publish(msg);
 }

src/gui/CMakeLists.txt

 
 add_library(gazebo_gui SHARED ${sources} ${headers_MOC} ${headers} ${resources_RCC})
                                          
-target_link_libraries(gazebo_gui Xpm  ${QT_LIBRARIES} ${ogre_libraries} ${CMAKE_LINK_LIBS_${CMAKE_BUILD_TYPE}} ${boost_libraries})
+target_link_libraries(gazebo_gui Xpm  ${QT_LIBRARIES} ${ogre_libraries} ${CMAKE_LINK_LIBS_${CMAKE_BUILD_TYPE}} ${boost_libraries} gazebo_physics)
 
 
 if (CMAKE_LINK_FLAGS_${CMAKE_BUILD_TYPE})
 
 set_target_properties(gazebo_gui PROPERTIES OUTPUT_NAME "gazebo_gui" VERSION ${GAZEBO_VERSION})
 
-install (TARGETS gazebo_gui DESTINATION ${CMAKE_INSTALL_PREFIX}/lib)
-install (FILES ${headers} ${qt_headers} DESTINATION ${CMAKE_INSTALL_PREFIX}/include/gazebo/gui COMPONENT headers)
+INSTALL_LIBRARY(gazebo_gui)
+INSTALL_INCLUDES( "gui" ${headers} ${qt_headers})

src/gui/CylinderMaker.cc

 
 void CylinderMaker::CreateTheEntity()
 {
-  msgs::InsertModel msg;
+  msgs::Factory msg;
   common::Message::Init(msg,"new cylinder");
   std::ostringstream newModelStr;
 
   newModelStr << "<?xml version='1.0'?>";
 
-  newModelStr << "<model type='physical' name='" << this->visualMsg->header().str_id() << "'>\
-    <xyz>" << this->visualMsg->pose().position().x() << " " 
-           << this->visualMsg->pose().position().y() << " " 
-           << this->visualMsg->pose().position().z() << "</xyz>\
-    <body name='body'>\
-    <geom type='cylinder' name='geom'>\
-    <size>" << this->visualMsg->scale().x()*.5 << " " 
-            << this->visualMsg->scale().z() << "</size>\
-    <mass>0.5</mass>\
-    <visual>\
-    <mesh>unit_cylinder</mesh>\
-    <scale>" << this->visualMsg->scale().x() << " "
-             << this->visualMsg->scale().y() << " "
-             << this->visualMsg->scale().z() << "</scale>\
-    <material>Gazebo/Grey</material>\
-    <shader>pixel</shader>\
-    </visual>\
-    </geom>\
-    </body>\
-    </model>";
+  newModelStr << "<model name='" << this->visualMsg->header().str_id() << "'>\
+    <static>false</static>\
+    <origin xyz='" << this->visualMsg->pose().position().x() << " " 
+                   << this->visualMsg->pose().position().y() << " " 
+                   << this->visualMsg->pose().position().z() << "'/>\
+    <link name='body'>\
+      <collision name='geom'>\
+        <geometry>\
+          <cylinder radius='" << this->visualMsg->scale().x()*.5 << "'\
+                    length='" << this->visualMsg->scale().z() << "'/>\
+        </geometry>\
+        <mass>0.5</mass>\
+      </collision>\
+      <visual>\
+        <geometry>\
+          <cylinder radius='" << this->visualMsg->scale().x()*.5 << "'\
+                    length='" << this->visualMsg->scale().z() << "'/>\
+        </geometry>\
+        <material name='Gazebo/Grey'/>\
+        <shader>pixel</shader>\
+        <cast_shadows>pixel</cast_shadows>\
+      </visual>\
+    </link>\
+  </model>";
 
   msg.set_xml( newModelStr.str() );
 
+  common::Message::Stamp(this->visualMsg->mutable_header());
   this->visualMsg->set_action( msgs::Visual::DELETE );
-  common::Message::Stamp(this->visualMsg->mutable_header());
   this->visPub->Publish(*this->visualMsg);
-  //Simulator::Instance()->SendMessage( msg );
+
+  this->makerPub->Publish(msg);
 }
 

src/gui/EntityMaker.cc

  *
 */
 #include "transport/Transport.hh"
+#include "transport/Node.hh"
 #include "gui/EntityMaker.hh"
 
 using namespace gazebo;
 /// Constructor
 EntityMaker::EntityMaker()
 {
-  this->visPub = transport::advertise<msgs::Visual>("/model_builder/visual");
+  this->node = transport::NodePtr(new transport::Node());
+  this->node->Init("model_builder");
+  this->visPub = this->node->Advertise<msgs::Visual>("~/visual");
+  this->makerPub = this->node->Advertise<msgs::Factory>("~/factory");
 }
 
 ////////////////////////////////////////////////////////////////////////////////

src/gui/EntityMaker.hh

       protected: virtual void CreateTheEntity() = 0;
   
       protected: rendering::UserCameraPtr camera; 
+
+      protected: transport::NodePtr node;
       protected: transport::PublisherPtr visPub;
+      protected: transport::PublisherPtr makerPub;
 
       private: static bool snapToGrid;
       private: static double snapDistance;

src/gui/MainWindow.cc

 #include "common/Exception.hh"
 #include "common/XMLConfig.hh"
 
+#include "transport/Node.hh"
 #include "transport/Transport.hh"
 
 #include "gui/ModelBuilderWidget.hh"
   QVBoxLayout *mainLayout = new QVBoxLayout;
   mainWidget->show();
 
-  this->worldControlPub = transport::advertise<msgs::WorldControl>("~/world_control");
+  this->node = transport::NodePtr(new transport::Node());
+  this->node->Init("default");
+  this->worldControlPub = this->node->Advertise<msgs::WorldControl>("~/world_control");
 
   this->glWidget = new RenderWidget(mainWidget);
   this->glWidget->hide();
 
 void MainWindow::NewModel()
 {
-  gzmsg << "new Model\n";
   ModelBuilderWidget *modelBuilder = new ModelBuilderWidget();
   modelBuilder->Init();
   modelBuilder->show();

src/gui/MainWindow.hh

       private: TimePanel *timePanel;
       private: RenderWidget *glWidget;
 
+      private: transport::NodePtr node;
       private: transport::PublisherPtr worldControlPub;
     };
   }

src/gui/ModelBuilderWidget.cc

 #include "rendering/Rendering.hh"
 #include "rendering/UserCamera.hh"
 
+#include "physics/World.hh"
+#include "physics/Physics.hh"
+
 #include "gui/GLWidget.hh"
 
 #include "gui/ModelBuilderWidget.hh"
 
   this->setLayout(mainLayout);
   this->layout()->setContentsMargins(0,0,0,0);
+
+  physics::init();
+  this->world = physics::create_world("model_builder");
+  this->world->Load(NULL);
+  this->world->Init();
+  this->world->SetPaused(true);
 }
 
 ModelBuilderWidget::~ModelBuilderWidget()

src/gui/ModelBuilderWidget.hh

 
 #include <QWidget>
 
+#include "physics/PhysicsTypes.hh"
+
 namespace gazebo
 {
   class GLWidget;
 
       private: GLWidget *glWidget; 
       private: QAction *boxCreateAct, *sphereCreateAct, *cylinderCreateAct;
+
+      private: physics::WorldPtr world;
     };
   }
 }

src/gui/SphereMaker.cc

 
 void SphereMaker::CreateTheEntity()
 {
-  msgs::InsertModel msg;
+  msgs::Factory msg;
   common::Message::Init(msg, "new_sphere");
   std::ostringstream newModelStr;
 
   newModelStr << "<?xml version='1.0'?>";
 
-  newModelStr << "<model type='physical' name='" << this->visualMsg->header().str_id() << "'>\
-    <xyz>" << this->visualMsg->pose().position().x() << " "
-           << this->visualMsg->pose().position().y() << " "
-           << this->visualMsg->pose().position().z() << "</xyz>\
-    <body name='body'>\
-    <geom type='sphere' name='geom'>\
-    <size>" << this->visualMsg->scale().x() << " "
-            << this->visualMsg->scale().y() << " "
-            << this->visualMsg->scale().z() << "</size>\
-    <mass>0.5</mass>\
-    <visual>\
-    <mesh>unit_sphere</mesh>\
-    <scale>" << this->visualMsg->scale().x() << " "
-             << this->visualMsg->scale().y() << " "
-             << this->visualMsg->scale().z() << "</scale>\
-    <material>Gazebo/Grey</material>\
-    <shader>pixel</shader>\
-    </visual>\
-    </geom>\
-    </body>\
-    </model>";
+  newModelStr << "<model name='" << this->visualMsg->header().str_id() << "'>\
+    <origin xyz='" << this->visualMsg->pose().position().x() << " " 
+                    << this->visualMsg->pose().position().y() << " " 
+                    << this->visualMsg->pose().position().z() << "'/>\
+    <link name='body'>\
+      <collision name='geom'>\
+        <geometry>\
+          <sphere radius='" << this->visualMsg->scale().x() << "'/>\
+        </geometry>\
+        <mass>0.5</mass>\
+      </collision>\
+      <visual>\
+        <geometry>\
+          <sphere radius='" << this->visualMsg->scale().x() << "'/>\
+        </geometry>\
+        <material name='Gazebo/Grey'/>\
+        <cast_shadows>true</cast_shadows>\
+        <shader>pixel</shader>\
+      </visual>\
+    </link>\
+  </model>";
 
   msg.set_xml( newModelStr.str() );
 
+  common::Message::Stamp(this->visualMsg->mutable_header());
   this->visualMsg->set_action( msgs::Visual::DELETE );
-  common::Message::Stamp(this->visualMsg->mutable_header());
   this->visPub->Publish(*this->visualMsg);
 
-  //Simulator::Instance()->SendMessage( msg );
+  this->makerPub->Publish(msg);
 }

src/gui/TimePanel.cc

 #include <QtGui>
 #include <sstream>
 
-#include "TimePanel.hh"
+#include "transport/Node.hh"
+#include "gui/TimePanel.hh"
 
 using namespace gazebo;
 using namespace gui;
   this->setLayout(mainLayout);
   this->layout()->setContentsMargins(0,0,0,0);
 
-  this->statsSub = transport::subscribe("/gazebo/default/world_stats", &TimePanel::OnStats, this);
+  this->node = transport::NodePtr(new transport::Node());
+  this->node->Init("default");
+  this->statsSub = this->node->Subscribe("~/world_stats", &TimePanel::OnStats, this);
 
   QTimer *timer = new QTimer(this);
   connect( timer, SIGNAL(timeout()), this, SLOT(Update()) );

src/gui/TimePanel.hh

 #define TIME_PANEL_HH
 
 #include <QWidget>
-#include "transport/Transport.hh"
+#include "transport/TransportTypes.hh"
+#include "msgs/MessageTypes.hh"
 #include "common/Time.hh"
 
 class QLineEdit;
       private: common::Time lastUpdateTime,statusUpdatePeriod;
       private: common::Time simTime, realTime, pauseTime;
       private: transport::SubscriberPtr statsSub;
+
+      private: transport::NodePtr node;
     };
   }
 }

src/msgs/CMakeLists.txt

 
 set (msgs color.proto
           header.proto
-          insert_model.proto
+          factory.proto
           light.proto
           plane.proto
           point.proto
           topic_info.proto
           world_stats.proto
           world_control.proto
+          entity.proto
 )
 
 
 
 configure_file ( ${PROJECT_SOURCE_DIR}/src/msgs/MessageTypes.hh.in ${CMAKE_CURRENT_BINARY_DIR}/MessageTypes.hh )
 
-install (TARGETS gazebo_msgs DESTINATION ${CMAKE_INSTALL_PREFIX}/lib)
-install (FILES ${PROTO_HDRS} ${CMAKE_CURRENT_BINARY_DIR}/MessageTypes.hh  DESTINATION ${CMAKE_INSTALL_PREFIX}/include/gazebo/msgs COMPONENT headers)
-
+INSTALL_LIBRARY(gazebo_msgs)
+INSTALL_INCLUDES("msgs" ${PROTO_HDRS} ${CMAKE_CURRENT_BINARY_DIR}/MessageTypes.hh)

src/msgs/factory.proto

+package gazebo.msgs;
+import "header.proto";
+
+message Factory
+{
+  required Header header = 1;
+  required string xml = 2;
+}

src/msgs/insert_model.proto

-package gazebo.msgs;
-import "header.proto";
-
-message InsertModel
-{
-  required Header header = 1;
-  required string xml = 2;
-}

src/physics/CMakeLists.txt

   target_link_libraries(gazebo_physics gazebo_physics_ode)
 endif()
 
-install ( TARGETS gazebo_physics DESTINATION ${CMAKE_INSTALL_PREFIX}/lib )
-install (FILES ${headers} DESTINATION ${CMAKE_INSTALL_PREFIX}/include/gazebo/physics COMPONENT headers)
+INSTALL_LIBRARY(gazebo_physics)
+INSTALL_INCLUDES("physics" ${headers})

src/physics/Entity.cc

 
 #include "transport/Publisher.hh"
 #include "transport/Transport.hh"
+#include "transport/Node.hh"
 
 #include "physics/Geom.hh"
 #include "physics/Model.hh"
 Entity::Entity(BasePtr parent)
   : Base(parent)
 {
+  this->node = transport::NodePtr(new transport::Node());
   this->AddType(ENTITY);
 
-  this->posePub = transport::advertise<msgs::Pose>("~/pose");
-  this->visPub = transport::advertise<msgs::Visual>("~/visual");
-
   common::Param::Begin(&this->parameters);
   this->staticP = new common::ParamT<bool>("static",false,0);
   this->staticP->Callback( &Entity::SetStatic, this );
 void Entity::Load(common::XMLConfigNode *node)
 {
   Base::Load(node);
+  this->node->Init(this->GetWorld()->GetName());
+  this->posePub = this->node->Advertise<msgs::Pose>("~/pose");
+  this->visPub = this->node->Advertise<msgs::Visual>("~/visual");
 
   this->visualMsg->mutable_header()->set_str_id(this->GetCompleteScopedName());
 

src/physics/Entity.hh

       private: common::Pose3d initialPose;
       private: common::Pose3d relativePose;
 
+      private: transport::NodePtr node;
       private: transport::PublisherPtr posePub;
       protected: transport::PublisherPtr visPub;
 

src/physics/Joint.cc

 Joint::Joint()
   : Base(BasePtr())
 {
-  this->vis_pub = transport::advertise<msgs::Visual>("~/visual");
   this->AddType(Base::JOINT);
   this->showJoints = false;
 
 // Desctructor
 Joint::~Joint()
 {
-  if (!this->visual.empty())
+  /*if (!this->visual.empty())
   {
     msgs::Visual msg;
     common::Message::Init(msg, this->visual);
     msg.set_action( msgs::Visual::DELETE );
     this->vis_pub->Publish(msg);
   }
+  */
 
   delete this->erpP;
   delete this->cfmP;
 {
   Base::Load(node);
 
+  //this->node->Init(this->GetWorld()->GetName());
+  //this->vis_pub = transport::advertise<msgs::Visual>("~/visual");
+
   this->childNameP->Load(node->GetChild("child"));
   this->parentNameP->Load(node->GetChild("parent"));
   this->anchorOffsetP->Load(node);
 // Set the joint to show visuals
 void Joint::ShowJoints(const bool &s)
 {
-  msgs::Visual msg;
+  /*msgs::Visual msg;
   common::Message::Init(msg, this->visual);
   msg.set_visible(s);
   this->vis_pub->Publish(msg);
   this->showJoints = s;
+  */
 }
 
 //////////////////////////////////////////////////////////////////////////////

src/physics/Physics.cc

 
 physics::WorldPtr physics::create_world(const std::string &name)
 {
-    physics::WorldPtr world( new physics::World() );
-    return world;
+  physics::WorldPtr world( new physics::World(name) );
+  return world;
 }
 
 void physics::load_world(WorldPtr world, common::XMLConfigNode *node)

src/physics/PhysicsEngine.cc

 #include "common/Events.hh"
 
 #include "transport/Transport.hh"
+#include "transport/Node.hh"
 
 #include "physics/World.hh"
 #include "physics/PhysicsEngine.hh"
 PhysicsEngine::PhysicsEngine(WorldPtr world)
   : world(world)
 {
-  this->vis_pub = transport::advertise<msgs::Visual>("~/visual");
+  this->node = transport::NodePtr(new transport::Node());
+  this->node->Init(world->GetName());
+  this->vis_pub = this->node->Advertise<msgs::Visual>("~/visual");
 
   common::Param::Begin(&this->parameters);
   this->gravityP = new common::ParamT<common::Vector3>("gravity",common::Vector3(0.0, -9.80665, 0.0), 0);

src/physics/PhysicsEngine.hh

       protected: common::Param_V parameters;
   
       protected: std::string visual;
+      protected: transport::NodePtr node;
       protected: transport::PublisherPtr vis_pub;
       private: event::ConnectionPtr showContactConnection; 
   

src/physics/PhysicsFactory.cc

  * SVN info: $Id:$
  */
 
-#include "World.hh"
-#include "PhysicsEngine.hh"
-#include "PhysicsFactory.hh"
+#include "physics/World.hh"
+#include "physics/PhysicsEngine.hh"
+#include "physics/PhysicsFactory.hh"
+#include "common/Console.hh"
 #include "gazebo_config.h"
 
 #ifdef INCLUDE_ODE
   {
     result = (engines[classname]) (world);
   }
+  else
+    gzerr << "Invalid Physics Type[" << classname << "]\n";
 
   return result;
 }

src/physics/RayShape.cc

   this->AddType(RAY_SHAPE);
   this->SetName("Ray");
 
-  this->vis_pub = transport::advertise<msgs::Visual>("~/visual");
+  /*this->vis_pub = transport::advertise<msgs::Visual>("~/visual");
   if (displayRays)
   {
     msgs::Visual msg;
 
     // NATY: put back in
     //this->lineMsg->visibility = GZ_LASER_CAMERA;
-  }
+  }*/
 
   this->contactLen = DBL_MAX;
   this->contactRetro = 0.0;
   pt = msg.add_points();
   common::Message::Set(pt, this->relativeEndPos );
 
-  this->vis_pub->Publish(msg);
+  //this->vis_pub->Publish(msg);
 }
 
 ////////////////////////////////////////////////////////////////////////////////
   common::Message::Set(pt, this->relativeStartPos );
   pt = msg.add_points();
   common::Message::Set(pt,  this->relativeEndPos );
-  this->vis_pub->Publish(msg);
+  //this->vis_pub->Publish(msg);
 }
 
 ////////////////////////////////////////////////////////////////////////////////

src/physics/World.cc

  */
 
 #include <boost/thread.hpp>
+#include <boost/thread/mutex.hpp>
 
 #include <tbb/parallel_for.h>
 #include <tbb/blocked_range.h>
 
+#include "transport/Node.hh"
 #include "transport/Transport.hh"
 #include "transport/Publisher.hh"
 #include "transport/Subscriber.hh"
 };
 
 ////////////////////////////////////////////////////////////////////////////////
-// Private constructor
-World::World()
+// constructor
+World::World(const std::string &name)
 {
   this->stepInc = false;
   this->pause = false;
 
-  
+  this->name = name;
+
+  this->updateMutex = new boost::mutex();
+
   common::Param::Begin(&this->parameters);
-  this->nameP = new common::ParamT<std::string>("name","default",1);
+  // NO Parameters...
   common::Param::End();
 
+
   this->connections.push_back( 
      event::Events::ConnectStepSignal( boost::bind(&World::OnStep, this) ) );
   this->connections.push_back( 
 // Private destructor
 World::~World()
 {
-  delete this->nameP;
   this->connections.clear();
   this->Fini();
 }
 // Load the world
 void World::Load(common::XMLConfigNode *rootNode)//, unsigned int serverId)
 {
+  common::XMLConfigNode *physicsNode = NULL;
+
   // DO THIS FIRST
-  this->nameP->Load(rootNode);
+  if (rootNode)
+  {
+    this->sceneMsg.CopyFrom( 
+        common::Message::SceneFromXML(rootNode->GetChild("scene")) );
+    physicsNode = rootNode->GetChild("physics");
+  }
+
+  this->node = transport::NodePtr(new transport::Node());
+  this->node->Init(this->GetName());
 
   // The period at which statistics about the world are published
   this->statPeriod = common::Time(0,200000000);
 
-  // Set the global topic namespace
-  transport::set_topic_namespace(**this->nameP);
 
   common::Message::Init( this->worldStatsMsg, "statistics" );
 
-  this->sceneMsg.CopyFrom( 
-      common::Message::SceneFromXML(rootNode->GetChild("scene")) );
+  this->factorySub = this->node->Subscribe("~/factory", 
+                                           &World::OnFactoryMsg, this);
 
-  this->controlSub = transport::subscribe("~/world_control", 
-                                        &World::OnControl, this);
 
-  this->sceneSub = transport::subscribe("~/publish_scene", 
+  this->controlSub = this->node->Subscribe("~/world_control", 
+                                           &World::OnControl, this);
+
+  this->sceneSub = this->node->Subscribe("~/publish_scene", 
                                         &World::PublishScene, this);
-  this->scenePub = transport::advertise<msgs::Scene>("~/scene");
+  this->visSub = this->node->Subscribe("~/visual", &World::VisualLog, this);
 
-  this->statPub = transport::advertise<msgs::WorldStatistics>("~/world_stats");
-  this->visSub = transport::subscribe("~/visual", &World::VisualLog, this);
-
-  this->selectionPub = transport::advertise<msgs::Selection>("~/selection");
-
-  common::XMLConfigNode *physicsNode = NULL;
-  if (rootNode )
-    physicsNode = rootNode->GetChild("physics");
+  this->scenePub = this->node->Advertise<msgs::Scene>("~/scene");
+  this->statPub = this->node->Advertise<msgs::WorldStatistics>("~/world_stats");
+  this->selectionPub = this->node->Advertise<msgs::Selection>("~/selection");
+  this->newEntityPub = this->node->Advertise<msgs::Entity>("~/new_entity");
 
   if (physicsNode)
   {
     std::string type = physicsNode->GetString("type","ode",1);
 
     this->physicsEngine = PhysicsFactory::NewPhysicsEngine( type, shared_from_this());
-    if (this->physicsEngine == NULL)
-      gzthrow("Unable to create physics engine\n");
   }
   else
+  {
     this->physicsEngine = PhysicsFactory::NewPhysicsEngine("ode", shared_from_this());
+  }
+
+  if (this->physicsEngine == NULL)
+    gzthrow("Unable to create physics engine\n");
 
   // This should come before loading of entities
   this->physicsEngine->Load(physicsNode);
   this->rootElement->SetName("root");
   this->rootElement->SetWorld(shared_from_this());
 
-  // First, create all the entities
-  this->LoadEntities(rootNode, this->rootElement);
+  // Create all the entities
+  if (rootNode)
+    this->LoadEntities(rootNode, this->rootElement);
 
   // Choose threaded or unthreaded model updating depending on the number of
   // models in the scene
 
   stream << "<world>\n";
 
-  stream << prefix << "  " << *(this->nameP);
+  stream << prefix << "  " << this->name;
 
   this->physicsEngine->Save(prefix, stream);
 
 
   this->startTime = common::Time::GetWallTime();
 
-  this->stop = false;
-
   // Set a default sleep time
   req.tv_sec  = 0;
   req.tv_nsec = 10000;
       this->pauseTime += step;
     else
     {
+      boost::mutex::scoped_lock lock(*this->updateMutex);
       this->simTime += step;
       this->Update();
     }
 /// Get the name of the world
 std::string World::GetName() const
 {
-  return **this->nameP;
+  return this->name;
 }
 
 ////////////////////////////////////////////////////////////////////////////////
   return this->rootElement->GetByName(name);
 }
 
+////////////////////////////////////////////////////////////////////////////////
+// Load a model 
+ModelPtr World::LoadModel(common::XMLConfigNode *node, BasePtr parent)
+{
+  ModelPtr model( new Model(parent) );
+  model->SetWorld(shared_from_this());
+  model->Load(node);
+
+  event::Events::addEntitySignal(model->GetCompleteScopedName());
+  this->models.push_back(model);
+
+  msgs::Entity msg;
+  common::Message::Init(msg, model->GetCompleteScopedName() );
+  msg.set_name(model->GetCompleteScopedName());
+
+  this->newEntityPub->Publish(msg);
+
+  return model;
+}
+
 ///////////////////////////////////////////////////////////////////////////////
 // Load a model
 void World::LoadEntities( common::XMLConfigNode *node, BasePtr parent )
   cnode = node->GetChild("model");
   while (cnode)
   {
-    ModelPtr model( new Model(parent) );
-    model->SetWorld(shared_from_this());
-    model->Load(cnode);
+    this->LoadModel(cnode, parent);
 
     // TODO : Put back in the ability to nest models. We should do this
     // without requiring a joint.
 
-    event::Events::addEntitySignal(model->GetCompleteScopedName());
-    this->models.push_back(model);
-
     cnode = cnode->GetNext("model");
   }
 
   {
     msgs::Light *lm = this->sceneMsg.add_light();
     lm->CopyFrom( common::Message::LightFromXML(cnode) );
+
     cnode = cnode->GetNext("light");
   }
 }
   common::Message::Stamp(this->sceneMsg.mutable_header());
 
   this->sceneMsg.clear_pose();
-  this->BuildSceneMsg(this->sceneMsg, this->rootElement);
-  this->scenePub->Publish( this->sceneMsg );
+  if (this->rootElement)
+  {
+    this->BuildSceneMsg(this->sceneMsg, this->rootElement);
+    this->scenePub->Publish( this->sceneMsg );
+  }
 }
 
 ////////////////////////////////////////////////////////////////////////////////
 // Construct a scene message
 void World::BuildSceneMsg(msgs::Scene &scene, BasePtr entity)
 {
-  if (entity->HasType(Entity::ENTITY))
+  if (entity)
   {
-    msgs::Pose *poseMsg = scene.add_pose();
-    common::Pose3d pose = boost::shared_static_cast<Entity>(entity)->GetRelativePose();
-    poseMsg->CopyFrom( common::Message::Convert(pose) );
-    common::Message::Init(*poseMsg, entity->GetCompleteScopedName() );
-  }
+    if (entity->HasType(Entity::ENTITY))
+    {
+      msgs::Pose *poseMsg = scene.add_pose();
+      common::Pose3d pose = boost::shared_static_cast<Entity>(entity)->GetRelativePose();
+      poseMsg->CopyFrom( common::Message::Convert(pose) );
+      common::Message::Init(*poseMsg, entity->GetCompleteScopedName() );
+    }
 
-  for (unsigned int i=0; i < entity->GetChildCount(); i++)
-  {
-    this->BuildSceneMsg( scene, entity->GetChild(i) );
+    for (unsigned int i=0; i < entity->GetChildCount(); i++)
+    {
+      this->BuildSceneMsg( scene, entity->GetChild(i) );
+    }
   }
 }
 
     (*iter)->Update();
   }
 }
+
+////////////////////////////////////////////////////////////////////////////////
+// Received a factory msg
+void World::OnFactoryMsg( const boost::shared_ptr<msgs::Factory const> &msg)
+{
+  // Load the world file
+  gazebo::common::XMLConfig *xmlFile = new gazebo::common::XMLConfig();
+  
+  try
+  {
+    xmlFile->LoadString(msg->xml());
+  }
+  catch (common::Exception e)
+  {
+    gzthrow("The XML config file can not be loaded, please make sure is a correct file\n" << e); 
+  }
+
+  common::XMLConfigNode *rootNode(xmlFile->GetRootNode());
+
+  {
+    boost::mutex::scoped_lock lock(*this->updateMutex);
+    // Add the new models into the World
+    ModelPtr model = this->LoadModel( rootNode, BasePtr() );
+    model->Init();
+  }
+}

src/physics/World.hh

 namespace boost
 {
   class thread;
+  class mutex;
 }
 
 namespace gazebo
     class World : public boost::enable_shared_from_this<World>
     {
       /// Private constructor
-      public: World();
+      public: World(const std::string &name);
     
       /// Private destructor
       public: ~World();
       /// \param node XMLConfg node pointer
       /// \param parent Parent of the model to load
       private: void LoadEntities(common::XMLConfigNode *node, BasePtr parent);
+
+      /// \brief Load a model
+      private: ModelPtr LoadModel(common::XMLConfigNode *node, BasePtr parent);
  
       /// \brief Function to run physics. Used by physicsThread
       private: void RunLoop();
 
       private: void VisualLog(const boost::shared_ptr<msgs::Visual const> &msg);
 
+      private: void OnFactoryMsg( const boost::shared_ptr<msgs::Factory const> &data);
 
       /// \brief TBB version of model updating
       private: void ModelUpdateTBB();
     
       private: std::vector<google::protobuf::Message> messages;
     
-      private: common::ParamT<std::string> *nameP;
+      private: std::string name;
                
       /// Current simulation time
       private: common::Time simTime, pauseTime, startTime;
       private: bool stepInc;
     
       private: event::Connection_V connections;
-    
+
+      private: transport::NodePtr node;    
       private: transport::PublisherPtr selectionPub, scenePub;
-      private: transport::PublisherPtr statPub;
-      private: transport::SubscriberPtr visSub, sceneSub, controlSub;
+      private: transport::PublisherPtr statPub, worldPub, newEntityPub;
+      private: transport::SubscriberPtr visSub, sceneSub, controlSub, factorySub;
 
       private: msgs::WorldStatistics worldStatsMsg;
       private: msgs::Scene sceneMsg;
       private: common::Time prevStatTime;
       private: common::Time pauseStartTime;
       private: common::Time realTimeOffset;
+
+      private: boost::mutex *updateMutex;
     };
 
   }

src/physics/ode/ODEBody.cc

   {
     this->bodyId = dBodyCreate(this->odePhysics->GetWorldId());
 
-    gzdbg << "ODEBody::Init [" << this->GetCompleteScopedName() << "] Static[" << this->IsStatic() << "] BodyID[" << this->bodyId << "]\n";
-
     dBodySetData(this->bodyId, this);
     dBodySetAutoDisableDefaults(this->bodyId);
     dBodySetAutoDisableFlag(this->bodyId, this->GetAutoDisable());

src/rendering/CMakeLists.txt

                                         ${ogre_libraries} 
                                         ${OPENGL_LIBRARIES} 
                                         X11 )
-
-install ( TARGETS gazebo_rendering DESTINATION ${CMAKE_INSTALL_PREFIX}/lib )
-install (FILES ${headers} DESTINATION ${CMAKE_INSTALL_PREFIX}/include/gazebo/rendering COMPONENT headers)
+INSTALL_LIBRARY(gazebo_rendering)
+INSTALL_INCLUDES("rendering" ${headers})

src/rendering/Light.cc

         "Unable to create a light");
   }
 
+  gzdbg << "Type[" << **this->lightTypeP  << "]\n";
+  gzdbg << "Diffuse[" << **this->diffuseP << "]\n";
+  gzdbg << "Direction[" << **this->directionP << "]\n";
+  gzdbg << "Attenuation[" << **this->attenuationP << "]\n";
+
   this->SetLightType( **this->lightTypeP );
   this->SetDiffuseColor(**this->diffuseP);
   this->SetSpecularColor(**this->specularP);

src/rendering/RenderEngine.cc

 // Create a scene
 ScenePtr RenderEngine::CreateScene(const std::string &name)
 {
-  gzdbg << "Create a scene\n";
   ScenePtr scene( new Scene(name) );
   scene->Load(NULL);
 

src/rendering/Scene.cc

 
 //#include "rendering/RTShaderSystem.hh"
 #include "transport/Transport.hh"
+#include "transport/Node.hh"
 
 #include "rendering/Scene.hh"
 
 /// Constructor
 Scene::Scene(const std::string &name)
 {
+  this->node = transport::NodePtr(new transport::Node());
+  this->node->Init(name);
   this->id = idCounter++;
   this->idString = boost::lexical_cast<std::string>(this->id);
 
   this->raySceneQuery = NULL;
   this->type = GENERIC;
 
-
-  // Set the global topic namespace
-  transport::set_topic_namespace(name);
-
   this->receiveMutex = new boost::mutex();
 
   this->connections.push_back( event::Events::ConnectPreRenderSignal( boost::bind(&Scene::PreRender, this) ) );
   common::Param::End();
 
   
-  this->sceneSub = transport::subscribe("~/scene", &Scene::ReceiveSceneMsg, this);
+  this->sceneSub = this->node->Subscribe("~/scene", &Scene::ReceiveSceneMsg, this);
 
-  this->visSub = transport::subscribe("~/visual", &Scene::ReceiveVisualMsg, this);
-  this->lightSub = transport::subscribe("~/light", &Scene::ReceiveLightMsg, this);
-  this->poseSub = transport::subscribe("~/pose", &Scene::ReceivePoseMsg, this);
-  this->selectionSub = transport::subscribe("~/selection", &Scene::HandleSelectionMsg, this);
+  this->visSub = this->node->Subscribe("~/visual", &Scene::ReceiveVisualMsg, this);
+  this->lightSub = this->node->Subscribe("~/light", &Scene::ReceiveLightMsg, this);
+  this->poseSub = this->node->Subscribe("~/pose", &Scene::ReceivePoseMsg, this);
+  this->selectionSub = this->node->Subscribe("~/selection", &Scene::HandleSelectionMsg, this);
 }
 
 ////////////////////////////////////////////////////////////////////////////////
 
   // Send a request to get the current world state
   // TODO: Use RPC or some service call to get this properly
-  transport::PublisherPtr pub = transport::advertise<msgs::Request>("/gazebo/default/publish_scene");
+  transport::PublisherPtr pub = this->node->Advertise<msgs::Request>("~/publish_scene");
   msgs::Request req;
   req.set_request("publish");
 

src/rendering/Scene.hh

       private: Light_M lights;
 
       private: boost::mutex *receiveMutex;
-  
+
+      private: transport::NodePtr node;  
       private: transport::SubscriberPtr sceneSub;
       private: transport::SubscriberPtr visSub;
       private: transport::SubscriberPtr lightSub;

src/sensors/CMakeLists.txt

                                      ${boost_libraries}
                                      )
 
-install ( TARGETS gazebo_sensors DESTINATION ${CMAKE_INSTALL_PREFIX}/lib )
-install (FILES ${headers} DESTINATION ${CMAKE_INSTALL_PREFIX}/include/gazebo/sensors COMPONENT headers)
+INSTALL_LIBRARY(gazebo_sensors)
+INSTALL_INCLUDES("sensors" ${headers})

src/sensors/Sensors.cc

   // Register all the sensor types
   sensors::SensorFactory::RegisterAll();
 
-  transport::set_topic_namespace(world_name);
-
   return true;
 }
 

src/server/CMakeLists.txt

 configure_file(${CMAKE_SOURCE_DIR}/cmake/gazeboserver_pkgconfig.cmake ${CMAKE_CURRENT_BINARY_DIR}/gazeboserver.pc @ONLY)
 install(FILES ${CMAKE_CURRENT_BINARY_DIR}/gazeboserver.pc DESTINATION ${CMAKE_INSTALL_PREFIX}/lib/pkgconfig COMPONENT pkgconfig)
 
-
 install (TARGETS gazebo_server_library DESTINATION ${CMAKE_INSTALL_PREFIX}/lib)
 #install (TARGETS gazebo-exec DESTINATION ${CMAKE_INSTALL_PREFIX}/bin)
 install (TARGETS gazebo_server DESTINATION ${CMAKE_INSTALL_PREFIX}/bin)
 install (TARGETS gazebo_client DESTINATION ${CMAKE_INSTALL_PREFIX}/bin)
 install (FILES ${gazeboserver_headers} DESTINATION ${CMAKE_INSTALL_PREFIX}/include/gazebo COMPONENT headers)
 
-
-# INCLUDE DIRS
-#${TBB_INCLUDE_DIRS}
-#${ODE_INCLUDE_DIRS}
-#${ogre_include_dirs}
-#${XML_INCLUDE_DIRS}
-#${XPM_INCLUDE_DIRS}
-#${OAL_INCLUDE_DIRS}
-#${AVF_INCLUDE_DIRS}
-#${AVC_INCLUDE_DIRS})
-
-# LINK DIRS
-#${TBB_LIBRARY_DIRS}
-#${ODE_LIBRARY_DIRS}
-#${ogre_library_dirs}
-#${GTK2_LIBRARY_DIRS} 
-#${XML_LIBRARY_DIRS}
-#${XPM_LIBRARY_DIRS}
-#${OAL_LIBRARY_DIRS}
-#${AVF_LIBRARY_DIRS}
-#${AVC_LIBRARY_DIRS})
-
-# LINK LIBS
-#${TBB_LINK_LIBS} ${TBB_LIBRARIES}
-#${ODE_LINK_LIBS} ${ODE_LIBRARIES}
-#${ogre_link_libs} ${ogre_libraries}
-#${GTK2_LINK_LIBS} ${GTK2_LIBRARIES}
-#${XML_LINK_LIBS} ${XML_LIBRARIES}
-#${XPM_LINK_LIBS} ${XPM_LIBRARIES}
-#${OAL_LINK_LIBS} ${OAL_LIBRARIES}
-#${AVF_LINK_LIBS} ${AVF_LIBRARIES}
-#${AVC_LINK_LIBS} ${AVC_LIBRARIES}
-
-# LD FLAGS
-#${TBB_LDFLAGS}
-#${ODE_LDFLAGS}
-#${ogre_ldflags}
-#${GTK2_LDFLAGS}
-#${XML_LDFLAGS}
-
-# C Flags
-#${ogre_cflags})
-#${GTK2_CFLAGS})
-#${XML_CFLAGS})
-
-
-# REMOVED FROM SEARCHFORSTUFF
-  #APPEND_TO_CACHED_LIST(gazeboserver_ldflags
-  #                      ${gazeboserver_ldflags_desc} 
-  #                      ${bullet_lflags})
-
-

src/transport/CMakeLists.txt

              SubscriptionTransport.cc
              PublicationTransport.cc
              Transport.cc
+             Node.cc
 ) 
 
 set (headers TopicManager.hh
              SubscribeOptions.hh
              Transport.hh
              TransportTypes.hh
+             Node.hh
 )
 
 add_library(gazebo_transport SHARED ${sources})
                                        gazebo_msgs 
                                        ${boost_libraries})
 
-install (TARGETS gazebo_transport DESTINATION ${CMAKE_INSTALL_PREFIX}/lib)
-install (FILES ${headers} DESTINATION ${CMAKE_INSTALL_PREFIX}/include/gazebo/transport COMPONENT headers)
+INSTALL_LIBRARY(gazebo_transport)
+INSTALL_INCLUDES("transport" ${headers})

src/transport/ConnectionManager.cc

     serverConn( new Connection() )
 {
   this->initialized = false;
+  this->thread = NULL;
 }
 
 ////////////////////////////////////////////////////////////////////////////////
 // Destructor
 ConnectionManager::~ConnectionManager()
 {
+  this->Stop();
   this->connections.clear();
   this->masterConn.reset();
   this->serverConn.reset();
   this->masterConn->StartRead( boost::bind(&ConnectionManager::OnMasterRead, this, _1) );
 
   this->initialized = true;
+  this->stop = false;
 }
 
 ////////////////////////////////////////////////////////////////////////////////
 // Finalize
 void ConnectionManager::Fini()
 {
+  this->Stop();
+
+  this->connections.clear();
+  this->masterConn->Cancel();
+  this->masterConn->StopRead();
+  this->masterConn->Close();
+}
+
+////////////////////////////////////////////////////////////////////////////////
+// Start the conneciton manager
+void ConnectionManager::Start()
+{
+  this->stop = false;
+  this->thread = new boost::thread( 
+      boost::bind(&ConnectionManager::RunLoop, this));
+}
+
+////////////////////////////////////////////////////////////////////////////////
+// Stop the conneciton manager
+void ConnectionManager::Stop()
+{
+  this->stop = true;
+  if (this->thread)
+  {
+    this->thread->join();
+    delete this->thread;
+    this->thread = NULL;
+  }
 }
 
 ////////////////////////////////////////////////////////////////////////////////
 // Run all the connections
-void ConnectionManager::Run()
+void ConnectionManager::RunLoop()
 {
   std::list<ConnectionPtr>::iterator iter;
-  while (true)
+  while (!this->stop)
   {
     this->masterConn->ProcessWriteQueue();
 

src/transport/ConnectionManager.hh

       public: void Init( const std::string &master_host, 
                          unsigned short master_port);
 
+      /// \brief Finalize the conneciton manager
       public: void Fini();
 
-      public: void Run();
+      /// \brief Start the conneciton manager
+      public: void Start();
+
+      /// \brief Stop the conneciton manager
+      public: void Stop();
 
       public: void Subscribe( const std::string &topic, 
                               const std::string &msgType);
       /// \brief Remove a connection
       public: void RemoveConnection(ConnectionPtr &conn);
  
+      /// \brief Run the connection manager loop
+      private: void RunLoop();
+
       /// \brief Find a connection that matches a host and port
       private: ConnectionPtr FindConnection(const std::string &host, 
                                             unsigned short port);
       private: std::list<ConnectionPtr> connections;
 
       private: bool initialized;
+      private: bool stop;
+      private: boost::thread *thread;
 
       //Singleton implementation
       private: friend class SingletonT<ConnectionManager>;

src/transport/TopicManager.cc

  *
 */
 
-#include <boost/algorithm/string.hpp>
 
 #include "common/Messages.hh"
 #include "transport/Publication.hh"
 // Constructor
 TopicManager::TopicManager()
 {
-  this->topicNamespace = "";
 }
 
 ////////////////////////////////////////////////////////////////////////////////
 // Subscribe to a topic give some options
 SubscriberPtr TopicManager::Subscribe(const SubscribeOptions &ops)
 {
-  std::string topic = this->DecodeTopicName( ops.GetTopic() );
   CallbackHelperPtr subscription = ops.GetSubscription();
 
   // Create a subscription (essentially a callback that gets 
   //CallbackHelperPtr subscription( new CallbackHelperT<M>( callback ) );
   //this->subscribed_topics[topic].push_back(subscription);
   
-  this->subscribed_topics[topic].push_back(subscription);
+  this->subscribed_topics[ops.GetTopic()].push_back(subscription);
 
   // The object that gets returned to the caller of this
   // function
-  SubscriberPtr sub( new Subscriber(topic, subscription) );
+  SubscriberPtr sub( new Subscriber(ops.GetTopic(), subscription) );
 
   // Find a current publication
-  PublicationPtr pub = this->FindPublication(topic);
+  PublicationPtr pub = this->FindPublication(ops.GetTopic());
 
   // If the publication exits, just add the subscription to it 
   if (pub)
   else
   {
     // Otherwise subscribe to the remote topic
-    ConnectionManager::Instance()->Subscribe(topic, ops.GetMsgType());
+    ConnectionManager::Instance()->Subscribe(ops.GetTopic(), ops.GetMsgType());
   }
 
   return sub;
 void TopicManager::ConnectPubToSub( const std::string &topic,
                                     const SubscriptionTransportPtr &sublink )
 {
-
-  if (topic == "/gazebo/default/publish_scene")
-    gzdbg << "Connect Pub To Sub\n";
-    
   PublicationPtr publication = this->FindPublication( topic );
   publication->AddSubscription( sublink );
 }
     std::list<CallbackHelperPtr>::iterator cbIter;
     for (cbIter = iter->second.begin(); cbIter != iter->second.end(); cbIter++)
     {
-      if (topic == "/gazebo/default/publish_scene")
-        gzdbg << "Connect Subscribers\n";
       publication->AddSubscription( *cbIter );
     }
   }
   return inserted;
 }
 
-std::string TopicManager::DecodeTopicName(const std::string &topic)
-{
-  std::string result = topic;
-  boost::replace_first(result, "~", "/gazebo/" + this->topicNamespace);
-  boost::replace_first(result, "//", "/");
-  return result;
-}
-
-std::string TopicManager::EncodeTopicName(const std::string &topic)
-{
-  std::string result = topic;
-  boost::replace_first(result, "/gazebo/" + this->topicNamespace, "~");
-  boost::replace_first(result, "//", "/");
-
-  return result;
-}
-
-void TopicManager::SetTopicNamespace(const std::string &space)
-{
-  this->topicNamespace = space;
-}
-
-void TopicManager::Fini()
-{
-  ConnectionManager::Instance()->Fini();
-}
-
 ////////////////////////////////////////////////////////////////////////////////
 /// Stop advertising on a topic
 void TopicManager::Unadvertise(const std::string &topic)

src/transport/TopicManager.hh

       public: template<typename M>
               PublisherPtr Advertise(const std::string &topic)
               {
-                std::string decodedTopic = this->DecodeTopicName(topic);
-
                 google::protobuf::Message *msg = NULL;
                 M msgtype;
                 msg = dynamic_cast<google::protobuf::Message *>(&msgtype);
                 if (!msg)
                   gzthrow("Advertise requires a google protobuf type");
 
-                if (this->UpdatePublications(decodedTopic, msg->GetTypeName()))
+                if (this->UpdatePublications(topic, msg->GetTypeName()))
                 {
-                  ConnectionManager::Instance()->Advertise(decodedTopic,
+                  ConnectionManager::Instance()->Advertise(topic,
                                                            msg->GetTypeName());
                 }
 
                 // Connect all local subscription to the publisher
-                PublicationPtr publication = this->FindPublication( decodedTopic );
+                PublicationPtr publication = this->FindPublication( topic );
                 SubMap::iterator iter;
                 for (iter = this->subscribed_topics.begin(); 
                      iter != this->subscribed_topics.end(); iter++)
                 {
-                  if ( iter->first == decodedTopic )
+                  if ( iter->first == topic )
                   {
                     std::list<CallbackHelperPtr>::iterator liter;
                     for (liter = iter->second.begin(); 
                   }
                 }
 
-                return PublisherPtr( new Publisher(decodedTopic, msg->GetTypeName()) );