From 443ed8a8f04b18297f6b2e9f559b700dbbba7bd9 Mon Sep 17 00:00:00 2001 From: Nicolas Schodet Date: Tue, 3 Mar 2009 00:55:03 +0100 Subject: * digital/asserv/tools: - switched to radians for all interfaces. --- digital/asserv/tools/asserv/asserv.py | 12 ++++++------ digital/asserv/tools/inter_asserv.py | 6 +++--- digital/asserv/tools/test_goto.py | 3 ++- digital/io/tools/test_simu.py | 5 +++-- 4 files changed, 14 insertions(+), 12 deletions(-) (limited to 'digital') diff --git a/digital/asserv/tools/asserv/asserv.py b/digital/asserv/tools/asserv/asserv.py index 2424a88b..665fc759 100644 --- a/digital/asserv/tools/asserv/asserv.py +++ b/digital/asserv/tools/asserv/asserv.py @@ -152,7 +152,8 @@ class Asserv: self.proto.send ('p', 'BL', ord ('Y'), 256 * y / self.param['scale']) if a is not None: - self.proto.send ('p', 'BL', ord ('A'), a * (1 << 24) / 360) + self.proto.send ('p', 'BL', ord ('A'), + a * (1 << 24) / (2 * math.pi)) def goto (self, x, y, backward_ok = False): """Go to position.""" @@ -165,7 +166,7 @@ class Asserv: def goto_angle (self, a): """Go to angle.""" self.mseq += 1 - self.proto.send ('x', 'HB', a * (1 << 16) / 360, self.mseq) + self.proto.send ('x', 'HB', a * (1 << 16) / (2 * math.pi), self.mseq) self.wait (self.finished, auto = True) def goto_xya (self, x, y, a, backward_ok = False): @@ -174,13 +175,12 @@ class Asserv: self.proto.send (backward_ok and 'r' or 'x', 'LLHB', 256 * x / self.param['scale'], 256 * y / self.param['scale'], - a * (1 << 16) / 360, self.mseq) + a * (1 << 16) / (2 * math.pi), self.mseq) self.wait (self.finished, auto = True) def set_simu_pos (self, x, y, a): """Set simulated position.""" - self.proto.send ('h', 'BHHH', ord ('X'), x, y, - math.radians (a) * 1024) + self.proto.send ('h', 'BHHH', ord ('X'), x, y, a * 1024) def register_pos (self, func, interval = 225 / 4): """Will call func each time a position is received.""" @@ -234,7 +234,7 @@ class Asserv: def handle_pos (self, x, y, a): x = x / 256 * self.param['scale'] y = y / 256 * self.param['scale'] - a = a * 360 / (1 << 24) + a = a * 2 * math.pi / (1 << 24) self.pos_func (x, y, a) def wait (self, cond = None, auto = False): diff --git a/digital/asserv/tools/inter_asserv.py b/digital/asserv/tools/inter_asserv.py index 1dd47fc3..d6b2ea34 100644 --- a/digital/asserv/tools/inter_asserv.py +++ b/digital/asserv/tools/inter_asserv.py @@ -90,7 +90,7 @@ class InterAsserv (Inter): def pos (self, x, y, a): self.tableview.robot.pos = (x, y) - self.tableview.robot.angle = float (a) / 180 * math.pi + self.tableview.robot.angle = a self.update (self.tableview.robot) self.update () @@ -106,8 +106,8 @@ class InterAsserv (Inter): def button3 (self, ev): x, y = self.tableview.screen_coord ((ev.x, ev.y)) - a = math.degrees (math.atan2 (y - self.tableview.robot.pos[1], - x - self.tableview.robot.pos[0])) + a = math.atan2 (y - self.tableview.robot.pos[1], + x - self.tableview.robot.pos[0]) action = self.actionVar.get () if action == 'set_pos': self.a.set_pos (a = a) diff --git a/digital/asserv/tools/test_goto.py b/digital/asserv/tools/test_goto.py index 8def90af..097cff69 100644 --- a/digital/asserv/tools/test_goto.py +++ b/digital/asserv/tools/test_goto.py @@ -6,6 +6,7 @@ import asserv.init import proto.popen_io import serial import random +import math if sys.argv[1] == '!': io = proto.popen_io.PopenIO (sys.argv[2:]) @@ -18,7 +19,7 @@ for i in xrange (10): x = random.randrange (2000) y = random.randrange (1100) a.goto (x, y) - a.goto_angle (random.randrange (360)) + a.goto_angle (math.radians (random.randrange (360))) a.goto (0, 0) a.goto_angle (0) a.close () diff --git a/digital/io/tools/test_simu.py b/digital/io/tools/test_simu.py index 1d7175a7..73e0259c 100644 --- a/digital/io/tools/test_simu.py +++ b/digital/io/tools/test_simu.py @@ -1,6 +1,7 @@ import sys sys.path.append (sys.path[0] + '/../../../host') sys.path.append (sys.path[0] + '/../../asserv/tools') +import math import mex.hub import utils.forked @@ -17,8 +18,8 @@ from Tkinter import * class TestSimu (InterNode): """Inter, with simulated programs.""" - robot_start_pos = ((200, 2100 - 70, -90), - (3000 - 200, 2100 - 70, -90)) + robot_start_pos = ((200, 2100 - 70, math.radians (-90)), + (3000 - 200, 2100 - 70, math.radians (-90))) def __init__ (self, asserv_cmd, io_cmd): # Hub. -- cgit v1.2.3