Exemple #1
0
class Bag:

    OUTPUT_UPPER_CLAMP_OPEN = 1
    OUTPUT_UPPER_CLAMP_OUT = 2
    OUTPUT_UPPER_CLAMP_IN = 3
    OUTPUT_UPPER_CLAMP_DOWN = 4
    OUTPUT_UPPER_CLAMP_UP = 5
    OUTPUT_DOOR_OPEN = 6
    OUTPUT_DOOR_CLOSE = 7
    OUTPUT_LOWER_CLAMP_1_CLOSE = 8
    OUTPUT_LOWER_CLAMP_2_CLOSE = 9

    def __init__ (self, scheduler, table, link_bag):
        self.color_switch = Switch (link_bag.io_hub.contact[0], invert = True)
        self.color_switch.state = random.choice ((False, True))
        self.color_switch.notify ()
        self.jack = Switch (link_bag.io_hub.contact[1], invert = True)
        self.strat_switch = Switch (link_bag.io_hub.contact[2], invert = True)
        self.nb_robots_switch = Switch (link_bag.io_hub.contact[12], invert = True)
        self.beacon = RoundObstacle (40, 5)
        table.obstacles.append (self.beacon)
        self.position = Position (link_bag.asserv.position, [ self.beacon ])
        output = link_bag.io_hub.output
        contact = [ Switch (c) for c in link_bag.io_hub.contact[3:12] ]
        self.clamps = Clamps (table, self.position, link_bag.mimot.aux[0],
                (PneumaticCylinder (output[self.OUTPUT_LOWER_CLAMP_1_CLOSE],
                    None, scheduler, 0., 30., 150., 75., 30.),
                PneumaticCylinder (output[self.OUTPUT_LOWER_CLAMP_2_CLOSE],
                    None, scheduler, 0., 30., 150., 75., 30.)),
                contact[0:2], contact[8],
                PneumaticCylinder (output[self.OUTPUT_UPPER_CLAMP_DOWN],
                    output[self.OUTPUT_UPPER_CLAMP_UP], scheduler,
                    0., 1., 1., 1., 1., contact[2], contact[3]),
                PneumaticCylinder (output[self.OUTPUT_UPPER_CLAMP_IN],
                    output[self.OUTPUT_UPPER_CLAMP_OUT], scheduler,
                    0., 1., 1., 1., 0.),
                PneumaticCylinder (None, output[self.OUTPUT_UPPER_CLAMP_OPEN],
                    scheduler, 0., 30., 150., 75., 30.),
                PneumaticCylinder (output[self.OUTPUT_DOOR_CLOSE],
                    output[self.OUTPUT_DOOR_OPEN], scheduler,
                    0., 1., 1., 1., 1., contact[5], contact[4])
                )
        self.distance_sensor = [
                DistanceSensorSensopart (link_bag.io_hub.adc[0], scheduler, table,
                    (150, 0), 0, (self.position, ), 4, factor = 5),
                DistanceSensorSensopart (link_bag.io_hub.adc[1], scheduler, table,
                    (50, 147), 0, (self.position, ), set ([3, 4]), factor = 5),
                DistanceSensorSensopart (link_bag.io_hub.adc[2], scheduler, table,
                    (50, -147), 0, (self.position, ), set ([3, 4]), factor = 5),
                DistanceSensorSensopart (link_bag.io_hub.adc[3], scheduler, table,
                    (-120, 0), pi, (self.position, ), 4, factor = 5),
                ]
        self.path = link_bag.io_hub.path
        self.pos_report = link_bag.io_hub.pos_report
        self.debug_draw = link_bag.io_hub.debug_draw
