Simplify the process of using gazebo as a library

#929 Merged at 9d0d8f1
Repository
Branch
api_update
Repository
Branch
gazebo_2.2
Author
  1. Nate Koenig
Reviewers
Description

This is in response to this question, where the user wants to use gazebo as a library in their own main loop.

The API to make this happen was very ugly. This PR simplifies the process of setting up gazebo for use as a client or a server.

Running ABI checker

Comments (15)

  1. Steve Peters

    There's a lot of sensor test failures (from console output of partially finished Jenkins job):

    The following tests FAILED:
        101 - UNIT_Sensor_TEST (Failed)
        109 - UNIT_GpuRaySensor_TEST (OTHER_FAULT)
        110 - check_UNIT_GpuRaySensor_TEST (Failed)
        111 - UNIT_SensorManager_TEST (Failed)
    
  2. Steve Peters

    I'm getting an error during the custom_main example:

    $ ./custom_main 
    Msg Waiting for master
    Msg Connected to gazebo master @ http://127.0.0.1:11345
    Msg Publicized address: 192.168.1.188
    Error [gazebo.cc:243] Unable to find file[empty.world]
    Iter
    Error [gazebo.cc:266] World pointer is NULL
    Iter
    Error [gazebo.cc:266] World pointer is NULL
    
  3. Steve Peters

    I'm also seeing the following error message fairly frequently (1 in 4) when opening gzserver:

    Error [Node.cc:84] No namespace found
    

    I haven't noticed it causing any problems, but it's probably bad anyway.

    There's also quite a few instances in the jenkins console output

    1. Steve Peters

      Looks fixed.

      I spoke too soon. I see this error stochastically during the custom_main example:

      $ ./custom_main 
      Msg Waiting for master
      Msg Connected to gazebo master @ http://127.0.0.1:11345
      Msg Publicized address: 192.168.1.188
      Error [Node.cc:84] No namespace found
      

      ~~~

      1. Steve Peters

        Looking into this a bit, I'm not sure the waitForNamespaces function is being used properly. Currently it waits a specified period of time and returns true if namespaces are found, otherwise false. None of the places that call that function actually check the return value though.

        I did some gdb and the complaint appears to arise from the LogRecord::Add function:

            frame #0: 0x00000001000619b1 libgazebo_transport.2.dylib`gazebo::transport::Node::Init(this=0x0000000107e2a9a0, _space=<unavailable>) + 689 at Node.cc:84
            frame #1: 0x0000000102a3c4da libgazebo_util.2.dylib`gazebo::util::LogRecord::Add(this=0x00000001002984f8, _name=0x00007fff5fbff108, _filename=0x00007fff5fbff100, _logCallback=<unavailable>)>) + 1418 at LogRecord.cc:312
            frame #2: 0x0000000100215d23 libgazebo_physics.2.dylib`gazebo::physics::World::Init(this=0x0000000108880200) + 1523 at World.cc:341
            frame #3: 0x000000010114ad1d libgazebo.2.dylib`gazebo::loadWorld(_worldFile=<unavailable>) + 925 at gazebo.cc:278
            frame #4: 0x0000000100005a12 custom_main`main + 178
        
  4. Nate Koenig author

    Thanks, they are all problems that I mostly have resolved. I'll update this PR shortly.

    1. Steve Peters

      Thanks Nate. I like the new API, by the way, really clean.

      I just had two comments about TransportIface.hh and DiffDrivePlugin.cc; otherwise it looks good to me.

      Now it's just the Node.hh error message in the custom_main example.

  5. Andrew Hundt

    Just a note, having the main version take char** and int parameters makes it a bit more difficult to use if you already process the command line arguments in a different way. Could the setup* functions also be overloaded as follows?

    setupServer(std::vector<std::string>& args)
    
    1. Steve Peters

      I would recommend creating an issue for this. It may not be too hard to create a wrapper function that can provide both interfaces.