summaryrefslogtreecommitdiffhomepage
path: root/host/simu/robots/guybrush/model/clamps.py
diff options
context:
space:
mode:
authorNicolas Schodet2012-03-31 14:24:53 +0200
committerNicolas Schodet2012-04-02 00:51:51 +0200
commitcbb9c4780b3551df44b0a1ca7ae08ca4497f1b02 (patch)
tree133e23038e36394fbf38e42efeafb36696daf240 /host/simu/robots/guybrush/model/clamps.py
parent7016e1fe93510c7fc9e3efdd09a9d91b0524a827 (diff)
host/simu/robots/guybrush: simulate lower clamps sensors
Diffstat (limited to 'host/simu/robots/guybrush/model/clamps.py')
-rw-r--r--host/simu/robots/guybrush/model/clamps.py16
1 files changed, 12 insertions, 4 deletions
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):