summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--host/simu/robots/guybrush/model/bag.py3
-rw-r--r--host/simu/robots/guybrush/model/clamps.py16
2 files changed, 14 insertions, 5 deletions
diff --git a/host/simu/robots/guybrush/model/bag.py b/host/simu/robots/guybrush/model/bag.py
index 6ff18194..3b6cc857 100644
--- a/host/simu/robots/guybrush/model/bag.py
+++ b/host/simu/robots/guybrush/model/bag.py
@@ -43,7 +43,8 @@ class Bag:
(PneumaticCylinder (None, link_bag.io_hub.output[8],
scheduler, 0., 30., 150., 75., 30.),
PneumaticCylinder (None, link_bag.io_hub.output[9],
- scheduler, 0., 30., 150., 75., 30.)))
+ scheduler, 0., 30., 150., 75., 30.)),
+ [ Switch (c) for c in link_bag.io_hub.contact[3:3+4] ])
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/guybrush/model/clamps.py b/host/simu/robots/guybrush/model/clamps.py
index 91e24f9b..1cfc30f1 100644
--- a/host/simu/robots/guybrush/model/clamps.py
+++ b/host/simu/robots/guybrush/model/clamps.py
@@ -29,12 +29,13 @@ from math import pi
class Clamps (Observable):
def __init__ (self, table, robot_position, lower_clamp_motor,
- lower_clamp_cylinders):
+ lower_clamp_cylinders, lower_clamp_sensors):
Observable.__init__ (self)
self.table = table
self.robot_position = robot_position
self.lower_clamp_motor = lower_clamp_motor
self.lower_clamp_cylinders = lower_clamp_cylinders
+ self.lower_clamp_sensors = lower_clamp_sensors
self.lower_clamp_clamping = [ None, None ]
self.lower_clamp_content = [ [ ], [ ] ]
self.lower_clamp_motor.register (self.__lower_clamp_notified)
@@ -84,9 +85,16 @@ class Clamps (Observable):
for e, y in self.lower_clamp_content[top_clamp]])
self.lower_clamp_content[top_clamp] = [ ]
changed = True
- # If something is found, there can be updates.
- if changed:
- pass
+ # Update sensors view.
+ old_state = self.lower_clamp_sensors[0].state
+ if floor_clamp is None:
+ new_state = True
+ else:
+ new_state = not self.lower_clamp_content[floor_clamp]
+ if new_state != old_state:
+ for s in self.lower_clamp_sensors:
+ s.state = new_state
+ s.notify ()
return changed
def __add_load (self, elements):