def surveyGuess(self, guesser): if self.service_stack: s = self.service_stack.pop(0) g = GuessRequest() g.inPoints = guesser.outPoints() g.means = guesser.means() g.stds = guesser.stds() g.pers = guesser.periods g.data_type = guesser.data_type g.source_stamp = guesser.stamp g.source_data = guesser.source_data service = self.services[s] resp = service(g) if self.debug: s = String() self.counter += 1 s.data += " CALLED:%d:%s \n" % (self.counter, str(service),) s.data += str(service.resolved_name) + " " s.data += resp.source_data + "\n" s.data += str(resp.source_stamp.secs) + ":" + str(resp.source_stamp.nsecs) self.pdebug.publish(s) if not resp.no_data: guesser.newPoints(resp.outPoints) guesser.stamp = resp.source_stamp guesser.source_data = resp.source_data else: resp = GuessResponse() resp.no_data = True return resp
def testService(self): ars = ARServer("ar_filter", 1000, (0.0, 0.0, 2 * math.pi), 0.1, 0.02, .95, 3.0, locfile=self.tmpfile) ts = Tags() t = Tag() t.id = 1 t.cf = 0.75 t.x = 1.0 t.y = 1.0 t.distance = 2.0**0.5 t.xRot = 0.0 t.yRot = math.pi / 4.0 t.zRot = 0.0 t.xMetric = 1.000 t.yMetric = 1.000 t.zMetric = 0 ts.tags.append(t) ts.tag_count = 1 ars.arGuesser.handle_image(ts) g = Guesser("ar_filter_test", (0.0, 0.0, 2 * math.pi), "location", (1, 1, 1)) xmax = 2.5 ymin = 0.0 g.uniform(ars.nPoints, [[0.0, xmax], [ymin, 2.0], [0.0, 3.25]]) greq = GuessRequest() greq.inPoints = g.outPoints() greq.pers = (0.0, 0.0, 2 * math.pi) greq.data_type = "location" gr = ars.answer_server(greq) parray = np.array([p.point for p in gr.outPoints]) mins = map(min, parray.transpose()) maxs = map(max, parray.transpose()) #print maxs, mins, xmax, ymin self.assertTrue(mins[1] > ymin) self.assertTrue(maxs[0] < xmax)
def testService(self): ars = ARServer("ar_filter", 1000, (0.0, 0.0, 2*math.pi), 0.1, 0.02, .95, 3.0, locfile=self.tmpfile) ts = Tags() t = Tag() t.id = 1 t.cf = 0.75 t.x = 1.0 t.y = 1.0 t.distance = 2.0**0.5 t.xRot = 0.0 t.yRot = math.pi/4.0 t.zRot = 0.0 t.xMetric = 1.000 t.yMetric = 1.000 t.zMetric = 0 ts.tags.append(t) ts.tag_count = 1 ars.arGuesser.handle_image(ts) g = Guesser("ar_filter_test", (0.0, 0.0, 2*math.pi), "location", (1,1,1)) xmax = 2.5 ; ymin = 0.0 g.uniform(ars.nPoints, [[0.0,xmax],[ymin,2.0],[0.0,3.25]]) greq = GuessRequest() greq.inPoints = g.outPoints() greq.pers = (0.0, 0.0, 2*math.pi) greq.data_type = "location" gr = ars.answer_server(greq) parray = np.array([p.point for p in gr.outPoints]) mins = map(min, parray.transpose()) maxs = map(max, parray.transpose()) #print maxs, mins, xmax, ymin self.assertTrue(mins[1] > ymin) self.assertTrue(maxs[0] < xmax)
def surveyGuess(self, guesser): if self.service_stack: s = self.service_stack.pop(0) g = GuessRequest() g.inPoints = guesser.outPoints() g.means = guesser.means() g.stds = guesser.stds() g.pers = guesser.periods g.data_type = guesser.data_type g.source_stamp = guesser.stamp g.source_data = guesser.source_data service = self.services[s] resp = service(g) if self.debug: s = String() self.counter += 1 s.data += " CALLED:%d:%s \n" % ( self.counter, str(service), ) s.data += str(service.resolved_name) + " " s.data += resp.source_data + "\n" s.data += str(resp.source_stamp.secs) + ":" + str( resp.source_stamp.nsecs) self.pdebug.publish(s) if not resp.no_data: guesser.newPoints(resp.outPoints) guesser.stamp = resp.source_stamp guesser.source_data = resp.source_data else: resp = GuessResponse() resp.no_data = True return resp
t.zRot = 0.0 t.xMetric = 1.000 t.yMetric = 1.000 t.zMetric = 0 ts.tags.append(t) ts.tag_count = 1 ars.arGuesser.handle_image(ts) g = Guesser("ar_filter_test", (0.0, 0.0, 2*math.pi), "location", (1,1,1)) g.uniform(ars.nPoints, [[0.0,2.25],[0.0,2.0],[0.0,3.25]]) greq = GuessRequest() greq.inPoints = g.outPoints() greq.pers = (0.0, 0.0, 2*math.pi) greq.data_type = "location" import tgraph tg = tgraph.Tgraph(400,300) parray = np.array([p.point for p in greq.inPoints]) tg.draw_scatter(parray, 0,1,2, "s") gr = ars.answer_server(greq) tg.new_graph() parray = np.array([p.point for p in ars.arGuesser.tarPts.points]) tg.draw_scatter(parray, 0,1,2, "s", recalc=False)
t.zRot = 0.0 t.xMetric = 1.000 t.yMetric = 1.000 t.zMetric = 0 ts.tags.append(t) ts.tag_count = 1 ars.arGuesser.handle_image(ts) g = Guesser("ar_filter_test", (0.0, 0.0, 2 * math.pi), "location", (1, 1, 1)) g.uniform(ars.nPoints, [[0.0, 2.25], [0.0, 2.0], [0.0, 3.25]]) greq = GuessRequest() greq.inPoints = g.outPoints() greq.pers = (0.0, 0.0, 2 * math.pi) greq.data_type = "location" import tgraph tg = tgraph.Tgraph(400, 300) parray = np.array([p.point for p in greq.inPoints]) tg.draw_scatter(parray, 0, 1, 2, "s") gr = ars.answer_server(greq) tg.new_graph() parray = np.array([p.point for p in ars.arGuesser.tarPts.points]) tg.draw_scatter(parray, 0, 1, 2, "s", recalc=False)