Exemple #2
0
class Bag:

    def __init__ (self, scheduler, table, link_bag):
        self.color_switch = Switch (link_bag.io_hub.contact[0], invert = True)
        self.color_switch.state = random.choice ((False, True))
        self.color_switch.notify ()
        self.jack = Switch (link_bag.io_hub.contact[1], invert = True)
        self.strat_switch = Switch (link_bag.io_hub.contact[9], invert = True)
        self.contact = [ Switch (contact)
                for contact in link_bag.io_hub.contact[2:9] ]
        self.beacon = RoundObstacle (40, 5)
        table.obstacles.append (self.beacon)
        self.position = Position (link_bag.asserv.position, [ self.beacon ])
        self.clamping_motor = MotorBasic (link_bag.io_hub.pwm[2], scheduler,
                8 * pi, 0, pi)
        self.door_motors = [ MotorBasic (link_bag.io_hub.pwm[i], scheduler,
            8 * pi, 0, 0.5 * pi) for i in (0, 1, 3, 4) ]
        self.clamp = Clamp (table, self.position, link_bag.mimot.aux[0],
                link_bag.mimot.aux[1], self.clamping_motor, self.door_motors,
                self.contact[0:7], link_bag.io_hub.codebar)
        def distance_sensor_exclude (o):
            return o is self.beacon
        self.distance_sensor = [
                DistanceSensorSensopart (link_bag.io_hub.adc[0], scheduler, table,
                    (20, 20), pi * 10 / 180, (self.position, ), 5,
                    distance_sensor_exclude, factor = 5),
                DistanceSensorSensopart (link_bag.io_hub.adc[1], scheduler, table,
                    (20, -20), -pi * 10 / 180, (self.position, ), 5,
                    distance_sensor_exclude, factor = 5),
                DistanceSensorSensopart (link_bag.io_hub.adc[2], scheduler, table,
                    (-20, -20), pi + pi * 10 / 180, (self.position, ), 5,
                    distance_sensor_exclude, factor = 5),
                DistanceSensorSensopart (link_bag.io_hub.adc[3], scheduler, table,
                    (-20, 20), pi - pi * 10 / 180, (self.position, ), 5,
                    distance_sensor_exclude, factor = 5),
                ]
        self.path = link_bag.io_hub.path
        self.pos_report = link_bag.io_hub.pos_report
Exemple #3
0
 def __init__ (self, scheduler, table, link_bag):
     self.table = table
     self.color_switch = Switch (link_bag.ihm_color, invert = True)
     self.color_switch.state = random.choice ((False, True))
     self.color_switch.notify ()
     self.jack = Switch (link_bag.raw_jack, invert = True)
     self.strat_switch = Switch (link_bag.ihm_strat, invert = True)
     self.robot_nb_switch = Switch (link_bag.ihm_robot_nb, invert = True)
     self.beacon = RoundObstacle (40, 5)
     table.obstacles.append (self.beacon)
     self.position = Position (link_bag.asserv.position, [ self.beacon ])
     usdist_f = 2040. / 3300
     self.distance_sensor = [
             DistanceSensorSensopart (link_bag.adc_dist[0], scheduler, table,
                 (102, 84), 0, (self.position, ), 4, factor = usdist_f),
             DistanceSensorSensopart (link_bag.adc_dist[1], scheduler, table,
                 (102, -84), 0, (self.position, ), 4, factor = usdist_f),
             DistanceSensorSensopart (link_bag.adc_dist[2], scheduler, table,
                 (-78, 104), pi, (self.position, ), 4, factor = usdist_f),
             DistanceSensorSensopart (link_bag.adc_dist[3], scheduler, table,
                 (-83, -120), pi, (self.position, ), 4, factor = usdist_f),
             ]
     self.cake_front = DistanceSensorTrig (link_bag.adc_cake_front,
             scheduler, table, (80, 136), pi / 2, (self.position, ), 0)
     self.cake_back = DistanceSensorTrig (link_bag.adc_cake_back,
             scheduler, table, (-66, 139), pi / 2, (self.position, ), 0)
     self.cake_arm = CakeArm (table, self.position,
             PneumaticCylinder (
                 link_bag.cake_arm_in,
                 link_bag.cake_arm_out,
                 scheduler, 0., 1., 2.5, 2.5, 1.),
             PneumaticCylinder (
                 link_bag.cake_push_far_in,
                 link_bag.cake_push_far_out,
                 scheduler, 0., 1., 10., 10., 0.),
             PneumaticCylinder (
                 link_bag.cake_push_near_in,
                 link_bag.cake_push_near_out,
                 scheduler, 0., 1., 10., 10., 0.),
             link_bag.cake_arm_out_contact, link_bag.cake_arm_in_contact)
     self.cannon = Cannon (table, self.position,
             PneumaticCylinder (
                 link_bag.cherry_plate_up,
                 link_bag.cherry_plate_down,
                 scheduler, 0., 1., 2.5, 2.5, 1.),
             PneumaticCylinder (
                 link_bag.cherry_plate_clamp_open,
                 link_bag.cherry_plate_clamp_close,
                 scheduler, 0., 1., 10., 10., 0.),
             (Switch (link_bag.cherry_plate_left_contact),
                 Switch (link_bag.cherry_plate_right_contact)),
             link_bag.io_hub.potentiometer)
     self.gifts_arm = GiftsArm (table, self.position,
             PneumaticCylinder (
                 link_bag.gift_in,
                 link_bag.gift_out,
                 scheduler, 0., 1., 10., 10., 0.))
     self.ballon = PneumaticCylinder (None, link_bag.ballon_funny_action,
             scheduler, 0., 1., .1, .1, 0.)
     self.path = link_bag.io_hub.path
     self.pos_report = link_bag.io_hub.pos_report
     self.debug_draw = link_bag.io_hub.debug_draw