How to run gmapping with CARLA

asked 2020-09-03 03:36:59 -0500

stef_pap gravatar image

updated 2020-09-03 11:34:00 -0500

Hello, I am trying to take a map (OGM) running gmapping (http://wiki.ros.org/gmapping) and taking sensors' measurements from CARLA simulator but the map doesn't exist in RViz. Specifically, I am running the following commands:

  • cd /opt/carla-simulator/bin
  • ./CarlaUE4.sh
  • roslaunch carla_ros_bridge carla_ros_bridge_with_rviz.launch
  • python3 custom_vehicle.py
  • rosrun pointcloud_to_laserscan pointcloud_to_laserscan_node cloud_in:=/carla/vehicle/097/lidar/front/point_cloud
  • rosrun gmapping slam_gmapping scan:=scan _base_frame:=vehicle/097

The number 097 in the topics might need change, because it is a random number generated by CARLA. You can check which number is generated by running "rostopic list".

I am trying to see if the corresponding topic takes messages correctly using the command "rostopic hz map" but the result is:

subscribed to [/map]
WARNING: may be using simulated time
no new messages
no new messages

which means that the 'map' topic doesn't take any messages.

The gmapping node gives the following result:

Scan Matching Failed, using odometry. Likelihood=0
lp:-32.0918 -173.326 1.08019
op:-20.6543 -162.97 0.599922
Average Scan Matching Score=0

I know that gmapping needs as input "sensor_msgs/LaserScan" messages in order to work properly, but the Lidar that is used by CARLA gives "sensor_msgs/PointCloud2" messages. Therefore, I use the package pointcloud_to_laserscan (http://wiki.ros.org/pointcloud_to_las...) to make the conversion from "sensor_msgs/PointCloud2" to "sensor_msgs/LaserScan".The result I take from the conversion is:

header: 
  seq: 33
  stamp: 
    secs: 178
    nsecs: 799193305
  frame_id: "vehicle/097/lidar/front"
angle_min: -1.57079637051
angle_max: 1.57079637051
angle_increment: 0.00872664619237
time_increment: 0.0
scan_time: 0.0333333350718
range_min: 0.449999988079
range_max: 4.0
ranges: [inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, 14.330135345458984, inf, inf, inf, 13.099976539611816, inf, inf, inf, 13.344094276428223, inf, inf, inf, 13.907910346984863, inf, inf, inf, 13.399917602539062, inf, inf, inf, 12.697638511657715, inf, inf, inf ...
(more)
edit retag flag offensive close merge delete