summaryrefslogtreecommitdiff
path: root/host/simu/robots/marcel/model
diff options
context:
space:
mode:
authorNicolas Schodet2010-05-11 22:39:29 +0200
committerNicolas Schodet2010-05-11 22:39:29 +0200
commit3462dbdfea97226ce1ddb27d23ccaca8d10b7e11 (patch)
tree259f179fdd4374e313541f6d2c9cd67f3f9f5813 /host/simu/robots/marcel/model
parent196a0500cc747be402d910ffb36ea521f842168c (diff)
digital/{asserv,io}, host/simu/robots/marcel: add gate simulation
Diffstat (limited to 'host/simu/robots/marcel/model')
-rw-r--r--host/simu/robots/marcel/model/bag.py2
-rw-r--r--host/simu/robots/marcel/model/loader.py21
2 files changed, 21 insertions, 2 deletions
diff --git a/host/simu/robots/marcel/model/bag.py b/host/simu/robots/marcel/model/bag.py
index 04edd12d..000090d1 100644
--- a/host/simu/robots/marcel/model/bag.py
+++ b/host/simu/robots/marcel/model/bag.py
@@ -37,7 +37,7 @@ class Bag:
self.position = Position (link_bag.asserv.position)
self.loader = Loader (table, self.position, link_bag.mimot.aux[0],
link_bag.mimot.aux[1], link_bag.asserv.aux[0],
- link_bag.io.contact[0:2])
+ link_bag.asserv.aux[1], link_bag.io.contact[0:2])
self.distance_sensor = [
DistanceSensorSensopart (link_bag.io.adc[0], scheduler, table,
(30 - 20, 0), 0, (self.position, ), 2),
diff --git a/host/simu/robots/marcel/model/loader.py b/host/simu/robots/marcel/model/loader.py
index 44ff83bc..79292ecd 100644
--- a/host/simu/robots/marcel/model/loader.py
+++ b/host/simu/robots/marcel/model/loader.py
@@ -36,16 +36,19 @@ class Loader (Observable):
ELEVATOR_LINEAR_STROKE = 32
ELEVATOR_ROTATING_STROKE = 200 - 32
+ GATE_STROKE = 3.3284 * pi
+
FRONT_ZONE_X_MIN = 120 - 15
FRONT_ZONE_X_MAX = 120 + CLAMP_LENGTH - 15
def __init__ (self, table, robot_position, left_clamp_link, right_clamp_link,
- elevator_link, element_contacts):
+ elevator_link, gate_link, element_contacts):
Observable.__init__ (self)
self.table = table
self.robot_position = robot_position
self.clamp_link = (left_clamp_link, right_clamp_link)
self.elevator_link = elevator_link
+ self.gate_link = gate_link
self.element_contacts = element_contacts
self.element_contacts[1].state = True
self.element_contacts[1].notify ()
@@ -58,6 +61,7 @@ class Loader (Observable):
self.clamp_link[0].register (self.__left_clamp_notified)
self.clamp_link[1].register (self.__right_clamp_notified)
self.elevator_link.register (self.__elevator_notified)
+ self.gate_link.register (self.__gate_notified)
def __robot_position_notified (self):
c = self.element_contacts[0]
@@ -149,6 +153,21 @@ class Loader (Observable):
def __right_clamp_notified (self):
self.__clamp_notified (1)
+ def __gate_notified (self):
+ self.gate_angle = self.gate_link.angle
+ if self.gate_angle is not None and self.robot_position is not None:
+ # If gate is high, drop elements.
+ if self.load and self.gate_angle > self.GATE_STROKE / 2:
+ m = TransMatrix ()
+ m.rotate (self.robot_position.angle)
+ m.translate (self.robot_position.pos)
+ pos = m.apply ((-250, 0))
+ for e in self.load:
+ e.pos = pos
+ e.notify ()
+ self.load = [ ]
+ self.notify ()
+
def __get_front_elements (self):
"""Return a list of elements in front of the robot, between clamp."""
elements = [ ]