summaryrefslogtreecommitdiff
path: root/host/simu/robots/apbirthday/view
diff options
context:
space:
mode:
authorNicolas Schodet2013-03-28 23:28:13 +0100
committerNicolas Schodet2013-03-28 23:32:49 +0100
commit75cc934b072310f22c5fe349168e5e4cdc231c4c (patch)
tree4c195e983d9974458f92199e15647f01235f4856 /host/simu/robots/apbirthday/view
parent09c941cd2d30d07ef2dfe779bff2c934ce7cd718 (diff)
host/simu/robots/apbirthday: add cake arm simulation
Still need color sensors simulation.
Diffstat (limited to 'host/simu/robots/apbirthday/view')
-rw-r--r--host/simu/robots/apbirthday/view/bag.py2
-rw-r--r--host/simu/robots/apbirthday/view/robot.py14
2 files changed, 14 insertions, 2 deletions
diff --git a/host/simu/robots/apbirthday/view/bag.py b/host/simu/robots/apbirthday/view/bag.py
index dfea21fa..7956e5f2 100644
--- a/host/simu/robots/apbirthday/view/bag.py
+++ b/host/simu/robots/apbirthday/view/bag.py
@@ -32,7 +32,7 @@ class Bag:
self.jack = Switch (sensor_frame, model_bag.jack, 'Jack')
self.color_switch = Switch (sensor_frame, model_bag.color_switch,
'Color')
- self.robot = Robot (table, model_bag.position)
+ self.robot = Robot (table, model_bag.position, model_bag.cake_arm)
self.distance_sensor = [DistanceSensorUS (self.robot, ds)
for ds in model_bag.distance_sensor]
diff --git a/host/simu/robots/apbirthday/view/robot.py b/host/simu/robots/apbirthday/view/robot.py
index 398d34c8..cb489fb0 100644
--- a/host/simu/robots/apbirthday/view/robot.py
+++ b/host/simu/robots/apbirthday/view/robot.py
@@ -29,11 +29,13 @@ COLOR_AXES = '#202040'
class Robot (simu.inter.drawable.Drawable):
- def __init__ (self, onto, position_model):
+ def __init__ (self, onto, position_model, cake_arm_model):
"""Construct and make connections."""
simu.inter.drawable.Drawable.__init__ (self, onto)
self.position_model = position_model
self.position_model.register (self.__position_notified)
+ self.cake_arm_model = cake_arm_model
+ self.cake_arm_model.register (self.update)
def __position_notified (self):
"""Called on position modifications."""
@@ -59,6 +61,16 @@ class Robot (simu.inter.drawable.Drawable):
self.draw_line ((0, +f / 2), (0, -f / 2), fill = COLOR_AXES)
self.draw_line ((-wr, f / 2), (+wr, f / 2), fill = COLOR_AXES)
self.draw_line ((-wr, -f / 2), (+wr, -f / 2), fill = COLOR_AXES)
+ # Draw arm.
+ m = self.cake_arm_model
+ f = m.arm_cyl.pos
+ for x, y, pos in ((m.far_x, m.far_y, m.far_cyl.pos),
+ (m.near_x, m.near_y, m.near_cyl.pos)):
+ e = (y - 140) * f + 140
+ gray = pos * 0x40
+ fill = '#%02x%02x%02x' % (gray, gray, gray)
+ self.draw_polygon ((x - 20, 140), (x - 20, e), (x + 20, e),
+ (x + 20, 140), fill = fill)
# Extends.
simu.inter.drawable.Drawable.draw (self)