summaryrefslogtreecommitdiffhomepage
path: root/digital
diff options
context:
space:
mode:
authorNicolas Schodet2011-04-30 20:45:16 +0200
committerNicolas Schodet2011-04-30 20:45:46 +0200
commit4909f63bea2598489a5895f9bbe1e2622093caa1 (patch)
tree302ecbddc392ae78121cc5f9e166c067f576dfe5 /digital
parentecdce887d87139db2e869e72918b4b5be8da5e67 (diff)
digital/io/tools, host/simu: add robospierre
Diffstat (limited to 'digital')
-rw-r--r--digital/io/tools/io/io.py2
-rw-r--r--digital/io/tools/robospierre.py39
-rw-r--r--digital/io/tools/test_simu.py3
-rw-r--r--digital/io/tools/test_simu_control_marcel.py (renamed from digital/io/tools/test_simu_control.py)0
-rw-r--r--digital/io/tools/test_simu_control_robospierre.py101
5 files changed, 144 insertions, 1 deletions
diff --git a/digital/io/tools/io/io.py b/digital/io/tools/io/io.py
index 87471bbd..375ad38d 100644
--- a/digital/io/tools/io/io.py
+++ b/digital/io/tools/io/io.py
@@ -53,7 +53,7 @@ class Proto:
self.proto.send ('s', 'BB', servo, high_time)
def pwm_set (self, value, timer):
- self.proto.send ('w', 'Hh', value, timer)
+ self.proto.send ('w', 'hH', value, timer)
def loader (self, command):
self.proto.send ('c', 'c', command)
diff --git a/digital/io/tools/robospierre.py b/digital/io/tools/robospierre.py
new file mode 100644
index 00000000..948faa8c
--- /dev/null
+++ b/digital/io/tools/robospierre.py
@@ -0,0 +1,39 @@
+import simu.model.table_eurobot2011
+import simu.view.table_eurobot2011
+
+import simu.robots.robospierre.link.bag
+import simu.robots.robospierre.model.bag
+import simu.robots.robospierre.view.bag
+
+import asserv
+import asserv.init
+import mimot
+import mimot.init
+import io
+import io.init
+
+from proto.popen_io import PopenIO
+import math
+
+class Robot:
+
+ def __init__ (self, proto_time):
+ self.table_model = simu.model.table_eurobot2011
+ self.table_view = simu.view.table_eurobot2011
+ self.robot_link = simu.robots.robospierre.link.bag
+ self.robot_model = simu.robots.robospierre.model.bag
+ self.robot_view = simu.robots.robospierre.view.bag
+ asserv_cmd = ('../../asserv/src/asserv/asserv.host', '-m9', 'marcel')
+ mimot_cmd = ('../../mimot/src/dirty/dirty.host', '-m9', 'marcel')
+ io_cmd = ('../src/io.host')
+ self.asserv = asserv.Proto (PopenIO (asserv_cmd), proto_time,
+ **asserv.init.host)
+ self.mimot = mimot.Proto (PopenIO (mimot_cmd), proto_time,
+ **mimot.init.host)
+ self.io = io.Proto (PopenIO (io_cmd), proto_time,
+ **io.init.host)
+ self.robot_start_pos = {
+ False: (700, 2100 - 250, math.radians (-270)),
+ True: (3000 - 700, 2100 - 250, math.radians (-270))
+ }
+
diff --git a/digital/io/tools/test_simu.py b/digital/io/tools/test_simu.py
index 36a5cb1b..80008bb9 100644
--- a/digital/io/tools/test_simu.py
+++ b/digital/io/tools/test_simu.py
@@ -138,6 +138,9 @@ def run (default_robot, test_class = TestSimu):
if options.robot == 'marcel':
import marcel
robot = marcel.Robot
+ elif options.robot == 'robospierre':
+ import robospierre
+ robot = robospierre.Robot
else:
parser.error ("unknown robot")
app = test_class (robot)
diff --git a/digital/io/tools/test_simu_control.py b/digital/io/tools/test_simu_control_marcel.py
index 2a43b7bb..2a43b7bb 100644
--- a/digital/io/tools/test_simu_control.py
+++ b/digital/io/tools/test_simu_control_marcel.py
diff --git a/digital/io/tools/test_simu_control_robospierre.py b/digital/io/tools/test_simu_control_robospierre.py
new file mode 100644
index 00000000..9da57196
--- /dev/null
+++ b/digital/io/tools/test_simu_control_robospierre.py
@@ -0,0 +1,101 @@
+# io - Input & Output with Artificial Intelligence (ai) support on AVR. {{{
+#
+# Copyright (C) 2011 Nicolas Schodet
+#
+# APBTeam:
+# Web: http://apbteam.org/
+# Email: team AT apbteam DOT org
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+#
+# }}}
+from test_simu import TestSimu, run
+from Tkinter import *
+import math
+
+class TestSimuControl (TestSimu):
+ """Interface with extra control."""
+
+ ELEVATION_STROKE = 0x3b0b
+
+ ROTATION_STROKE = 0x11c6
+
+ def __init__ (self, robot_class):
+ TestSimu.__init__ (self, robot_class)
+
+ def create_widgets (self):
+ TestSimu.create_widgets (self)
+ self.control_frame = Frame (self)
+ self.control_frame.pack (side = 'left', before = self.table_view,
+ fill = 'y')
+ self.clamp_var = IntVar ()
+ self.clamp_var.set (1)
+ self.clamp_button = Checkbutton (self.control_frame, text = 'Clamp',
+ indicatoron = False,
+ variable = self.clamp_var, command = self.clamp_command)
+ self.clamp_button.pack ()
+ self.elevation_up_button = Button (self.control_frame,
+ text = 'Elevation up', padx = 0, pady = 0,
+ command = self.elevation_up_command)
+ self.elevation_up_button.pack ()
+ self.elevation_down_button = Button (self.control_frame,
+ text = 'Elevation down', padx = 0, pady = 0,
+ command = self.elevation_down_command)
+ self.elevation_down_button.pack ()
+ self.rotation_cw_button = Button (self.control_frame,
+ text = 'Rotation cw', padx = 0, pady = 0,
+ command = self.rotation_cw_command)
+ self.rotation_cw_button.pack ()
+ self.rotation_ccw_button = Button (self.control_frame,
+ text = 'Rotation ccw', padx = 0, pady = 0,
+ command = self.rotation_ccw_command)
+ self.rotation_ccw_button.pack ()
+ self.table_view.bind ('<1>', self.move)
+ self.table_view.bind ('<3>', self.orient)
+
+ def move (self, ev):
+ pos = self.table_view.screen_coord ((ev.x, ev.y))
+ self.asserv.goto (pos[0], pos[1])
+
+ def orient (self, ev):
+ x, y = self.table_view.screen_coord ((ev.x, ev.y))
+ robot_pos = self.robot_model.position.pos
+ if robot_pos is not None:
+ a = math.atan2 (y - robot_pos[1], x - robot_pos[0])
+ self.asserv.goto_angle (a)
+
+ def clamp_command (self):
+ if self.clamp_var.get ():
+ self.io.pwm_set (-0x7fff, 255)
+ else:
+ self.io.pwm_set (0x7fff, 255)
+
+ def elevation_up_command (self):
+ self.mimot.speed_pos ('a0', self.ELEVATION_STROKE / 2)
+
+ def elevation_down_command (self):
+ self.mimot.speed_pos ('a0', -self.ELEVATION_STROKE / 2)
+
+ def rotation_cw_command (self):
+ self.mimot.speed_pos ('a1', self.ROTATION_STROKE / 2)
+
+ def rotation_ccw_command (self):
+ self.mimot.speed_pos ('a1', -self.ROTATION_STROKE / 2)
+
+ def change_color (self, *dummy):
+ pass
+
+if __name__ == '__main__':
+ run ('robospierre', TestSimuControl)