Configure move_base using ONLY hector_mapping
Hello everyone,
First of all, i want to apologyze if i make any syntax flaws, i dont usually write English.
I am new to ROS and i'm trying to develop a little autonomous car with the only sensor RPLidar.
I'm trying to configurate Navigation Stack pkg using only hector_mapping
since i dont have IMU or other sensors that give odometry of the car. I have read multiple posts where people try the to do the same, and they finally get it but unlucky they dont explain how.
I've read that hectormapping can publish odometry using the following arg: `pubmapodomtransformto
Truealso it can be published using the undocumented param:
pubodometryin the topic:
scanmatcherframe`
I've already configured hector_slam
to record and save a map with map_saver
. And configured hector_mapping
with the params mentioned above. Checking the topic list i see that hectormapping is publishing in the topics: poseupdate
, `slamoutpose,
tf,
scanmatcherframeand
map`
The first question, which topic contains the odometry that move_base will use to work?
I,ve read that is tf
but i've doubts.
I have also read that you dont need to use AMCL
if you are using hector_mapping
to run Navigation stack
, am i wrong?
Assuming that for now everything is fine, the errors must be in the params .yaml files i am using to configure move_base. I dont really know how to fill all the args properly. I am going to paste the code of each one and ask the doubts i have:
baselocalplanner_params.yaml
TrajectoryPlannerROS:
max_vel_x: 0.45
min_vel_x: 0.1
max_vel_theta: 1.0
min_in_place_vel_theta: 0.4
acc_lim_theta: 3.2
acc_lim_x: 2.5
acc_lim_y: 2.5
holonomic_robot: true
costmapcommonparams.yaml
obstacle_range: 2.5
raytrace_range: 3.0
footprint: [[-0.31, -0.69], [-0.31, 0.25], [0.31, 0.25], [0.31, -0.69]]
#robot_radius: ir_of_robot
inflation_radius: 0.55
observation_sources: laser_scan_sensor
laser_scan_sensor: {sensor_frame: laser_frame, data_type: LaserScan, topic: scan, marking: true, clearing: true}
The footprint
arg i dont really know what means, may someone explain it please? I have just copied some values i have seen in other post.
globalcostmapparams.yaml
global_costmap:
global_frame: map
robot_base_frame: base_link
update_frequency: 5.0
static_map: true
localcostmapparams.yaml
local_costmap:
global_frame: odom
robot_base_frame: base_link
update_frequency: 5.0
publish_frequency: 2.0
static_map: false
rolling_window: true
width: 6.0
height: 6.0
resolution: 0.05
When i run the launch file of the move_base:
<launch>
<node pkg="move_base" type="move_base" respawn="false" name="move_base" output="screen">
<rosparam file="$(find miniduvis)/cfg/costmap_common_params.yaml" command="load" ns="global_costmap" />
<rosparam file="$(find miniduvis)/cfg/costmap_common_params.yaml" command="load" ns="local_costmap" />
<rosparam file="$(find miniduvis)/cfg/local_costmap_params.yaml" command="load" />
<rosparam file="$(find miniduvis)/cfg/global_costmap_params.yaml" command="load" />
<rosparam file="$(find miniduvis)/cfg/base_local_planner_params.yaml" command="load" />
</node>
</launch>
I get the following errors/ warnings and nothing is being published in cmd_vel
topic:
[ WARN] [1579353283.210167580]: Timed out waiting for transform from base_link to odom to become available before running costmap, tf error: canTransform: target_frame odom does not exist.. canTransform returned after 0.100419 timeout was 0.1.
[ WARN] [1579353284.017275501]: Costmap2DROS transform timeout. Current time: 1579353284.0171, global_pose stamp: 1579353283.7111, tolerance: 0.3000
[ WARN] [1579353284.017705039]: Could not get robot pose, cancelling reconfiguration
More info: Nothing changes if i place an initial pose with Rviz or a goal point. I am running all the codes in the same machine.
I have noticed that the map which hectormapping is published is not the map i have recorded with mapsaver, how can i use that map?
Does anyone can tell me what am i missing or what are my errors that make things not working?
The final goal i believe is to obtain the cmd_vel command and transform it to servo and esc commands with an own controller, right?
Thank you everyone in advance, i really believe this post will help everyone with similar doubts.
J.
Edit 1: Adding roslaunch file of hector_mapping
<?xml version="1.0"?>
<launch>
<arg name="tf_map_scanmatch_transform_frame_name" default="scanmatcher_frame"/>
<!-- <arg name="base_frame" default="base_footprint"/>
<arg name="odom_frame" default="nav"/> -->
<arg name="base_frame" default="base_link"/>
<arg name="odom_frame" default="base_link"/>
<!-- <arg name="base_frame" default="base_frame"/>
<arg name="odom_frame" default="base_frame"/> -->
<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)"/>
<!-- param name="pub_odometry" value="false"/> -->
<!-- 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>
<!--<node pkg="tf" type="static_transform_publisher" name="map_nav_broadcaster" args="0 0 0 0 0 0 map nav 100"/>-->
<node pkg="tf" type="static_transform_publisher" name="base_to_laser_broadcaster" args="0 0 0 0 0 0 base_link laser 100" />
</launch>
Asked by jjggmm on 2020-01-18 08:23:42 UTC
Answers
Hi, it would help immensely to if you post the launch file for hector_mapping as well.
Anyway, the short answer to resolve the WARN
message is to set map
as the global_frame
in local_costmap.yaml
. This is because hector_mapping doesn't always publish the map -> odom
transform unless you configured it that way. In your case I'm guessing it only publishes map -> base_link
since your robot doesn't have any odometry source. (Setting pub_map_odom_tranform
would only configure hector_mapping to publish a transform to the tf tree. I'm assuming you used the option 2 in setting up Hector slam )
The first question, which topic contains the odometry that move_base will use to work? I,ve read that is tf but i've doubts.
move_base always reads the odometry from /tf. But for that to work, another source must broadcast the odometry related transforms to the TF tree. In your setting there's no odometry source and hector_mapping doesn't publish the required transform.
I have also read that you dont need to use AMCL if you are using hector_mapping to run Navigation stack, am i wrong?
You are right. To clarify, Navigation stack requires a localization source and a correct TF tree that has map -> odom -> base_link
chain correctly setup. ( Or map -> base_link
with global_frame
set to map for both costmaps ). hector_mapping is doing SLAM and AMCL is doing localization. So either one of them could be used. The difference is for AMCL you have to provide a map through the map_server to localize against and to use for global_costmap. hector_mapping generates the map that you can use in global_costmap in addition to doing the localization.
I have noticed that the map which hector_mapping is published is not the map i have recorded with map_saver, how can i use that map?
You can't use the pre recorded map when you're using hector_mapping. hector_mapping always generates a new map everytime it is launched. It can't use existing maps. As I said earlier, you can use AMCL instead of hector_slam using the recorded map.
The footprint arg i dont really know what means, may someone explain it please? I have just copied some values i have seen in other post.
It is used to specify what it means, the footprint of the robot. Robots can be of any shape, so during configuration of move_base you have to specify what shape the robot's 2D projection is going to look like. You specify the footprint as a series of points in a polygon (with the 0,0 point being the center of the robot, using the ROS coordinate frame standard https://www.ros.org/reps/rep-0103.html#axis-orientation ) either in clockwise or counter-clockwise direction.
Hope this helps.
Asked by Namal Senarathne on 2020-01-21 20:05:48 UTC
Comments
Interesting - I learned a lot about Nav Stack by looking at your response. Have you successfully used hector mapping as part of Nav stack to navigate in known/unknown environment?
Asked by billy on 2020-01-21 21:50:05 UTC
Hello Namal,
First of all thank you for your comment, i have also learnt more about Nav Stack by looking your response.
I've added the content of the launch file of hector_mapping
in the main post. As you can see i think i have bad configured the odom_frame
and the base_frame
arg since i've set them to base_link
and in the hector Slam wiki, the Option 2 set them to base_frame
Anyway if i set them to base_frame
i get the following error and the mapping is not working:
[ INFO] [1579869692.598166452]: lookupTransform base_frame to laser timed out. Could not transform laser scan into base_frame.
So i dont know if they have a misprint on their wiki.
Assuming that the params in hector_mapping
launch file are set to base_link
and changing the param base_frame
in the local_costmap.yaml
to map
and changing the footprint
param acording to the size of my robot
(continuing in next comment since i've reach the total amount of characters)
Asked by jjggmm on 2020-01-24 07:54:47 UTC
when i run the move_base
launch file i get the following error:
[ WARN] [1579870361.339426768]: Unable to get starting pose of robot, unable to create global plan
I have set the 2D Nav Goal with Rviz and the 2D Pose Estimate.
What am i missing?
Thank you again.
Asked by jjggmm on 2020-01-24 07:58:47 UTC
Hello again,
Just noticed viewing the Pose
in Rviz that the heading given by hector_mapping
was in the opposite direction of the real robot heading... I had to rotate 180ยบ and now its working.
I have a new question, does the move_base
consider the dynamic obstacles in the way?
Greetings
Asked by jjggmm on 2020-01-24 10:13:16 UTC
Hi, I couldn't find the hector_mapping launch file in your main post. Anyway, it seems you got it working.
Regarding dynamic obstacles, the basic obstacle layer provided by the ObstacleCostmapPlugin (http://wiki.ros.org/costmap_2d/hydro/obstacles) can be used to update the changes in the environment. So dynamic objects can be encoded using this layer. However they are treated as static objects for that update cycle. If your costmap update rate is fast enough (say 5Hz) and robot speed is slow (say 0.5m/s) you can use this setting for many situations.
For true dynamic object encoding in costmaps, you'd have to integrate the object tracking information to the costmap as well. Social Nav Layer is one such example layer that tries to encode dynamic object more richly in a costmap.
Asked by Namal Senarathne on 2020-01-25 08:54:00 UTC
Hello, i'm sorry i think i didn't save the edit of the original post. Hector_mapping
launch file should be now on the original post.
I will take a look of the ObstacleCostmapPlugin. Thank you Namal,
If i could ask you another question, sometimes when i publish the 2D Nav Goal the robot start moving but does the following orders "move-stop-move-stop" very fast. And i get the following warning in the move_base:
[ WARN] [1579870361.339426768]: Unable to get starting pose of robot, unable to create global plan
It seems like it's publishing to stop the robot since it cant get the pose of robot, but it finally reach the goal, i dont really understand it.
Asked by jjggmm on 2020-01-25 09:12:28 UTC
Yes, when the planner fails to get the pose of the robot, move_base stops the robot and spits out that warning. My guess is that this move-stop-move behavior is related to the transform_tolerance
parameter of costmaps. Try setting it to say 0.5 rather than your current value of 0.3.
Both global planners and local planners use this parameter to check if their output plans are relevant with respect to the current time. If the costmap takes too long to update then the plans generated based on those maps are not going to be valid/safe. If setting transform_tolerance
parameter to a large value solves your problem, then ideally you should look into improving the real update rate of the costmaps used by the planners.
Asked by Namal Senarathne on 2020-01-25 09:42:47 UTC
Hello again Namal, thank you for your answer.
I have set the param transform_tolerance
to 0.5 and tried again to run move_base algorithm.
While testing i keep getting the following warnings:
[ WARN] [1580494333.274486301]: Costmap2DROS transform timeout. Current time: 1580494333.2743, global_pose stamp: 1580494332.7591, tolerance: 0.5000
[ WARN] [1580494333.308167650]: Could not get robot pose, cancelling reconfiguration
[ WARN] [1580494349.207849785]: Costmap2DROS transform timeout. Current time: 1580494349.2077, global_pose stamp: 1580494348.7042, tolerance: 0.5000
[ WARN] [1580494349.207964324]: Could not get robot pose, cancelling reconfiguration
I am doing the following sequence of actions , i dont know if i'm doing any mistake:
Robot: Launch
controller
andlidar
nodesAt PC: Launch
roscore
,hector_mapping
,move_base
andRviz
to monitor everything and send goal points.
(continuing in next comment)
Asked by jjggmm on 2020-01-31 13:27:16 UTC
I publish the 2D Pose estimate
point and then record the map of my room with some static obstacles and when the map is already recorded and the robot is placed at the "starting zone", I publish a goal point and the robot starts moving to that point.
Everything seems to work fine but the robot crash into obstacles. I believe that the robot is just following a path between initial and goal points and if there is an obstacle in between it just crash into it.
All the time the warnings mentioned in the last comment are being published, so i think that the algorithm is not recalculating the path considering obstacles,
So assuming i'm not doing anything wrong, i have 2 question:
Does the move_base
algorithm calculates in real time how the robot must move between the start and goal point? Or it just calculate the entire path considering the map and sends commands to the robot?
(continuing in next comment)
Asked by jjggmm on 2020-01-31 13:40:19 UTC
Assuming that the option 1 is the right one in the question (the algorithm calculates in real time how to move the robot), i believe that if it cant get the robot pose and cancels reconfiguration, the robot wont consider the obstacles and just move forward from one point to another and collides with obstacles.
So, what can i do to fix the warnings mentioned above?
Thank you again for all your comments, you are really helping me.
EDIT: Just noticed sometimes i dont get those warnings during the test and it seems to work properly. Now i am even more confused.. I am sorry but i'm adding a new question:
Just noticed i had the param holonomic_robot
set to true in the file base_local_planner_params.yaml but i'm using a car-like robot with steering mechanism in front wheels (nonholonomic).
And the question is, what param in the base_local_planner_params.yaml
controls the max or min rotation angle value to set it according to my controller?
Asked by jjggmm on 2020-01-31 13:44:43 UTC
Did you finally fix it? I followed all explanations and now navigation works, but I have exactly the same warnings you said: "Costmap2DROS transform timeout" and "Could not get robot pose, cancelling reconfiguration". Any help will be welcome. Thanks!
Asked by dgarcialopez on 2020-02-23 14:00:54 UTC
Hello, i was very busy this month so i had no time to still trying. If i finally solve it, dont worry, i will EDIT main post or add another comment with the solution. I would like you to do the same.
Asked by jjggmm on 2020-02-23 15:34:44 UTC
hi, if you have finally solved it and completed integrating move base with hector slam using only lidar can you tell me the steps that you went through (i finished mapping on rviz using hector slam ) any help will be appreciated
Asked by mada63 on 2021-04-15 05:15:35 UTC
Hi, is there any update for this topic? I'm still having the same problem with the transform timeout and Unable to get starting pose of robot error, really appreciate if anyone can help me with this. Thank you.
Asked by mstfa23x on 2022-12-02 05:02:25 UTC
Comments
Hi jjggmm,
I am currently making a robot car that is similar if not the same as the one you stated above. I too am using an RPLIDAR and only Hector Slam for the navigation. My .yaml files and the hector_mapping launch file is similar if not the same as yours as well.
I also read the answers/comments you had with Namal. However, I still can't get my robot to move when after using the 2D Pose Estimate and 2D Nav Goal on RVIZ. When I use echo to see the cmd_vel topic, nothing shows up.
I was wondering if you don't mind telling me what you did to get your robot to work?
Thanks!
Asked by KennyxD on 2020-11-29 18:47:58 UTC
hi, if you have finally solved it and completed integrating move base with hector slam using only lidar can you tell me the steps that you went through (i finished mapping on rviz using hector slam ) any help will be appreciated
Asked by mada63 on 2021-04-14 09:57:36 UTC