example_move_base.py
Go to the documentation of this file.
1 #! /usr/bin/env python
2 
3 """
4 This action server node will wait for 3 MoveBaseGoals and handle each differently:
5 - succeed the first one
6 - abort the 2nd goal
7 - just ignore the 3rd one
8 """
9 
10 import rospy
11 
12 from scenario_test_tools.scriptable_move_base import ScriptableMoveBase
13 
14 from move_base_msgs.msg import MoveBaseAction, MoveBaseResult
15 
16 
17 if __name__ == "__main__":
18  rospy.init_node('move_base_fake')
19 
20  succeeded = MoveBaseResult()
21 
22  # By default, wait 5 secs for the robot to arrive
23  result_delay = rospy.get_param("~result_delay", 5)
24  # By default, wait forever for a move_base goal
25  timeout = rospy.get_param("~timeout", None)
26  # By default, publish transformation /map to /base_link
27  pub_transform = rospy.get_param("~pub_transform", True)
28 
29  move_base = ScriptableMoveBase(rospy.get_name(), MoveBaseAction, default_result_delay=result_delay, pub_transform=pub_transform)
30  move_base.start()
31  rospy.loginfo("fake move base running")
32 
33 
34  try:
35  move_base.reply(succeeded, marker='1: succeeded', timeout=timeout)
36 
37  # The action server will abort the goal,
38  # to check that the client will perhaps retry the navigation or otherwise handle an abort
39  move_base.reply(move_base.ABORT_GOAL, marker='2: Aborted', reply_delay=0, timeout=timeout)
40 
41  # The action server will ignore the goal and never send a result.
42  # The client will have to decide it's taking too long and cancel
43  move_base.reply(move_base.IGNORE_GOAL, marker='3: Ignored', reply_delay=0, timeout=timeout)
44  except AssertionError as assertion_err:
45  rospy.logerr(assertion_err)
46  raise assertion_err
47  rospy.spin()


scenario_test_tools
Author(s): Loy van Beek
autogenerated on Wed Apr 7 2021 03:03:18