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

How to use Ydlidar X4 with hector_mapping

asked 2022-07-18 07:19:55 -0500

avion09 gravatar image

updated 2022-07-18 15:11:23 -0500

Hello,

I'm new to ROS, I got a ydlidar X4 to do mapping. I manage to obtain information on lidar and display them on RVIZ, however I have an error and I cannot display the map.

I get this error:

[ WARN] [1658145959.852818339]: No transform between frames /map and /base_link available after 20.002508 seconds of waiting. This warning only prints once.

and here is my code :

<launch>

 <node name="ydlidar_node" pkg="ydlidar" type="ydlidar_node" output="screen" respawn="false" >
  <param name="port" type="string" value="/dev/ydlidar"/>
  <param name="baudrate" type="int" value="128000"/>
  <param name="frame_id" type="string" value="laser_frame"/>
  <param name="low_exposure" type="bool" value="false"/>
  <param name="resolution_fixed" type="bool" value="true"/>
  <param name="auto_reconnect" type="bool" value="true"/>
  <param name="reversion" type="bool" value="false"/>
  <param name="angle_min" type="double" value="-180" />
  <param name="angle_max" type="double" value="180" />
  <param name="range_min" type="double" value="0.1" />
  <param name="range_max" type="double" value="16.0" />
  <param name="ignore_array" type="string" value="" />
  <param name="samp_rate" type="int" value="9"/>
  <param name="frequency" type="double" value="7"/>
 </node>
 <node pkg ="tf" type="static_transform_publisher" name="map_to_odom" args="0.0 0.0 0.0 0.0 0.0 0.0 /map /nav 40"/>
 <node pkg ="tf" type="static_transform_publisher" name="odom_to_base_link" args="0.0 0.0 0.0 0.0 0.0 0.0 /nav /base_footprint 40"/>
 <node pkg="tf" type="static_transform_publisher" name="base_link_to_laser" args="0.2245 0.0 0.2 0.0 0.0 0.0 /base_footprint /laser_frame 40" />
 <include file="$(find hector_mapping)/launch/mapping_default.launch" />
 <node pkg="rviz" name="rviz" type="rviz" args="-d $(find ydlidar)/launch/lidar.rviz" />
 <include file="$(find hector_geotiff)/launch/geotiff_mapper.launch" />

Can anyone help me? Thank you,

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
0

answered 2022-07-20 11:53:03 -0500

adityatandon gravatar image

At first I thought the problem may have been the parameters in the mapping_default.launch file, but I think the issue here has to do with the static tf you are publishing between the map and odom frame. Think about it this way - if the odometry frame never transforms with respect to the map frame, how is the map actually going to be formed?

I would suggest you delete the following line from this launch file and try running it without this line.

<node pkg ="tf" type="static_transform_publisher" name="map_to_odom" args="0.0 0.0 0.0 0.0 0.0 0.0 /map /nav 40"/>

The Hector SLAM algorithm publishes the transform between the map and the odometry frame when set to true. In your case, the parameters in your mapping_default.launch file should read as below

arg name="base_frame" default="base_footprint"
arg name="odom_frame" default="nav"
arg name="pub_map_odom_transform" default="true"

Hope the above changes work for you.

edit flag offensive delete link more

Comments

Thank you for your help. Unfortunately I still have the same error even after removing this line. My mapping_default.launch is configured like you.

I see the laser scans in RVIZ but still no map.

avion09 gravatar image avion09  ( 2022-07-20 12:10:55 -0500 )edit

Okay, good to know that the parameters are correct.

Is there a reason you don't just directly include the tutorial.launch file in the hector_slam_launch package as most tutorials do and instead include the mapping_default.launch and geotiff_mapper.launch in your launch file manually?

What happens when you include the tutorial.launch file directly? To do this - remove the lines

<include file="$(find hector_mapping)/launch/mapping_default.launch" />
<include file="$(find hector_geotiff)/launch/geotiff_mapper.launch" />

and add

<include file="$(find hector_slam_launch)/launch/tutorial.launch" />

Do the results vary?

adityatandon gravatar image adityatandon  ( 2022-07-20 12:24:52 -0500 )edit

If I do as you say, RVIZ doesn't launch and I have another error :

   roslaunch file contains multiple nodes named [/rviz].
   Please check all <node> 'name' attributes to make sure they are unique.
   Also check that $(anon id) use different ids.
   The traceback for the exception was written to the log file

Maybe the tutorials I looked at are not correct, do you have a link?

avion09 gravatar image avion09  ( 2022-07-20 12:38:42 -0500 )edit

Okay, that is probably because both of the RVIZ nodes are being launched at the same time. When using RVIZ for visualizing the RPLiDAR points, one would typically launch the view_rplidar.launch file and then launch Hector SLAM after. The RVIZ config and demo then shuts down the Rplidar RVIZ window and takes over.

A tutorial that I followed is on here from the Youtube channel of Tiziano. But then again, this is for the RPLiDAR, but I don't see anything that is too different.

How about you try adding all Hector SLAM related lines in your launch file to the mapping_default.launch file in the hector_mapping package and launch Hector SLAM using the tutorial.launch file after you have already launched your own LiDAR visualization? That should work similarly to what I've tried (and it works).

adityatandon gravatar image adityatandon  ( 2022-07-21 07:24:04 -0500 )edit

Question Tools

Stats

Asked: 2022-07-18 07:16:38 -0500

Seen: 422 times

Last updated: Jul 20 '22