summaryrefslogtreecommitdiff
path: root/host/simu
diff options
context:
space:
mode:
Diffstat (limited to 'host/simu')
-rw-r--r--host/simu/robots/marcel/model/bag.py2
-rw-r--r--host/simu/robots/marcel/model/loader.py21
-rw-r--r--host/simu/robots/marcel/view/loader.py6
3 files changed, 27 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 = [ ]
diff --git a/host/simu/robots/marcel/view/loader.py b/host/simu/robots/marcel/view/loader.py
index e640157b..4ad2ffce 100644
--- a/host/simu/robots/marcel/view/loader.py
+++ b/host/simu/robots/marcel/view/loader.py
@@ -59,6 +59,12 @@ class Loader (Drawable):
if x > 200:
x = 0
y += 40
+ if self.model.gate_angle is not None:
+ ratio = self.model.gate_angle / self.model.GATE_STROKE
+ # Draw gate.
+ for i in xrange (0, 4):
+ self.draw_line ((100, 125 + 5 * i),
+ (300, 25 + 25 * i + (75 - 10 * i) * ratio))
if self.model.elevator_height is not None:
self.trans_identity ()
self.trans_rotate (-self.model.elevator_angle)