summaryrefslogtreecommitdiffhomepage
path: root/host/simu/robots/guybrush/view
diff options
context:
space:
mode:
authorNicolas Schodet2012-03-30 23:09:45 +0200
committerNicolas Schodet2012-04-02 00:51:50 +0200
commitd66664cde28a490759fd6f3a11791b9f20c1933d (patch)
tree983f7d2b777a127963d0392c73c3ac7fe71d3db1 /host/simu/robots/guybrush/view
parentc0640f4a2598a8fcc9c90d484c0d8f0b54f03b31 (diff)
host/simu/robots/guybrush: simulate lower clamps elements taking
Diffstat (limited to 'host/simu/robots/guybrush/view')
-rw-r--r--host/simu/robots/guybrush/view/bag.py2
-rw-r--r--host/simu/robots/guybrush/view/clamps.py5
-rw-r--r--host/simu/robots/guybrush/view/robot.py18
3 files changed, 22 insertions, 3 deletions
diff --git a/host/simu/robots/guybrush/view/bag.py b/host/simu/robots/guybrush/view/bag.py
index f512886a..3d5fb621 100644
--- a/host/simu/robots/guybrush/view/bag.py
+++ b/host/simu/robots/guybrush/view/bag.py
@@ -37,7 +37,7 @@ class Bag:
'Color')
self.strat_switch = Switch (sensor_frame, model_bag.strat_switch,
'Strat')
- self.robot = Robot (table, model_bag.position)
+ self.robot = Robot (table, model_bag.position, model_bag.clamps)
self.clamps = ClampsSide (actuator_view.add_view (ClampsSide.width,
ClampsSide.height), model_bag.clamps)
self.distance_sensor = [DistanceSensorUS (self.robot, ds)
diff --git a/host/simu/robots/guybrush/view/clamps.py b/host/simu/robots/guybrush/view/clamps.py
index 11ef09b8..bdcb08a4 100644
--- a/host/simu/robots/guybrush/view/clamps.py
+++ b/host/simu/robots/guybrush/view/clamps.py
@@ -55,6 +55,11 @@ class ClampsSide (Drawable):
if c is not None:
self.draw_line ((7, -45), (7, -46 - c * 33),
(-28, -46 - c * 33))
+ if self.model.lower_clamp_content[i]:
+ e, y = self.model.lower_clamp_content[i][0]
+ self.draw_rectangle ((7, -45 - c * 15),
+ (7 - e.radius * 2, -49 - c * 15),
+ fill = GREY)
if not i:
self.trans_rotate (pi)
self.trans_pop ()
diff --git a/host/simu/robots/guybrush/view/robot.py b/host/simu/robots/guybrush/view/robot.py
index fcf375cb..79c61d15 100644
--- a/host/simu/robots/guybrush/view/robot.py
+++ b/host/simu/robots/guybrush/view/robot.py
@@ -23,18 +23,21 @@
# }}}
"""Guybrush robot view."""
import simu.inter.drawable
-from math import pi
+from math import pi, cos
+from simu.view.table_eurobot2012 import WHITE, BLACK
COLOR_ROBOT = '#000000'
COLOR_AXES = '#202040'
class Robot (simu.inter.drawable.Drawable):
- def __init__ (self, onto, position_model):
+ def __init__ (self, onto, position_model, clamps_model):
"""Construct and make connections."""
simu.inter.drawable.Drawable.__init__ (self, onto)
self.position_model = position_model
+ self.clamps_model = clamps_model
self.position_model.register (self.__position_notified)
+ self.clamps_model.register (self.update)
def __position_notified (self):
"""Called on position modifications."""
@@ -48,6 +51,17 @@ class Robot (simu.inter.drawable.Drawable):
if self.pos is not None:
self.trans_translate (self.pos)
self.trans_rotate (self.angle)
+ # Draw lower clamps content.
+ r = self.clamps_model.lower_clamp_rotation
+ if r is not None:
+ sx = cos (r)
+ for content in self.clamps_model.lower_clamp_content:
+ for e, y in content:
+ x = 117 + sx * 54
+ color = WHITE if e.value else BLACK
+ self.draw_oval ((x, y), sx * e.radius, e.radius,
+ fill = color)
+ sx = - sx
# Draw robot body.
self.draw_polygon ((150, 171.5), (-80, 171.5), (-130, 121.5),
(-130, -121.5), (-80, -171.5), (150, -171.5),