Gazebo resources: Tutorials | Q&A | Documentation | Blog

Retrieving Lidar data from Gazebo (not using ROS)


#1

Greetings Gazebo community,

I am trying to get Lidar data from the simulation. In Gazebo, if I select the topic for the for the Lidar (hokuyo/link/laser/scan) I can plot and visualize the rays and the obstacles seen by the lidar. 

My problem is how to get this data out of Gazebo for later use? So far, I have implemented a short program which body is the following:

///////////////////// laser_scan///////////////////////////////////////////
// input: ConstlaserScanPtr //
// ouput: Void //
// Comments: Updated every time a message is //
// received //
// messages to the console //
////////////////////////////////////////////////////////////////////////////////
void lidar_info(ConstLaserScanPtr &_msg)
{
double dAngle_minimum;
dAngle_minimum = _msg->angle_min();
std::cout << dAngle_minimum<<std::endl;
}

But I am getting the following error :

[libprotobuf ERROR google/protobuf/wire_format.cc:1053] String field contains invalid UTF-8 data when parsing a protocol buffer. Use the ‘bytes’ type if you intend to send raw bytes.
[libprotobuf ERROR google/protobuf/message_lite.cc:123] Can’t parse message of type “gazebo.msgs.LaserScan” because it is missing required fields: angle_min, angle_max, angle_step, range_min, range_max, count, world_pose.position, world_pose.orientation
[libprotobuf ERROR google/protobuf/wire_format.cc:1053] String field contains invalid UTF-8 data when parsing a protocol buffer. Use the ‘bytes’ type if you intend to send raw bytes.

and the reported value for the minimum angle is 0

Thanks in advance for any suggestions or examples,
John Gonzalez


#2

If I had to hazard a guess, the version of the message received by your program is different from the version used during compilation.

Can you provide the following information:

  • What version of gazebo are your using?
  • Do you have multiple versions of Gazebo installed?
  • Can you include a complete working example so that we can reproduce the problem?