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)
def execute_watering(self, duration_ms): pin = self.get_water_pin() if Logger.LOGGER_LEVEL < 2: log( "Water ON, wait {}ms, OFF on PIN {}".format(duration_ms, pin), title="execute_watering", ) # water on, wait, water off device.write_pin(pin, pin_value=1, pin_mode=0) device.wait(duration_ms) device.write_pin(pin, pin_value=0, pin_mode=0) else: log( "FAKE: Water ON, wait {}ms, OFF on PIN {}".format( duration_ms, pin), title="execute_watering", )
) if sequenceAfter2ndGridMoveId > 0 : device.log(message='Execute sequence: ' + sequenceAfter2ndGridMove, message_type='success') device.execute(sequenceAfter2ndGridMoveId) time.sleep(waitSeconds) moveCount += 1 if canMove == True and movesPerCycle > 0 and movesPerCycle == moveCount: # Turn the moves off and save the index device.log(message='Turn the moves off and save the index', message_type='success') canMove = False os.remove(configFileName) # Write the current position of the 2nd grids x,y co-ordinates to the config configContents = {evName: str(plant)} with open(configFileName, 'w') as f: json.dump(configContents, f) f.close() if plant < numberOfPlants : # If we aren't at the end of the loop then break out of the loop device.log(message='If we arent at the end of the loop then break out of the loop', message_type='success') loopBreaked = True break elif canMove == False and savedMoveIndex == plant: # Turn the moves on if we have reached the saved index device.log(message='Turn the moves on if we have reached the saved index', message_type='success') canMove = True # If loop finishes without breaking then signal that Grid2Grid has finished if loopBreaked == False : device.log(message='If loop finishes without breaking then signal that Grid2Grid has finished', message_type='success') device.write_pin(3,0,0) time.sleep(waitSeconds)
#!/usr/bin/env python ''' ' A farmware for a custom tool for Farmbot ''' import os, sys, json, Qualify from random import randint from farmware_tools import device, app, get_config_value from Coordinate import Coordinate PIN_LIGHTS = 7 PKG = 'Test Bed' input_errors = [] integer = Qualify.integer(PKG, 'integer') tools = app.get_toolslots() device.log(json.dumps(tools)) tool = Qualify.get_tool(4469) device.log(json.dumps(tool)) plants = app.get_plants() device.log(json.dumps(plants)) device.write_pin(PIN_LIGHTS, 0, 0)
moveAbs(seedToolX, seedToolY, seedToolZ) moveAbs(toolExtractX, seedToolY, seedToolZ) moveAbs(toolExtractX, seedToolY, toolExtractZ) for i in range(len(plantLocation)): #Get current location of arm current_arm_x = device.get_current_position('x') current_arm_y = device.get_current_position('y') current_arm_z = device.get_current_position('z') #Move to seed tray moveAbs(current_arm_x, current_arm_y, toolExtractZ) moveAbs(seedTrayX, current_arm_y, toolExtractZ) moveAbs(seedTrayX, seedTrayY, toolExtractZ) moveAbs(seedTrayX, seedTrayY, seedTrayDepth) #Turn on vac pump device.write_pin(10, 1, 0) #Extract from seed tray moveAbs(seedTrayX, seedTrayY, toolExtractZ) #Move to seeding location moveAbs(plantLocation[i][0] + pos_x, seedTrayY, toolExtractZ) moveAbs(plantLocation[i][0] + pos_x, plantLocation[i][1] + pos_y, toolExtractZ) moveAbs(plantLocation[i][0] + pos_x, plantLocation[i][1] + pos_y, pos_z - 10) #Turn off vac pump device.write_pin(10, 0, 0) #Extract from seed hole moveAbs(plantLocation[i][0] + pos_x, plantLocation[i][1] + pos_y, pos_z) moveAbs(toolExtractX, seedToolY, seedToolZ) moveAbs(seedToolX, seedToolY, seedToolZ)
#!/usr/bin/env python '''Farmware to reset encoder tracking on a v1.4 Farmduino.''' from farmware_tools import device device.set_pin_io_mode(1, 49) device.write_pin(49, 0, 0) device.write_pin(49, 1, 0) device.set_pin_io_mode(2, 49)