38 usage: %prog /action_name action_type 45 from optparse
import OptionParser
51 from cStringIO
import StringIO
52 from library
import to_yaml, yaml_msg_str
53 from dynamic_action
import DynamicAction
54 from actionlib_msgs.msg
import GoalStatus
71 self.
status.SetLabel(label)
89 if self.
client.wait_for_server(rospy.Duration.from_sec(TIMEOUT)):
91 wx.Colour(192, 252, 253),
True)
94 wx.Colour(200, 0, 0),
False)
99 self.
set_status(
"Canceling goal", wx.Colour(211, 34, 243))
104 self.
goal.GetValue())
112 self.
set_status(
"Goal is pending", wx.Colour(255, 174, 59))
115 except roslib.message.SerializationError
as e:
117 wx.MessageBox(str(e),
"Error serializing goal", wx.OK)
122 except UnicodeDecodeError:
123 self.
result.SetValue(
"Cannot display result due to unprintable characters")
126 return {GoalStatus.PENDING: [
'PENDING', wx.Colour(255, 174, 59)],
127 GoalStatus.ACTIVE: [
'ACTIVE', wx.Colour(0, 255, 0)],
128 GoalStatus.PREEMPTED: [
'PREEMPTED', wx.Colour(255, 252, 16)],
129 GoalStatus.SUCCEEDED: [
'SUCCEEDED', wx.Colour(38, 250, 253)],
130 GoalStatus.ABORTED: [
'ABORTED', wx.Colour(200, 0, 0)],
131 GoalStatus.REJECTED: [
'REJECTED', wx.Colour(253, 38, 159)],
132 GoalStatus.PREEMPTING: [
'PREEMPTING', wx.Colour(253, 38, 159)],
133 GoalStatus.RECALLING: [
'RECALLING', wx.Colour(230, 38, 253)],
134 GoalStatus.RECALLED: [
'RECALLED', wx.Colour(230, 38, 253)],
135 GoalStatus.LOST: [
'LOST', wx.Colour(255, 0, 0)]}[status]
138 status_string, status_color = self.
status_gui(state)
139 wx.CallAfter(self.
set_status,
''.join([
"Goal finished with status: ",
140 status_string]), status_color)
145 wx.CallAfter(self.
set_status,
"Goal is active", wx.Colour(0, 200, 0))
150 except UnicodeDecodeError:
151 self.
feedback.SetValue(
"Cannot display feedback due to unprintable characters")
166 self.
sz = wx.BoxSizer(wx.VERTICAL)
170 self.
goal = wx.TextCtrl(self.
frame, -1, style=wx.TE_MULTILINE)
182 self.
result = wx.TextCtrl(self.
frame, -1, style=(wx.TE_MULTILINE |
197 self.
status_bg.SetBackgroundColour(wx.Colour(200, 0, 0))
226 rospy.init_node(
'axclient', anonymous=
True)
228 parser = OptionParser(__doc__.strip())
233 (options, args) = parser.parse_args(rospy.myargv())
237 topic_type = rostopic._get_topic_type(
"%s/goal" % args[1])[0]
239 assert(
"Goal" in topic_type)
240 topic_type = topic_type[0:len(topic_type)-4]
241 elif (len(args) == 3):
244 assert(
"Action" in topic_type)
246 parser.error(
"You must specify the action topic name (and optionally type) Eg: ./axclient.py action_topic actionlib/TwoIntsAction ")
252 rospy.signal_shutdown(
'GUI shutdown')
255 if __name__ ==
'__main__':
def set_status(self, label, color)
def done_cb(self, state, result)
def on_cancel(self, event)
def server_check(self, event)
def status_gui(self, status)
def __init__(self, action_type, action_name)
def set_server_status(self, label, color, enabled)
A Simple client implementation of the ActionInterface which supports only one goal at a time...
def set_cancel_button(self, enabled)
def set_feedback(self, feedback)
def yaml_msg_str(type_, yaml_str, filename=None)
def feedback_cb(self, feedback)
def set_result(self, result)