3 import roslib; roslib.load_manifest(
'flexbe_core')
6 from threading
import Timer
14 A proxy for calling actions. 21 def __init__(self, topics={}, wait_duration=10):
23 Initializes the proxy with optionally a given set of clients. 25 @type topics: dictionary string - message class 26 @param topics: A dictionay containing a collection of topic - message type pairs. 28 @type wait_duration: int 29 @param wait_duration: Defines how long to wait for each client in the 30 given set to become available (if it is not already available). 33 for topic, msg_type
in topics.iteritems():
39 Tries to set up an action client for calling it later. 42 @param topic: The topic of the action to call. 44 @type msg_type: msg type 45 @param msg_type: The type of messages of this action client. 47 @type wait_duration: int 48 @param wait_duration: Defines how long to wait for the given client if it is not available right now. 50 if topic
not in ProxyActionClient._clients:
54 available = client.wait_for_server(rospy.Duration.from_sec(wait_duration))
58 except Exception
as ve:
63 Logger.logerr(
"Action client %s timed out!" % topic)
65 ProxyActionClient._clients[topic] = client
67 Logger.loginfo(
"Finally found action client %s..." % (topic))
72 Performs an action call on the given topic. 75 @param topic: The topic to call. 77 @type goal: action goal 78 @param goal: The request to send to the action server. 80 if topic
not in ProxyActionClient._clients:
81 raise ValueError(
'ProxyActionClient: topic %s not yet registered!' % topic)
83 ProxyActionClient._result[topic] =
None 84 ProxyActionClient._feedback[topic] =
None 86 ProxyActionClient._clients[topic].
send_goal(goal,
92 ProxyActionClient._result[topic] = result
95 ProxyActionClient._feedback[topic] = feedback
100 Checks if the client on the given action topic is available. 103 @param topic: The topic of interest. 105 return topic
in ProxyActionClient._clients
109 Checks if the given action call already has a result. 112 @param topic: The topic of interest. 114 return ProxyActionClient._result[topic]
is not None 118 Returns the result message of the given action call. 121 @param topic: The topic of interest. 123 return ProxyActionClient._result[topic]
127 Removes the latest result message of the given action call. 130 @param topic: The topic of interest. 132 ProxyActionClient._result[topic] =
None 136 Checks if the given action call has any feedback. 139 @param topic: The topic of interest. 141 return ProxyActionClient._feedback[topic]
is not None 145 Returns the latest feedback message of the given action call. 148 @param topic: The topic of interest. 150 return ProxyActionClient._feedback[topic]
154 Removes the latest feedback message of the given action call. 157 @param topic: The topic of interest. 159 ProxyActionClient._feedback[topic] =
None 163 Determines the current actionlib state of the given action topic. 164 A list of possible states is defined in actionlib_msgs/GoalStatus. 167 @param topic: The topic of interest. 169 return ProxyActionClient._clients[topic].
get_state()
173 Determines if an action request is already being processed on the given topic. 176 @param topic: The topic of interest. 178 return ProxyActionClient._clients[topic].simple_state != actionlib.SimpleGoalState.DONE
182 Cancels the current action call on the given action topic. 185 @param topic: The topic of interest. 187 ProxyActionClient._clients[topic].cancel_goal()
190 Logger.logwarn(
"Waiting for action client %s..." % (topic))
def get_result(self, topic)
def _done_callback(self, topic, terminal_state, result)
def send_goal(self, topic, goal)
def __init__(self, topics={}, wait_duration=10)
def remove_result(self, topic)
def get_state(self, topic)
def is_active(self, topic)
def is_available(self, topic)
def _print_wait_warning(self, topic)
def _feedback_callback(self, topic, feedback)
def setupClient(self, topic, msg_type, wait_duration=10)
def remove_feedback(self, topic)
def has_result(self, topic)
def get_feedback(self, topic)
def has_feedback(self, topic)