10 import nav_msgs.srv
as nav_srvs
11 import mbf_msgs.msg
as mbf_msgs
12 import move_base_msgs.msg
as mb_msgs
13 from dynamic_reconfigure.client
import Client
14 from dynamic_reconfigure.server
import Server
15 from geometry_msgs.msg
import PoseStamped
16 from move_base.cfg
import MoveBaseConfig
20 move_base legacy relay node: 21 Relays old move_base actions to the new mbf move_base action, similar but with richer result and feedback. 22 We also relay the simple goal topic published by RViz, the make_plan service and dynamic reconfiguration 23 calls (note that some parameters have changed names; see http://wiki.ros.org/move_base_flex for details) 32 mbf_mb_ac.send_goal(mbf_msgs.MoveBaseGoal(target_pose=msg, planner=bgp, controller=blp))
33 rospy.logdebug(
"Relaying move_base_simple/goal pose to mbf")
37 mbf_mb_ac.send_goal(mbf_msgs.MoveBaseGoal(target_pose=msg.target_pose, planner=bgp, controller=blp),
38 feedback_cb=mbf_feedback_cb)
39 rospy.logdebug(
"Relaying legacy move_base goal to mbf")
40 mbf_mb_ac.wait_for_result()
42 status = mbf_mb_ac.get_state()
43 result = mbf_mb_ac.get_result()
45 rospy.logdebug(
"MBF execution completed with result [%d]: %s", result.outcome, result.message)
46 if result.outcome == mbf_msgs.MoveBaseResult.SUCCESS:
47 mb_as.set_succeeded(mb_msgs.MoveBaseResult(),
"Goal reached.")
49 mb_as.set_aborted(mb_msgs.MoveBaseResult(), result.message)
53 mbf_gp_ac.send_goal(mbf_msgs.GetPathGoal(start_pose=request.start, target_pose=request.goal,
54 use_start_pose=bool(request.start.header.frame_id),
55 planner=bgp, tolerance=request.tolerance))
56 rospy.logdebug(
"Relaying legacy make_plan service to mbf get_path action server")
57 mbf_gp_ac.wait_for_result()
59 status = mbf_gp_ac.get_state()
60 result = mbf_gp_ac.get_result()
62 rospy.logdebug(
"MBF get_path execution completed with result [%d]: %s", result.outcome, result.message)
63 if result.outcome == mbf_msgs.GetPathResult.SUCCESS:
64 return nav_srvs.GetPlanResponse(plan=result.path)
68 mb_as.publish_feedback(mb_msgs.MoveBaseFeedback(base_position=feedback.current_pose))
72 rospy.logdebug(
"Relaying legacy move_base reconfigure request to mbf")
74 if not hasattr(mb_reconf_cb,
"default_config"):
75 mb_reconf_cb.default_config = copy.deepcopy(config)
77 if config.get(
'restore_defaults'):
78 config = mb_reconf_cb.default_config
80 mbf_config = copy.deepcopy(config)
85 if 'base_local_planner' in mbf_config:
87 blp = mbf_config.pop(
'base_local_planner')
88 if 'controller_frequency' in mbf_config:
89 mbf_config[
'controller_frequency'] = mbf_config.pop(
'controller_frequency')
90 if 'controller_patience' in mbf_config:
91 mbf_config[
'controller_patience'] = mbf_config.pop(
'controller_patience')
92 if 'max_controller_retries' in mbf_config:
93 mbf_config[
'controller_max_retries'] = mbf_config.pop(
'max_controller_retries')
94 if 'base_global_planner' in mbf_config:
96 bgp = mbf_config.pop(
'base_global_planner')
97 if 'planner_frequency' in mbf_config:
98 mbf_config[
'planner_frequency'] = mbf_config.pop(
'planner_frequency')
99 if 'planner_patience' in mbf_config:
100 mbf_config[
'planner_patience'] = mbf_config.pop(
'planner_patience')
101 if 'max_planning_retries' in mbf_config:
102 mbf_config[
'planner_max_retries'] = mbf_config.pop(
'max_planning_retries')
103 if 'recovery_behavior_enabled' in mbf_config:
104 mbf_config[
'recovery_enabled'] = mbf_config.pop(
'recovery_behavior_enabled')
105 if 'conservative_reset_dist' in mbf_config:
106 mbf_config.pop(
'conservative_reset_dist')
107 if 'clearing_rotation_allowed' in mbf_config:
108 mbf_config.pop(
'clearing_rotation_allowed')
109 if 'make_plan_add_unreachable_goal' in mbf_config:
110 mbf_config.pop(
'make_plan_add_unreachable_goal')
111 if 'make_plan_clear_costmap' in mbf_config:
112 mbf_config.pop(
'make_plan_clear_costmap')
113 mbf_drc.update_configuration(mbf_config)
117 if __name__ ==
'__main__':
118 rospy.init_node(
"move_base")
126 mbf_mb_ac.wait_for_server(rospy.Duration(20))
127 mbf_gp_ac.wait_for_server(rospy.Duration(10))
130 mbf_drc = Client(
"move_base_flex", timeout=10)
133 mb_sg = rospy.Subscriber(
'move_base_simple/goal', PoseStamped, simple_goal_cb)
138 mb_mps = rospy.Service(
'~make_plan', nav_srvs.GetPlan, make_plan_cb)
141 mb_drs = Server(MoveBaseConfig, mb_reconf_cb)
def mbf_feedback_cb(feedback)
def mb_reconf_cb(config, level)
def make_plan_cb(request)