summaryrefslogtreecommitdiff
path: root/host/simu/robots
diff options
context:
space:
mode:
authorNicolas Schodet2011-06-01 15:26:22 +0200
committerNicolas Schodet2011-06-01 15:26:22 +0200
commit51b917f7994d6d53fde11263ba4da3470fd2a6c4 (patch)
treebcddd256b54a9be8a77eb190ed891b75ba91edc4 /host/simu/robots
parentb2c12931a8378cdb2112da8b21b63099683516f5 (diff)
digital/io-hub, host/simu: add codebar
Diffstat (limited to 'host/simu/robots')
-rw-r--r--host/simu/robots/robospierre/model/bag.py2
-rw-r--r--host/simu/robots/robospierre/model/clamp.py15
2 files changed, 12 insertions, 5 deletions
diff --git a/host/simu/robots/robospierre/model/bag.py b/host/simu/robots/robospierre/model/bag.py
index 284e5bb8..b9d3bc3f 100644
--- a/host/simu/robots/robospierre/model/bag.py
+++ b/host/simu/robots/robospierre/model/bag.py
@@ -44,7 +44,7 @@ class Bag:
8 * pi, 0, 0.5 * pi) for i in (0, 1, 3, 4) ]
self.clamp = Clamp (table, self.position, link_bag.mimot.aux[0],
link_bag.mimot.aux[1], self.clamping_motor, self.door_motors,
- self.contact[0:7])
+ self.contact[0:7], link_bag.io_hub.codebar)
self.distance_sensor = [
DistanceSensorSensopart (link_bag.io_hub.adc[0], scheduler, table,
(20, 20), pi * 10 / 180, (self.position, ), 2),
diff --git a/host/simu/robots/robospierre/model/clamp.py b/host/simu/robots/robospierre/model/clamp.py
index 0af4ccf3..dbcab5f2 100644
--- a/host/simu/robots/robospierre/model/clamp.py
+++ b/host/simu/robots/robospierre/model/clamp.py
@@ -30,13 +30,14 @@ from math import pi, cos, sin
class Slot:
"""Slot which can contain a pawn."""
- def __init__ (self, x, y, z, side, door_motor, contact):
+ def __init__ (self, x, y, z, side, door_motor, contact, codebar = None):
self.x = x
self.y = y
self.z = z
self.side = side
self.door_motor = door_motor
self.contact = contact
+ self.codebar = codebar
self.pawn = None
class Clamp (Observable):
@@ -62,7 +63,8 @@ class Clamp (Observable):
SLOT_SIDE = 6
def __init__ (self, table, robot_position, elevation_motor,
- rotation_motor, clamping_motor, door_motors, slot_contacts):
+ rotation_motor, clamping_motor, door_motors, slot_contacts,
+ codebars):
Observable.__init__ (self)
self.table = table
self.robot_position = robot_position
@@ -75,13 +77,13 @@ class Clamp (Observable):
door_motors[2], None, door_motors[3], None)
self.slots = (
Slot (self.BAY_OFFSET, 0, 0 * self.BAY_ZOFFSET, 0,
- door_motors[0], slot_contacts[0]),
+ door_motors[0], slot_contacts[0], codebars[0]),
Slot (self.BAY_OFFSET, 0, 1 * self.BAY_ZOFFSET, 0,
None, slot_contacts[1]),
Slot (self.BAY_OFFSET, 0, 2 * self.BAY_ZOFFSET, 0,
door_motors[1], slot_contacts[2]),
Slot (-self.BAY_OFFSET, 0, 0 * self.BAY_ZOFFSET, 1,
- door_motors[2], slot_contacts[3]),
+ door_motors[2], slot_contacts[3], codebars[1]),
Slot (-self.BAY_OFFSET, 0, 1 * self.BAY_ZOFFSET, 1,
None, slot_contacts[4]),
Slot (-self.BAY_OFFSET, 0, 2 * self.BAY_ZOFFSET, 1,
@@ -203,6 +205,11 @@ class Clamp (Observable):
and slots[0].pawn.kind == 'tower'))
# This one is really high.
slots[2].contact.state = not (slots[2].pawn is not None)
+ if slots[0].pawn:
+ slots[0].codebar.element_type = slots[0].pawn.kind
+ else:
+ slots[0].codebar.element_type = None
+ slots[0].codebar.notify ()
slot_side = self.slots[self.SLOT_SIDE]
slot_side.contact.state = slot_side.pawn is None
clamp_slot = self.__get_clamp_slot ()