Home | Tutorials | Wiki | Issues
Ask Your Question
0

how to bring up sensors in a stand alone Gazebo

asked 2015-09-22 06:28:34 -0600

scarlett gravatar image

Hello! I am starting a stand alone gazebo and loading a .world from a cpp file with :

    gazebo::setupServer();
    // Load a world
    gazebo::physics::WorldPtr world = gazebo::loadWorld(
                "worlds/pepper_base.world");
   for (unsigned int i = 0; i < 10000; ++i)
{
   gazebo::runWorld(world, 1);
}

This world include a robot model containing an hokuyo laser : pepper_model.sdf :

 <include>
      <uri>model://hokuyo</uri>
      <pose>0.0562 0 -0.303 0 -0.0175 0</pose>
    </include>
    <joint name="hokuyo_joint" type="revolute">
      <child>hokuyo::link</child>
      <parent>Tibia</parent>
      <axis>
        <xyz>0 0 1</xyz>
        <limit>
          <upper>0</upper>
          <lower>0</lower>
        </limit>
      </axis>
    </joint>

When I am importing this model from the GUI gazebo, no problem, I can listen the laser topic with :

gz topic -e /gazebo/default/virtual_pepper/hokuyo/link/laser/scan

But when launching my cpp program ( without any gazebo launched, except the server written above ), there is no data comming from the laser.

I tried several function from the gazebo API as :

gazebo::sensors::SensorManager *mgr = gazebo::sensors::SensorManager::Instance();
gazebo::sensors::Sensor_V vect_sensor = mgr->GetSensors();

=> to init() the captors "by hand" but vect_sensor is always empty

whereas :

 gazebo::physics::LinkPtr tibia= pepper->GetLink("Tibia");
 nom=tibia->GetSensorName(0);

give me the name of my sensor

What I am missing?

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
1

answered 2015-09-23 07:50:10 -0600

scarlett gravatar image

By searching into this file in Gazebo lib :

server.cc

I had the idea to add few lines in my code to take care of sensors :

    gazebo::setupServer();
    gazebo::physics::WorldPtr world = gazebo::loadWorld(
                "worlds/pepper_base.world");

    // Make sure the sensors are updated once before running the world.
    // This makes sure plugins get loaded properly.
    gazebo::sensors::run_once(true);
    gazebo::sensors::run_threads();

 for (unsigned int i = 0; i < 100000; ++i)
    {
        gazebo::runWorld(world, 1);
        gazebo::sensors::run_once();
        gazebo::common::Time::MSleep(1);
    }

Now it is working fine

edit flag offensive delete link more
Login/Signup to Answer

Question Tools

Stats

Asked: 2015-09-22 06:28:34 -0600

Seen: 983 times

Last updated: Sep 23 '15