When I run roslaunch, an error occurs. After running dozens of normal cycles, an error is reported:
[local_planner/dwa_planner-7] process has died [pid 4185027, exit code -8, cmd /home/oem/dwa_simulation/devel/lib/dwa_planner/dwa_planner /cmd_vel:=/cmd_vel_1 /local_map:=/local_map /move_base_simple/goal:=/goal_pose /odom:=/odom /dist_to_goal_th:=/dist_to_goal_th /scan:=/scan_2 /footprint:=/footprint /path:=/path /target_velocity:=/target_velocity __name:=dwa_planner __log:=/home/oem/.ros/log/1d0fce4a-5f65-11ef-9f18-253e39130628/local_planner-dwa_planner-7.log].
I checked the breakpoints and found that the error occurred in ros::spinOnce();
Run to loop_rate.sleep();
. I think there is a problem there? How should I fix it?
I have tried to check whether the topic is successfully mapped and the topic is initialized, and both are normal.
The original code link is https://github.com/amslabtech/dwa_planner.git.
We will probably need more information to identify where your error occurred, but I'll explain where you may want to look and why.
When a ROS node calls ros::spinOnce()
, it hands control of the current thread to ROS, so that ROS can call any callbacks waiting to be called (read more). In your case, these callbacks were set up in the DWAPlanner
constructor:
dist_to_goal_th_sub_ = nh_.subscribe("/dist_to_goal_th", 1, &DWAPlanner::dist_to_goal_th_callback, this);
edge_on_global_path_sub_ = nh_.subscribe("/path", 1, &DWAPlanner::edge_on_global_path_callback, this);
footprint_sub_ = nh_.subscribe("/footprint", 1, &DWAPlanner::footprint_callback, this);
goal_sub_ = nh_.subscribe("/move_base_simple/goal", 1, &DWAPlanner::goal_callback, this);
local_map_sub_ = nh_.subscribe("/local_map", 1, &DWAPlanner::local_map_callback, this);
odom_sub_ = nh_.subscribe("/odom", 1, &DWAPlanner::odom_callback, this);
scan_sub_ = nh_.subscribe("/scan", 1, &DWAPlanner::scan_callback, this);
target_velocity_sub_ = nh_.subscribe("/target_velocity", 1, &DWAPlanner::target_velocity_callback, this);
So, if an error occurred during ros::spinOnce()
, the error could have originated from any of those callbacks (i.e., any of the ..._callback
functions of the DWAPlanner
class).
To identify the culprit, you could add breakpoints to the beginning of each callback, or use ROS_DEBUG
to log when the callbacks are entered and exited.