Robotics StackExchange | Archived questions

I get different ray sensor data at each run (How to get exactly the same?)

Hi,

Is there a way to retrieve ray sensor data directly from the physics engine? so that I get exactly the same data at each run. I use Gazebo version 6. I tried the code bellow, but it doesn't work:

sensors::SensorPtr sensor=sensors::SensorManager::Instance()->GetSensor(sensorName);
sensors::RaySensorPtr laser=boost::dynamic_pointer_cast<sensors::RaySensor>(sensor);
physics::MultiRayShapePtr multiRayShape=laser->GetLaserShape();    

double min=multiRayShape->GetRange(0);
for(int i=0; i<640; i++){
    if(multiRayShape->GetRange(i)<min)
        min=multiRayShape->GetRange(i);
}
cout << "min range= "<<min<<endl;

This is the data I get with tow runs of the same simulation: image description

Asked by djou07 on 2017-06-29 01:39:47 UTC

Comments

Not sure if it will make any difference, but if you subscribe to the ray sensor topic, the messages received should be timestamped. So try plotting the min range against the timestamp from the messages, and hopefully that gives consistent results.

Asked by iche033 on 2017-07-03 18:16:27 UTC

Answers