33 from actionlib_msgs.msg
import GoalStatus
43 SimpleGoalState.to_string = classmethod(get_name_of_constant)
83 def send_goal(self, goal, done_cb=None, active_cb=None, feedback_cb=None):
109 def send_goal_and_wait(self, goal, execute_timeout=rospy.Duration(), preempt_timeout=rospy.Duration()):
113 rospy.logdebug(
"Canceling goal")
116 rospy.logdebug(
"Preempt finished within specified preempt_timeout [%.2f]", preempt_timeout.to_sec())
118 rospy.logdebug(
"Preempt didn't finish specified preempt_timeout [%.2f]", preempt_timeout.to_sec())
126 rospy.logerr(
"Called wait_for_result when no goal exists")
129 timeout_time = rospy.get_rostime() + timeout
130 loop_period = rospy.Duration(0.1)
132 while not rospy.is_shutdown():
133 time_left = timeout_time - rospy.get_rostime()
134 if timeout > rospy.Duration(0.0)
and time_left <= rospy.Duration(0.0):
140 if time_left > loop_period
or timeout == rospy.Duration():
141 time_left = loop_period
150 rospy.logerr(
"Called get_result when no goal is running")
164 return GoalStatus.LOST
165 status = self.
gh.get_goal_status()
167 if status == GoalStatus.RECALLING:
168 status = GoalStatus.PENDING
169 elif status == GoalStatus.PREEMPTING:
170 status = GoalStatus.ACTIVE
182 rospy.logerr(
"Called get_goal_status_text when no goal is running")
183 return "ERROR: Called get_goal_status_text when no goal is running" 215 comm_state = gh.get_comm_state()
217 error_msg =
"Received comm state %s when in simple state %s with SimpleActionClient in NS %s" % \
218 (CommState.to_string(comm_state), SimpleGoalState.to_string(self.
simple_state), rospy.resolve_name(self.
action_client.ns))
220 if comm_state == CommState.ACTIVE:
226 rospy.logerr(error_msg)
227 elif comm_state == CommState.RECALLING:
229 rospy.logerr(error_msg)
230 elif comm_state == CommState.PREEMPTING:
236 rospy.logerr(error_msg)
237 elif comm_state == CommState.DONE:
238 if self.
simple_state in [SimpleGoalState.PENDING, SimpleGoalState.ACTIVE]:
241 self.
done_cb(gh.get_goal_status(), gh.get_result())
245 rospy.logerr(
"SimpleActionClient received DONE twice")
254 rospy.logerr(
"Got a feedback callback on a goal handle that we're not tracking. %s vs %s" %
255 (self.
gh.comm_state_machine.action_goal.goal_id.id, gh.comm_state_machine.action_goal.goal_id.id))
def _handle_transition(self, gh)
def cancel_goal(self)
Cancels the goal that we are currently pursuing.
def _set_simple_state(self, state)
def get_result(self)
Gets the Result of the current goal.
def send_goal(self, goal, done_cb=None, active_cb=None, feedback_cb=None)
Sends a goal to the ActionServer, and also registers callbacks.
def __init__(self, ns, ActionSpec)
Constructs a SimpleActionClient and opens connections to an ActionServer.
def wait_for_server(self, timeout=rospy.Duration())
Blocks until the action server connects to this client.
def cancel_goals_at_and_before_time(self, time)
Cancels all goals prior to a given timestamp.
def _handle_feedback(self, gh, feedback)
def get_goal_status_text(self)
Returns the current status text of the goal.
def get_state(self)
Get the state information for this goal.
def send_goal_and_wait(self, goal, execute_timeout=rospy.Duration(), preempt_timeout=rospy.Duration())
Sends a goal to the ActionServer, waits for the goal to complete, and preempts goal is necessary...
def cancel_all_goals(self)
Cancels all goals currently running on the action server.
def stop_tracking_goal(self)
Stops tracking the state of the current goal.
def wait_for_result(self, timeout=rospy.Duration())
Blocks until this goal transitions to done.