32 lrfviewer_spec = [
"implementation_id",
"LRFViewer",
33 "type_name",
"LRFViewer",
34 "description",
"Laser Range Finder Viewer component",
36 "vendor",
"Noriaki Ando, AIST",
37 "category",
"example",
38 "activity_type",
"DataFlowComponent",
41 "lang_type",
"SCRIPT",
52 OpenRTM_aist.DataFlowComponentBase.__init__(self, manager)
61 _pose3D = RTC.Pose3D(RTC.Point3D(0.0, 0.0, 0.0),
62 RTC.Orientation3D(0.0, 0.0, 0.0))
63 _size3D = RTC.Size3D(0.0, 0.0, 0.0)
64 _geometry3D = RTC.Geometry3D(_pose3D, _size3D)
65 _rangerConfig = RTC.RangerConfig(0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0)
68 RTC.RangerGeometry(_geometry3D, []),
90 self.
end_point = _rangeData.config.maxAngle
137 ToggleItem.__init__(self)
164 def __init__(self, canvas, x0, y0, width, height, pitch, color, linewd):
165 ToggleItem.__init__(self)
184 x_start = int(self.
x0 % self.
pitch)
185 x_num = int((self.
width - x_start) / self.
pitch) + 1
186 for x
in range(x_num):
187 x0 = x_start + self.
pitch * x
192 y_start = int(self.
y0 % self.
pitch)
193 y_num = int((self.
height - y_start) / self.
pitch) + 1
194 for y
in range(y_num):
195 y0 = y_start + self.
pitch * y
196 id = self.
canvas.create_line(0, y0, self.
width, y0,
223 def __init__(self, canvas, width, height, color="#ffffff", linewd=1):
224 ToggleItem.__init__(self)
268 self.
tick = simulator.get_tick()
270 self.
trans = simulator.get_translation()
274 return self.
trans(x, y, dx, dy, dth)
286 line_color="#ff0000", fill_color="#ff0000", linewd=1):
287 ScaledObject.__init__(self, simulator)
333 text = Label(frame, text=
"LRF range area", anchor=W, justify=LEFT)
335 line = Checkbutton(frame, text=
"Line",
336 onvalue=
"on", offvalue=
"off",
337 justify=LEFT, anchor=W,
341 fill = Checkbutton(frame, text=
"Fill",
342 onvalue=
"on", offvalue=
"off",
343 justify=LEFT, anchor=W,
347 thresh = Checkbutton(frame, text=
"Threshold",
348 onvalue=
True, offvalue=
False,
349 justify=LEFT, anchor=W,
351 thresh_scale = Scale(frame, from_=0, to=100, resolution=0.1,
355 tfilter = Checkbutton(frame, text=
"Filter(Time)",
356 onvalue=
True, offvalue=
False,
357 justify=LEFT, anchor=W,
359 tfilter_scale = Scale(frame, from_=0, to=1, resolution=0.01,
363 sfilter = Checkbutton(frame, text=
"Filter(Spacial)",
364 onvalue=
True, offvalue=
False,
365 justify=LEFT, anchor=W,
367 sfilter_scale = Scale(frame, from_=0, to=1, resolution=0.01,
371 for w
in [text, line, fill, thresh, thresh_scale,
372 tfilter, tfilter_scale, sfilter, sfilter_scale]:
373 w.pack(side=TOP, anchor=W, fill=X)
413 rpos.append(self.
translate(0, 0, 0, 0, 0))
432 if tfilter
and len(data) == len(self.
pre_data):
433 for (n, d)
in enumerate(data):
435 data[n] = self.
pre_data[n] * k_t + d * (1 - k_t)
438 for (n, d)
in enumerate(data):
445 d = pre_d * k_s + d * (1 - k_s)
455 pos.append(self.
translate(x, y, 0, 0, 0))
466 rdata = self.
source.get_range_data()
470 res = self.
source.get_angular_res()
474 beg_angle = self.
source.get_start_point()
478 end_angle = self.
source.get_end_point()
493 def __init__(self, master=None, width=480, height=480):
494 Frame.__init__(self, master)
538 self.
canvas.pack(side=LEFT)
547 self.
frame.pack(side=LEFT)
585 dummy = Frame(frame, width=self.
wd)
587 sl = Scale(frame, from_=0, to=10, resolution=0.01,
588 label=
"Scale Factor", command=self.
on_scale,
589 variable=self.
scale_var, orient=HORIZONTAL)
590 bt = Button(frame, text=
"Reset Scale", command=self.
reset_scale)
591 sl.pack(side=TOP, fill=X)
592 bt.pack(side=TOP, fill=X)
630 axis = Checkbutton(frame, text=
"Axis",
631 onvalue=
"on", offvalue=
"off",
632 justify=LEFT, anchor=W,
635 grid = Checkbutton(frame, text=
"Grid",
636 onvalue=
"on", offvalue=
"off",
637 justify=LEFT, anchor=W,
640 for w
in [axis, grid]:
641 w.pack(side=TOP, anchor=W, fill=X)
644 for r
in self.
rnames.keys():
658 x_tmp = (math.cos(dt) * x - math.sin(dt) * y + dx)/self.
scale 659 y_tmp = (math.sin(dt) * x + math.cos(dt) * y + dy)/self.
scale 662 yo = -y_tmp + self.
y0 669 threading.Thread.__init__(self)
687 data[i] = pre * 0.9 + random.randint(0, 255) * 0.1
692 self.
lrf.set_value(data)
699 m.master.title(
"Laser Range Finder Viewer")
701 mgr = OpenRTM_aist.Manager.init(sys.argv)
702 mgr.activateManager()
704 mgr.registerFactory(profile, LRFViewer, OpenRTM_aist.Delete)
706 lrf_rtc = mgr.createComponent(
"LRFViewer")
707 m.lrf.set_data_source(lrf_rtc)
712 if __name__ ==
'__main__':
main()
def on_rname_toggle(self)
def __init__(self, canvas, text, x, y)
def get_start_point(self)
def set_value(self, data)
def create_checkbutton(self, frame)
def set_data_source(self, source)
def draw_text(self, x, y, text)
The Properties class represents a persistent set of properties.
def on_tfilter(self, var)
def __init__(self, simulator, line_color="#ff0000", fill_color="#ff0000", linewd=1)
def __init__(self, manager)
def create_scale(self, frame)
def create_ctrl(self, frame)
def __init__(self, canvas, width, height, color="#ffffff", linewd=1)
def onDeactivated(self, ec_id)
def on_tickchange(self, val)
def get_translation(self)
def on_threshold(self, var)
def translate(self, x, y, dx, dy, dth)
def range_to_pos(self, data)
def __init__(self, lrf, step=681)
def onExecute(self, ec_id)
def __init__(self, simulator)
def addInPort(self, name, inport)
def real_to_canvas(self, x, y, dx, dy, dt)
def set_pitch(self, pitch)
def onShutdown(self, ec_id)
def __init__(self, master=None, width=480, height=480)
def __init__(self, canvas, x0, y0, width, height, pitch, color, linewd)
def on_sfilter(self, var)
def reset_tickscale(self)
DataFlowComponentBase class.
def get_angular_res(self)