35 usage: %prog /action_name action_type 40 from optparse
import OptionParser
46 from cStringIO
import StringIO
47 from library
import to_yaml, yaml_msg_str
48 from dynamic_action
import DynamicAction
64 self.action_type.action,
74 self.status_bg.SetBackgroundColour(wx.Colour(200, 0, 0))
75 self.status.SetLabel(
"Waiting For Goal...")
76 self.send_feedback.Disable()
77 self.succeed.Disable()
79 self.preempt.Disable()
81 self.goal.SetValue(
"")
84 self.status_bg.SetBackgroundColour(wx.Colour(0, 200, 0))
85 self.status.SetLabel(
"Received Goal. Send feedback, succeed, or abort.")
86 self.send_feedback.Enable()
92 self.goal.SetValue(
to_yaml(goal))
93 except UnicodeDecodeError:
94 self.goal.SetValue(
"Cannot display goal due to unprintable characters")
97 self.status_bg.SetBackgroundColour(wx.Colour(0, 200, 200))
98 self.status.SetLabel(
"Preempt requested...")
103 self.condition.acquire()
115 if self.server.is_preempt_requested():
117 self.condition.wait(1.0)
127 self.server.set_aborted()
130 self.server.set_preempted()
134 self.condition.release()
137 self.condition.acquire()
141 self.feedback.GetValue())
143 self.feedback_msg.serialize(buff)
146 self.condition.notify()
147 except roslib.message.SerializationError
as e:
149 wx.MessageBox(str(e),
"Error serializing feedback", wx.OK)
151 self.condition.release()
154 self.condition.acquire()
159 self.result_msg.serialize(buff)
162 self.condition.notify()
163 except roslib.message.SerializationError
as e:
165 wx.MessageBox(str(e),
"Error serializing result", wx.OK)
167 self.condition.release()
170 self.condition.acquire()
173 self.condition.notify()
175 self.condition.release()
178 self.condition.acquire()
181 self.condition.notify()
183 self.condition.release()
189 self.
action_name +
' - ' + self.action_type.name +
' - Standin' 192 self.
sz = wx.BoxSizer(wx.VERTICAL)
194 tmp_feedback = self.action_type.feedback()
195 tmp_result = self.action_type.result()
197 self.
goal = wx.TextCtrl(self.
frame, -1, style=(wx.TE_MULTILINE | wx.TE_READONLY))
200 self.goal_st.Add(self.
goal, 1, wx.EXPAND)
203 self.feedback.SetValue(
to_yaml(tmp_feedback))
206 self.feedback_st.Add(self.
feedback, 1, wx.EXPAND)
209 self.result.SetValue(
to_yaml(tmp_result))
212 self.result_st.Add(self.
result, 1, wx.EXPAND)
215 self.send_feedback.Bind(wx.EVT_BUTTON, self.
on_feedback)
218 self.succeed.Bind(wx.EVT_BUTTON, self.
on_succeed)
221 self.abort.Bind(wx.EVT_BUTTON, self.
on_abort)
224 self.preempt.Bind(wx.EVT_BUTTON, self.
on_preempt)
227 self.status_bg.SetBackgroundColour(wx.Colour(200, 0, 0))
230 self.sz.Add(self.
goal_st, 1, wx.EXPAND)
232 self.sz.Add(self.
result_st, 1, wx.EXPAND)
234 self.sz.Add(self.
succeed, 0, wx.EXPAND)
235 self.sz.Add(self.
abort, 0, wx.EXPAND)
236 self.sz.Add(self.
preempt, 0, wx.EXPAND)
237 self.sz.Add(self.
status_bg, 0, wx.EXPAND)
239 self.frame.SetSizer(self.
sz)
249 if __name__ ==
'__main__':
250 rospy.init_node(
'axserver', anonymous=
True)
252 parser = OptionParser(__doc__.strip())
257 (options, args) = parser.parse_args(rospy.myargv())
260 parser.error(
"You must specify the action name and type. Eg: ./axserver.py my_action actionlib/Test")
266 rospy.signal_shutdown(
'GUI shutdown')
def on_preempt(self, event)
def __init__(self, action_type, action_name)
def on_succeed(self, event)
def on_feedback(self, event)
def on_abort(self, event)
def set_preempt_requested(self)
def yaml_msg_str(type_, yaml_str, filename=None)