Rosanswers logo

I am trying to do slam gmapping using a quadrotor uses px4 as an autopilot in gazebo simulator. I am trying to follow the tutorial shown in the following link:


I didn’t use a fake laser since my quad is equipped with a laser scan that publishes a topic called \quad\scan

I have the following launch file:

<?xml version="1.0"?>
<arg name="paused" default="false"/>
<arg name="debug" default="false"/>
<arg name="gui" default="true" />
<arg name="headless" default="false"/>
<arg name="enable_logging" default="false"/>
<arg name="enable_ground_truth" default="true"/>
<arg name="ns" default="quad"/>
<arg name="log_file" default="$(arg ns)"/>
<arg name="gazebo_arg" default=""/>
<arg name="world" default="sar_world1.world"/>

<include file="$(find my_pack)/launch/world.launch" >
<arg name="paused" default="$(arg paused)"/>
<arg name="debug" default="$(arg debug)"/>
<arg name="gui" value="$(arg gui)" />
<arg name="headless" default="$(arg headless)"/>

  <group ns="quad">
  <include file="$(find rotors_gazebo)/launch/spawn_ardrone.launch">
  <arg name="model" value="$(find rotors_description)/urdf/drone_sensors.gazebo" />
  <arg name="enable_logging" value="$(arg enable_logging)" />
  <arg name="enable_ground_truth" value="$(arg enable_ground_truth)" />
  <arg name="log_file" value="$(arg log_file)"/>
  <arg name="x" value="-3.0"/>
  <arg name="y" value="-2.0"/>
  <arg name="Y" value="3.14"/> 
  <arg name="name" value="quad"/>
  <arg name="fcu_url" default="udp://localhost:14560@localhost:14565" />
   <include file="$(find mavros)/launch/px4.launch">
  <arg name="fcu_url" value="$(arg fcu_url)" />

<include file="$(find rotors_gazebo)/launch/ardrone.launch">
<arg name="ns" value="quad"/>

  <!-- Fake laser -->

 <!-- <node pkg="nodelet" type="nodelet" name="laserscan_nodelet_manager" args="manager"/>
       <node pkg="nodelet" type="nodelet" name="depthimage_to_laserscan"
        args="load depthimage_to_laserscan/DepthImageToLaserScanNodelet laserscan_nodelet_manager">
       <param name="scan_height" value="10"/> 
       <param name="scan_time" value="0.033"/>
       <param name="range_min" value="0.45"/>
       <param name="range_max" value="10.0"/>
       <param name="min_height" value=".10"/>
        <param name="max_height" value="2.0"/>
        <param name="output_frame_id" value="quad/depth_optical_frame"/>
        <remap from="image" to="depth/image_raw"/>
        <remap from="/scan" to="/sim_scan"/> 
       <node name="slam_gmapping" pkg="gmapping" type="slam_gmapping">
       <remap from="scan" to="uav_1/scan"/>
       <param name="map_frame" value="map" />
       <param name="odom_frame" value="world" />
       <param name="base_frame_id" value="/quad/odometry_frame" />
       <node pkg="tf" type="static_transform_publisher" name="link3_broadcaster" args="0 0 0 0 0 0 map world 500" />
       <node pkg="rviz" type="rviz" name="rviz" args="-d $(find my_pack)/config/sim_rviz.rviz" />


when I am trying to see the map in RVIZ, I added the map with topic map and it says that there is "no map received" ? I don't know where is the error ?

Originally posted by RSA_kustar on ROS Answers with karma: 275 on 2016-08-14

Post score: 2

Original comments

Comment by WeiShih on 2016-08-14:
Does the slam_gmapping node need to subsrcibe /tf and /scan? (same as gmapping?) If yes, I wonder whether the will cause the problem due to the "/scan" topic doesn't exist, no to mention any data in it. Maybe you can check this.

Comment by RSA_kustar on 2016-08-15:
@WeiShih When I did Slam Gmaping using the command line it worked but using it here in the launch file it did not work. So what exactly are the tags that I should use in order for this code to work ?

Comment by DavidN on 2016-08-15:
I saw that you are using namespace "quad" in your launch file. Pay extra attention to the topic/service name. Maybe you can try to run rosnode info /slam_gmapping to make sure it subscribes to correct scan topic.

Comment by WeiShih on 2016-08-18:
Sorry I'm not going to run this launch file. But just like @DavidN said, you have to check whether the topic names are correct. Make sure the slam_gmapping gets all the data it wants. You can also use $rostopic echo <topic_name> to show if there is any data in the topic.

Comment by RSA_kustar on 2016-09-06:
@David and @WeiShih I fixed the name space but the error was not from the namespace, I removed the Gmapping and I run it from the command line and it worked. the error was from the parameters names I will post the solution now


1 Answer 1


Rosanswers logo

The problem is solved when using the following gmapping tags

  <node name="slam_gmapping" pkg="gmapping" type="slam_gmapping">   
     <param name="output_frame_id" value="/base_link"/>
     <remap from="/scan" to="/uav_1/scan"/> 
     <param name="map_frame" value="map" />
     <param name="_odom_frame" value="world" />
     <param name="_base_frame" value="/base_link" />
     <param name="_inverted_laser" value="false" />

Originally posted by RSA_kustar with karma: 275 on 2016-09-06

This answer was ACCEPTED on the original site

Post score: 0


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.