Exemple #1
0
def zap_weeds():
    device.execute(weeder_tool_retrieve_sequence_id)
    coord = Coordinate(device.get_current_position('x'),
                       device.get_current_position('y'))
    for weed_point in weed_points:
        coord.set_coordinate(z=Z_TRANSLATE)  # move up to translate height
        coord.set_coordinate(weed_point['x'] + LASER_OFFSET_X,
                             weed_point['y'] + LASER_OFFSET_Y)  # move to point
        coord.set_axis_position('z', ZAP_HEIGHT)  # move down to zapping height
        coord.set_offset(-(AREA_SIZE / 2),
                         -(AREA_SIZE / 2))  # offset x and y half of area
        coord.set_speed(ZAP_SPEED)
        device.write_pin(PIN_ZAPPER, 1, 0)
        for i in range(AREA_SIZE):
            if coord.get_offset_axis_position('x') > 0:
                #coord.set_offset_axis_position('x', -(AREA_SIZE / 2))
                for j in range(AREA_SIZE):
                    coord.set_offset_axis_position('x',
                                                   (AREA_SIZE / 2) - j - 1)
                    device.wait(ZAP_TIMEOUT)
            else:
                #coord.set_offset_axis_position('x', AREA_SIZE / 2)
                for j in range(AREA_SIZE):
                    coord.set_offset_axis_position('x',
                                                   -(AREA_SIZE / 2) + j + 1)
                    device.wait(ZAP_TIMEOUT)
            coord.set_offset_axis_position(
                'y',
                coord.get_offset_axis_position('y') + 1)
        device.write_pin(PIN_ZAPPER, 0, 0)
        coord.set_speed(100)
        coord.set_offset(0, 0)
        coord.set_coordinate(z=Z_TRANSLATE)
    device.execute(weeder_tool_return_sequence_id)
Exemple #2
0
 def execute_sequence(self, sequence: Union[Sequence, str, int, None]):
     if sequence is not None:
         if not isinstance(sequence, Sequence):
             sequence = _get_sequences()[sequence]
         device.log(F"Executing sequence {sequence.name}")
         if not self.debug:
             device.execute(sequence.id)
 def execute_sequence_before(self):
     if len(self.config["sequence_beforemove_dic"]) != 0:
         for s in self.config["sequence_beforemove_dic"]:
             log(
                 "Execute Sequence: {} id: {}".format(
                     s, self.config["sequence_beforemove_dic"][s]),
                 title="execute_sequence_before",
             )
             if Logger.LOGGER_LEVEL < 2:
                 device.execute(
                     sequence_id=self.config["sequence_beforemove_dic"][s])
     else:
         log("Nothing to execute", title="execute_sequence_before")
Exemple #4
0
def take_readings():
    plants_chosen = []
    device.execute(moisture_tool_retrieve_sequence_id)
    #coord = Coordinate(device.get_current_position('x'), device.get_current_position('y'), Z_TRANSLATE)
    #device.log('Creating Coordinate')
    bot = Coordinate(device.get_current_position('x'),
                     device.get_current_position('y'))
    bot.set_offset(OFFSET_X, OFFSET_Y,
                   move_abs=False)  # sets the offset, auto-move disabled
    #device.log('BOT: {}'.format(bot))
    for i in range(NUM_SITES):
        rand_plant_num = randint(0, len(target_plants) - 1)
        while rand_plant_num in plants_chosen:
            rand_plant_num = randint(0, len(target_plants) - 1)
        plants_chosen.append(rand_plant_num)
        rand_plant = target_plants[rand_plant_num]
        device.log('Random Plant: {}'.format(json.dumps(rand_plant)))

        bot.set_axis_position(
            'z', Z_TRANSLATE
        )  # sets the z axis to translate height, auto-move enabled
        bot.set_coordinate(
            rand_plant['x'],
            rand_plant['y'])  # set the plant coordinate, auto-move enabled
        bot.set_axis_position(
            'z', SENSOR_Z_DEPTH)  # plunge sensor into soil, auto-move enabled
        # take reading(s)
        site_readings = []
        for j in range(NUM_SAMPLES):
            device.read_pin(PIN_SENSOR, 'Sensor', 1)
            site_readings.append(device.get_pin_value(PIN_SENSOR))
            device.wait(100)
        average = 0
        for reading in site_readings:
            average += reading
        average /= NUM_SAMPLES
        moisture_readings.append(average)
        device.log('Site Reading #{}: {}'.format(i, average), 'success')
    bot.set_axis_position('z', Z_TRANSLATE)
    device.log('Readings: {}'.format(json.dumps(moisture_readings)), 'success')
    device.execute(moisture_tool_return_sequence_id)
Exemple #5
0
def response():
    average = 0
    for i in moisture_readings:
        average += i
    average /= len(moisture_readings)
    device.log('Total Moisture Average: {}'.format(average), 'info')
    if average < THRESHOLD:
        device.execute(water_tool_retrieve_sequence_id)
        device.execute(water_sequence_id)
        device.execute(water_tool_return_sequence_id)
Exemple #6
0
        # Move Grid 1
        grid1Item = grid1Coordinates[plant]
        device.move_absolute(
            {
                'kind': 'coordinate',
                'args': {'x': grid1Item.xPosition, 'y': grid1Item.yPosition, 'z': grid1Item.zPosition}
            },
            100,
            {
                'kind': 'coordinate',
                'args': {'x': 0, 'y': 0, 'z': 0}
            }
        )
        if sequenceAfter1stGridMoveId > 0 :
            device.log(message='Execute sequence: ' + sequenceAfter1stGridMove, message_type='success')
            device.execute(sequenceAfter1stGridMoveId)
            time.sleep(waitSeconds)

        # Move Grid 2
        grid2Item = grid2Coordinates[plant]
        device.move_absolute(
            {
                'kind': 'coordinate',
                'args': {'x': grid2Item.xPosition, 'y': grid2Item.yPosition, 'z': grid2Item.zPosition}
            },
            100,
            {
                'kind': 'coordinate',
                'args': {'x': 0, 'y': 0, 'z': 0}
            }
        )