35 PKG =
'fingertip_pressure' 38 roslib.load_manifest(PKG)
42 from pr2_msgs.msg
import PressureState
46 from fingertip_pressure.msg
import PressureInfo
47 from geometry_msgs.msg
import Vector3
50 wxversion.ensureMinimal(
"2.8")
61 if r + g + b < 3 *128:
62 (rt,gt,bt) = (255,255,255)
65 return (
"#%02x%02x%02x"%(r,g,b),
"#%02x%02x%02x"%(rt,gt,bt))
69 wx.Panel.__init__(self, parent, wx.ID_ANY)
72 sizer = wx.BoxSizer(wx.HORIZONTAL)
75 sizer.Add(self.panel0.panel, 1, wx.EXPAND)
77 sizer.Add(self.panel1.panel, 1, wx.EXPAND)
85 rospy.Subscriber(topic+
"_info", PressureInfo, self.
info_callback)
101 if not self.timer.IsRunning():
102 self.timer.Start(1000./RATE,
True)
105 self._mutex.release()
112 self._mutex.acquire()
114 if self.new_message_ !=
None:
117 self.panel0.new_message(self.new_message_.l_finger_tip)
118 self.panel1.new_message(self.new_message_.r_finger_tip)
120 self.new_message_ =
None 124 if self.new_info_ !=
None:
125 self.panel0.set_info(self.new_info_.sensor[0])
126 self.panel1.set_info(self.new_info_.sensor[1])
127 self.new_info_ =
None 130 self._mutex.release()
138 xrc_path = roslib.packages.get_pkg_dir(PKG) +
'/ui/fingertip_panel.xrc' 139 panelxrc = xrc.XmlResource(xrc_path)
141 self.
panel = panelxrc.LoadPanel(parent,
'FingertipPressurePanel')
143 bag =self.panel.GetSizer()
144 bag.SetEmptyCellSize(wx.Size(0,0))
147 self.
zeros = [0
for i
in range(0,22)]
151 for i
in range(0, NUMSENSORS):
152 self.pad.append(xrc.XRCCTRL(self.
panel,
'pad%i'%i))
153 self.
pad[i].SetEditable(
False)
154 font = self.
pad[i].GetFont()
156 self.
pad[i].SetFont(font)
157 self.
pad[i].SetMinSize(wx.Size(40,35))
160 self.panel.Bind(wx.EVT_RADIOBUTTON, self.
set_Newton, id=xrc.XRCID(
'button_N'))
161 self.panel.Bind(wx.EVT_RADIOBUTTON, self.
set_kPascal, id=xrc.XRCID(
'button_kPa'))
164 self.panel.Bind(wx.EVT_CHECKBOX, self.
set_Zero, id=xrc.XRCID(
'button_Zero'))
167 self._mutex.acquire()
169 self._mutex.release()
172 self._mutex.acquire()
174 self._mutex.release()
177 self._mutex.acquire()
178 cb = event.GetEventObject()
182 self.
zeros = [0
for i
in range(0,22)]
183 self._mutex.release()
187 w.x = u.y * v.z - u.z * v.y
188 w.y = u.z * v.x - u.x * v.z
189 w.z = u.x * v.y - u.y * v.x
190 return math.sqrt(w.x*w.x + w.y*w.y + w.z*w.z)
193 self._mutex.acquire()
195 self.
areas = [self.
calc_area(info.halfside1[i], info.halfside2[i]) * 4
for i
in range(0,22)]
196 self.frame_id_box.SetValue(info.frame_id)
197 self._mutex.release()
200 self._mutex.acquire()
202 for i
in range(0, NUMSENSORS):
206 dat = data[i] - self.
zeros[i]
221 self.
pad[i].SetBackgroundColour(colb)
222 self.
pad[i].SetForegroundColour(colf)
223 self.
pad[i].SetValue(
'#%i\n%i\n%s %s'%(i,dat,scaled,self.
unit))
224 self._mutex.release()
def set_Newton(self, event)
def __init__(self, parent)
def info_callback(self, message)
def on_timer(self, event)
def calc_area(self, u, v)
def message_callback(self, message)
def __init__(self, parent, topic)
def set_Zero(self, event)
def set_kPascal(self, event)
def new_message(self, data)