ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question

Hector Slam with Raspberry Pi 3, RPLIDAR A1 and Laptop

asked 2019-12-16 18:39:44 -0500

pmt2019 gravatar image

updated 2019-12-19 09:57:04 -0500

Hello to everyone :)

I want to build up a little car and on its top there should be a RPLIDAR A1 which is connected to a Raspberry Pi 3. After scanning the room I want to visualize everything with Rviz on my Laptop. So my plan is to start Rplidar on my raspberry pi and than I want to start hector slam on my laptop. Im using ROS kinetic and ubiquity on my raspberry pi. On my laptop im using ubuntu 16.04.

I have correctly networked the laptop and the raspberry pi 3. The laptop (MASTER) is for viewing and processing the Scan and also receiving the data from the Raspberry/Rplidar. I'm able to view the data on my MASTER laptop, using Rviz. I'm then running the hector_slam package on my MASTER, with the following mapping_default.launch file---

(the actual launch file)

<launch> <arg name="tf_map_scanmatch_transform_frame_name" default="scanmatcher_frame"/> <arg name="base_frame" default="base_link"/> <arg name="odom_frame" default="base_link"/> <arg name="pub_map_odom_transform" default="true"/> <arg name="scan_subscriber_queue_size" default="5"/> <arg name="scan_topic" default="scan"/> <arg name="map_size" default="2048"/>

<node pkg="hector_mapping" type="hector_mapping" name="hector_mapping" output="screen">

<!-- Frame names -->
<param name="map_frame" value="map" />
<param name="base_frame" value="$(arg base_frame)" />
<param name="odom_frame" value="$(arg odom_frame)" />

<!-- Tf use -->
<param name="use_tf_scan_transformation" value="true"/>
<param name="use_tf_pose_start_estimate" value="false"/>
<param name="pub_map_odom_transform" value="$(arg pub_map_odom_transform)"/>

<!-- Map size / start point -->
<param name="map_resolution" value="0.050"/>
<param name="map_size" value="$(arg map_size)"/>
<param name="map_start_x" value="0.5"/>
<param name="map_start_y" value="0.5" />
<param name="map_multi_res_levels" value="2" />

<!-- Map update parameters -->
<param name="update_factor_free" value="0.4"/>
<param name="update_factor_occupied" value="0.9" />    
<param name="map_update_distance_thresh" value="0.4"/>
<param name="map_update_angle_thresh" value="0.06" />
<param name="laser_z_min_value" value = "-1.0" />
<param name="laser_z_max_value" value = "1.0" />

<!-- Advertising config --> 
<param name="advertise_map_service" value="true"/>

<param name="scan_subscriber_queue_size" value="$(arg scan_subscriber_queue_size)"/>
<param name="scan_topic" value="$(arg scan_topic)"/>

<!-- Debug parameters -->
  <param name="output_timing" value="false"/>
  <param name="pub_drawings" value="true"/>
  <param name="pub_debug_output" value="true"/>
<param name="tf_map_scanmatch_transform_frame_name" value="$(arg tf_map_scanmatch_transform_frame_name)" />

   <node pkg="tf" type="static_transform_publisher" name="base_to_laser_broadcaster" args="0 0 0 0 0 0 base_link         laser 100" />


When i launch rplidar, Rviz opens and i can see the Scan on the map. Than than i type "rosrun tf static_transform_publisher 0 0 0 0 0 0 map scanmatcher_frame 10". I did this because I was getting the warning "No transform between frames /map and scanmatcher_frame available after 20.002338 seconds of waiting. This warning only prints once.". Then i launch hector slam and another Rviz opens with an empty map and the terminal shows the following message:

[ INFO] [1576537404.723676302]: lookupTransform base_frame to laser timed out. Could not ...
edit retag flag offensive close merge delete


can you share your tf tree for both of these scenarios. You can simply look at with using this command:

rosrun tf view_frames
ermanas gravatar image ermanas  ( 2019-12-16 23:40:49 -0500 )edit

Maybe on the laptop your launch file includes the TF publisher and on the RPi is doesn't? Or that the RPi doesn't have the publisher node installed but your launch file tries to open it on RPi?

billy gravatar image billy  ( 2019-12-17 02:03:16 -0500 )edit

Thank you for your quick responses guys,


Ok now I transfered my tf tree into google-drive so i’m able to share the link with you:

pmt2019 gravatar image pmt2019  ( 2019-12-17 03:48:39 -0500 )edit


Do i have to use the same TF publisher command in both launch.files (on my Laptop and my raspberry pi)? If yes, which TF publisher ("static_transform_publisher"?) commands do i have to copy?

