# I can't do mapping with my LiDar

**URL:** <https://forum.ubiquityrobotics.com/t/i-cant-do-mapping-with-my-lidar/716>\
**Category:** Uncategorized\
**Created:** [January 28, 2021, 1:44pm UTC](https://forum.ubiquityrobotics.com/t/i-cant-do-mapping-with-my-lidar/716 "2021-01-28T13:44:14Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![lucasalbini](https://forum.ubiquityrobotics.com/user_avatar/forum.ubiquityrobotics.com/lucasalbini/32/494_2.png) [@lucasalbini](https://forum.ubiquityrobotics.com/u/lucasalbini)\
**Post date:** [January 28, 2021, 1:44pm UTC](https://forum.ubiquityrobotics.com/t/i-cant-do-mapping-with-my-lidar/716/1 "2021-01-28T13:44:14Z")

</div>

Hi guys! I’m trying to map my workplace, but I’m not getting it, the map that is made rotates together with the robot and is unable to map effectively, as in the figure below.

 ![Screenshot from 2021-01-27 15-32-46](https://frm.ubiquityrobotics.com/uploads/default/original/1X/e4df1db441dc7c4ff5a032cbec1d0d3320dab848.png)

My laser is Keyence’s SZ-16D model with 270-degree coverage with 0.36-degree resolution.

Our old lidar was an XV11 and it worked perfectly with the same settings, with the difference that it had a 360-degree field of view.

We have already tried with Gmapping and Hector Slam and both are problematic, the configuration files are shown below.

**Keyence launch file**

```
<launch>
    <node pkg="tf" type="static_transform_publisher" name="laser_broadcaster" 
          args="0 0 0 0 0 0 base_link keyence_laser 100">
    </node>
    <!--node pkg="tf" type="static_transform_publisher" name="odom_map_broadcaster" args="0 0 0 0 0 0 /map /odom 100" /-->
    <node pkg="nav_hub" type="LaserScan_SZ-16D.py" name="laserscan_sz16D_node" output="screen" />
</launch>

```

**Gmapping launch file**

```
<launch>
  <arg name="scan_topic" default="scan" />
  <arg name="base_frame" default="base_link"/>
  <arg name="odom_frame" default="odom"/>

  <node pkg="gmapping" type="slam_gmapping" name="slam_gmapping" output="screen">
    <param name="base_frame" value="$(arg base_frame)"/>
    <param name="odom_frame" value="$(arg odom_frame)"/>
    <param name="map_update_interval" value="5.0"/>
    <param name="maxUrange" value="14.0"/>
    <param name="maxRange" value="16.0"/>
    <param name="sigma" value="0.05"/>
    <param name="kernelSize" value="1"/>
    <param name="lstep" value="0.05"/>
    <param name="astep" value="0.05"/>
    <param name="iterations" value="5"/>
    <param name="lsigma" value="0.075"/>
    <param name="ogain" value="3.0"/>
    <param name="lskip" value="0"/>
    <param name="minimumScore" value="0"/>
    <param name="srr" value="0.01"/>
    <param name="srt" value="0.02"/>
    <param name="str" value="0.01"/>
    <param name="stt" value="0.02"/>
    <param name="linearUpdate" value="0.5"/>
    <param name="angularUpdate" value="0.436"/>
    <param name="temporalUpdate" value="-1.0"/>
    <param name="resampleThreshold" value="0.5"/>
    <param name="particles" value="80"/>
    <param name="xmin" value="-10.0"/>
    <param name="ymin" value="-10.0"/>
    <param name="xmax" value="10.0"/>
    <param name="ymax" value="10.0"/>

    <param name="delta" value="0.036"/>
    <param name="llsamplerange" value="0.01"/>
    <param name="llsamplestep" value="0.01"/>
    <param name="lasamplerange" value="0.005"/>
    <param name="lasamplestep" value="0.005"/>
    <remap from="scan" to="$(arg scan_topic)"/>
  </node>
</launch>

```

Thanks in advance 🙂

---

<div class="post-metadata">

**Author:** ![MoffKalast](https://forum.ubiquityrobotics.com/user_avatar/forum.ubiquityrobotics.com/moffkalast/32/214_2.png) [@MoffKalast](https://forum.ubiquityrobotics.com/u/MoffKalast)\
**Post date:** [January 28, 2021, 8:09pm UTC](https://forum.ubiquityrobotics.com/t/i-cant-do-mapping-with-my-lidar/716/2 "2021-01-28T20:09:43Z")

</div>

This is probably the slightly infuriating type of answer, so I apologize in advance, but I’d say the problem lies in your usage of gmapping and hector slam. I haven’t tried hector myself, but gmapping is pretty old and there are more efficient and more accurate approaches to slam these days.

Our team has been using [Iris LaMa](https://github.com/iris-ua/iris_lama_ros) slam for our internal projects for a few months now and I think I can say that it’s quite good, especially on the magni. The best part of it that it has no parameters to tweak and works instantly with a single rosrun line.

My suggestion would be to switch to that or something equally newer like it.

---

<div class="post-metadata">

**Author:** ![lucasalbini](https://forum.ubiquityrobotics.com/user_avatar/forum.ubiquityrobotics.com/lucasalbini/32/494_2.png) [@lucasalbini](https://forum.ubiquityrobotics.com/u/lucasalbini)\
**Post date:** [January 29, 2021, 5:16pm UTC](https://forum.ubiquityrobotics.com/t/i-cant-do-mapping-with-my-lidar/716/3 "2021-01-29T17:16:41Z")

</div>

Thanks for the reply @MoffKalast!

We’ve been using Gmapping for a long time and we have good results too, but the problem is with our new Lidar. We were using this first lidar, which works in 360 degrees and we had good results, but it didn’t have such a good resolution and ended up getting lost in the location.

 ![e11f86c4-7819-4c04-8a23-3bfc6766e564](https://frm.ubiquityrobotics.com/uploads/default/original/1X/11b16c82cad1b9295382fe23879d1f345371c4a4.jpeg)

So we decided to switch to a better quality lidar and chose this one from Keyence, which is much better, but we were unable to make it map in the same way as with the other.

 ![keyence](https://frm.ubiquityrobotics.com/uploads/default/original/1X/174a6a4c651af982d56b3450af0cab215e630f61.jpeg)

We don’t know where is the problem, so if anyone has similar errors, please talk to us, please.

Thanks 🙂

---

<div class="post-metadata">

**Author:** ![mjstn2011](https://forum.ubiquityrobotics.com/user_avatar/forum.ubiquityrobotics.com/mjstn2011/32/30_2.png) [@mjstn2011](https://forum.ubiquityrobotics.com/u/mjstn2011)\
**Post date:** [January 30, 2021, 8:27am UTC](https://forum.ubiquityrobotics.com/t/i-cant-do-mapping-with-my-lidar/716/4 "2021-01-30T08:27:44Z")

</div>

Ok. So clearly you are already used to lidar and gmapping. That is good because that part of it is very involved.

The Sick Tim551 which is highly respected is also a 270 deg scan. It has 1 deg angular resolution much like the Neato lidar. There are a bunch of launch files and stuff for the Tim551 on this site:

> **[GitHub - SICKAG/sick\_scan: sick\_scan is an open-source project to support the...](https://github.com/SICKAG/sick_scan/)**
>
> sick\_scan is an open-source project to support the laser scanner of the company SICK using the ROS-framework

There may be some very good clues there. I am just guessing but it seems similar and the laserscan topic may be about the same as yours perhaps.

Also this link: [sick\_tim - ROS Wiki](http://wiki.ros.org/sick_tim)  
In the launches and on this wiki I see min\_ang and max\_ang values of 2.35 type ranges which is radians and so is about what you may want. These you may already know about but just offering some thoughts.

Good luck. Perhaps somebody will respond with more concrete info.

---

<div class="post-metadata">

**Author:** ![rohbotics](https://forum.ubiquityrobotics.com/user_avatar/forum.ubiquityrobotics.com/rohbotics/32/222_2.png) [@rohbotics](https://forum.ubiquityrobotics.com/u/rohbotics)\
**Post date:** [January 30, 2021, 6:48pm UTC](https://forum.ubiquityrobotics.com/t/i-cant-do-mapping-with-my-lidar/716/5 "2021-01-30T18:48:30Z")

</div>

Hi @lucasalbini,

My best guess is that your lidar might have time synchronization issues, namely that it is putting the wrong timestamps on the laserscan data. This means that when you turn, the laser scan (after transformed with the timestamps) turns with the robot instead of staying static with the walls.

To see this in RViz set your fixed frame to `/odom` and visualize the robots `base_link` and the laser scan topic. Then click the “Experimental” checkbox in the bottom of RViz and turn Synchronization to Exact. This should make RViz visualize everything with the correct timestamps and transformations (instead of approximating by just using data as it comes as it usually does for effeminacy). Now when you turn the robot, you will see that the scan doesn’t stay fixed in space, but instead it has a “jello like” lagging and turning with the robot.

You might be able to tune or modify the ROS node that you are using with your lidar to get better time sync. I know the hokuyo lidars had a timing calibration that was needed to solve this issue, maybe the Keyence has similar?

Rohan

---

<div class="post-metadata">

**Author:** ![lucasalbini](https://forum.ubiquityrobotics.com/user_avatar/forum.ubiquityrobotics.com/lucasalbini/32/494_2.png) [@lucasalbini](https://forum.ubiquityrobotics.com/u/lucasalbini)\
**Post date:** [February 1, 2021, 1:42pm UTC](https://forum.ubiquityrobotics.com/t/i-cant-do-mapping-with-my-lidar/716/6 "2021-02-01T13:42:48Z")

</div>

Thank you for the response!

We’ve tried this synchronization with the RViz and changed some base\_link parameters (mostly the yaw ones), and the mapping seems to be going a bit better. Still, we’ve run into another problem - it can, now, actually map our place, but only if the robot is going overbearingly slow. If it’s just a little fast, the map loses itself and starts writing something completely absurd.

Do you know a way that we can map with faster velocities? A parameter or configuration, or something in the Magni?

Thanks a lot in advance, and for the support!

---

<div class="post-metadata">

**Author:** ![MoffKalast](https://forum.ubiquityrobotics.com/user_avatar/forum.ubiquityrobotics.com/moffkalast/32/214_2.png) [@MoffKalast](https://forum.ubiquityrobotics.com/u/MoffKalast)\
**Post date:** [February 4, 2021, 2:19pm UTC](https://forum.ubiquityrobotics.com/t/i-cant-do-mapping-with-my-lidar/716/7 "2021-02-04T14:19:16Z")

</div>

Well the odometry should still be fairly accurate even at high speeds, so it’s likely something you need to adjust with gmapping. Looking at some other sources it would seem that gmapping performance is very dependant on CPU speed, which isn’t really that high on ARM.
