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

asked 2017-06-29 01:39:47 -0500

djou07 gravatar image


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++){
cout << "min range= "<<min<<endl;

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

edit retag flag offensive close merge delete


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.

iche033 gravatar imageiche033 ( 2017-07-03 18:16:27 -0500 )edit