Here are the active nodes when i run my system:

Raspberry Pi: ubuntu@ubiquityrobot:~$ rosnode list

/controller_spawner /joint_state_publisher /joy_node /motor_node /robot_state_publisher /rosbridge_ws/rosapi /rosbridge_ws/rosbridge_websocket /rosbridge_wss/rosapi /rosbridge_wss/rosbridge_websocket /rosout /teleop_twist_joy /tf2_web_republisher

Laptop:~$ rosnode list

/base_to_laser_broadcaster /hector_geotiff_node /hector_mapping /hector_trajectory_server /listener_23508_1576622227974 /map_nav_broadcaster /map_scanmatcher_broadcaster /nav_basefootprint_broadcaster /nav_baseframe_broadcaster /nav_baselink_broadcaster /rosout /rplidarNode /rviz /static_transform_publisher_1576622692801770813 /static_transform_publisher_1576622735323857703 /talker_1727_145520

pmt2019 gravatar image pmt2019  ( 2019-12-17 17:00:22 -0500 )edit

Hello again, As you can see there is no transform from the laser to the base_frame. Is this tree the same when you can see the map from the laptop? If you check the hector_slamros wiki. You'll see the links on the robot. I also applied hector slam with just a 2D laser as well. I only used base_link to accomplish. My tf is like this:

ermanas gravatar image ermanas  ( 2019-12-18 00:24:44 -0500 )edit

Hi. Today i rebuilt my system completely. I also tried just to use base_link like you did. So when i connect the Rplidar directly with my laptop i also get the same tf like you:

But when i connect the Rplidar with the Raspberry Pi and start everything from my laptop (remote control) i will get this tf with no connection between base_link and map. And also there appears base_footprint:

I just changed the launch file like in this explanation link: (at the end of the site)

My Order: - start roscore on my laptop - tell raspi that laptop is the master (export ROS_MASTER_URI=) - define my raspi as a talker and laptop as listener (rosrun rospy_tutorials - start Rplidar - start hector slam

Did i miss something or are there differences to ...(more)

pmt2019 gravatar image pmt2019  ( 2019-12-18 10:20:21 -0500 )edit

First, because of the reputation problem, you can tell your problem better in the ROS discord channel. ROS Discord Channel Invitation Link

I couldn't find the problem but in the code on your question(if you didn't change completely), you wrote arguments first and I guess you tried to assign the parameter with these arguments when you're defining base_frame and odom_frame. But in your case, you assign the argument with this:

 <arg name="base_frame" default="base_link"/>

Then you didn't use it and you've just assigned as a base_frame

But it doesn't assign the argument to the parameter. If you want to do this parametric, you can do like this:

 <param name="base_frame" value="$(arg base_frame)" />
ermanas gravatar image ermanas  ( 2019-12-19 07:29:02 -0500 )edit

In catkin_ws/src/rplidar_hector_slam/hector_slam/hector_mapping/launch/mapping_default.launch:

  1. replace the second last line with <node pkg="tf" type="static_transform_publisher" name="base_to_laser_broadcaster" args="0 0 0 0 0 0 base_link laser 100"/>

  2. the third line with <arg name="base_frame" default="base_link"/>

  3. the fourth line with <arg name="odom_frame" default="base_link"/>

I just changed the original data in the above three points. I refreshed my launch file in my first question! But if i understand it right you also used a Lidar with a Pi and a laptop and everything worked? Did you have another launch file than me?

Thank you for the invitation!

Could it possible be that i have the same problem like: ? I have the problem that i cannot install this bag file because i get: ERROR 404: Not found.

I don't get it...

pmt2019 gravatar image pmt2019  ( 2019-12-19 09:44:18 -0500 )edit

1 Answer

Sort by » oldest newest most voted

answered 2019-12-19 19:28:48 -0500

pmt2019 gravatar image

Finally i have the solution. It was a time issue and i had to synchronize the Pi and my laptop. I did it with point 5 of the following link:

Anyway a big thank you to you guys for your help!

edit flag offensive delete link more


Good to hear that you found the solution. Good luck on your project. I will also check the Network setup for my project.

PS: I was using industrial safety scanner and a single-board PC but not RP and rplidar. But the concept is the same,

ermanas gravatar image ermanas  ( 2019-12-20 03:31:40 -0500 )edit

Question Tools

1 follower


Asked: 2019-12-16 18:00:59 -0500

Seen: 1,791 times

Last updated: Dec 19 '19