Robotics StackExchange | Archived questions

I want to subscribe the data of laser scaner in gazebo and become this error:

I built a car ( a chassis an four tiers) and as a sensor I built my own lidar sensor with respect to its specifications and following gazebo tutorials. When I run my world by writtin gz topic -l I can see my laser scan in gazebo’s topics under /gazebo/default/my_car/rplidar/top/sensor/scan, and I can see the data scanning of my sensor if I write gz topic -e /gazebo/default/my_car/rplidar/top/sensor/scan. but when I try to subscribe these data with a listener after compilling I became this error with false data:

[libprotobuf ERROR google/protobuf/wire_format_lite.cc:534] String field 'gazebo.msgs.LaserScan.frame' contains invalid UTF-8 data when parsing a protocol buffer. Use the 'bytes' type if you intend to send raw bytes.

Here is my listener code:

#include <gazebo/transport/transport.hh>

#include <gazebo/msgs/msgs.hh>

#include <gazebo/gazebo_client.hh>

#include <iostream>

// Function is called everytime a message is received.

void cb(ConstLaserScanPtr &_msg){

// Dump the message contents to stdout.

std::cout << _msg->DebugString();

}

int main(int _argc, char **_argv){

// Load gazebo gazebo::client::setup(_argc, _argv);

// Create the node for communication

gazebo::transport::NodePtr node(new gazebo::transport::Node());

node->Init();

// Listen to Gazebo my_car/rplidar/top/sensor/scan topic

gazebo::transport::SubscriberPtr sub = node->Subscribe("~/my_car/rplidar/top/sensor/scan", cb);

// Busy wait loop while (true) gazebo::common::Time::MSleep(10);

// Shut everything down

gazebo::client::shutdown();

}

Asked by Azar on 2019-07-23 03:13:43 UTC

Comments

Answers