def move_absolute_point(self, point):
        move_offset_x = (0 if self.config["move_offset_x"] is None else
                         self.config["move_offset_x"])
        move_offset_y = (0 if self.config["move_offset_y"] is None else
                         self.config["move_offset_y"])
        move_z = 0 if self.config["move_z"] is None else self.config["move_z"]

        point_desc = ("{} of type {}".format(
            point["name"], point["pointer_type"]) if "name" in point else "")

        log(
            "Move absolute to {} ({}, {}) with offset ({}, {}) and move_z {}".
            format(point_desc, point["x"], point["y"], move_offset_x,
                   move_offset_y, move_z),
            title="move_absolute_point",
        )

        if Logger.LOGGER_LEVEL < 2:
            device.move_absolute(
                location=device.assemble_coordinate(point["x"], point["y"],
                                                    move_z),
                offset=device.assemble_coordinate(move_offset_x, move_offset_y,
                                                  0),
                speed=self.config["move_speed"],
            )
def moveAbs(x, y, z):
    device.log('Moving to ' + str(x) + ', ' + str(y) + ', ' + str(z), 'success', ['toast'])
    device.move_absolute(
        {
            'kind': 'coordinate',
            'args': {'x': x, 'y': y, 'z': z}
        },
        100,
        {
            'kind': 'coordinate',
            'args': {'x': 0, 'y': 0, 'z': 0}
        }
    )
Exemple #3
0
 def moveto_smart(self, target: Union[Coordinate, Tool, Dict[str, int]], speed: int = 100, offset_x: int = 0, offset_y: int = 0, offset_z: int = 0, travel_height: Optional[int] = 0,
                  proximity_range: int = 20) -> Coordinate:
     """
     Perform a smart movement to the given point.
     :returns The previous position
     """
     position = self.bot_state().location_data.position
     if not self.debug:
         if isinstance(target, Tool):
             target = self.get_toolslots(tool_id=target.id)[0]
         if not isinstance(target, Coordinate):
             target = position.merge(target)
         if (travel_height is not None) and (travel_height > position.z or travel_height > target.z) and (
                 abs(position.x - target.x) > proximity_range or abs(position.y - target.y) > proximity_range):
             # travel height must be respected
             if target.z + offset_z > travel_height:
                 travel_height = target.z + offset_z
             device.move_relative(0, 0, travel_height - position.z, speed)
             device.move_absolute(target.merge({'z': travel_height}).to_coordinate(), speed, device.assemble_coordinate(offset_x, offset_y, 0))
             if abs((target.z + offset_z) - travel_height) <= 2:
                 return position
         device.move_absolute(target.to_coordinate(), speed, device.assemble_coordinate(offset_x, offset_y, offset_z))
     return position
Exemple #4
0
alternateInBetweenGrid1 = get_config_value(farmware_name='Grid2Grid30Sec', config_name='alternateInBetweenGrid1', value_type=int)
startLastRowOfGrid1 = get_config_value(farmware_name='Grid2Grid30Sec', config_name='startLastRowOfGrid1', value_type=int)

rowsGrid2 = get_config_value(farmware_name='Grid2Grid30Sec', config_name='rowsGrid2', value_type=int)
colsGrid2 = get_config_value(farmware_name='Grid2Grid30Sec', config_name='colsGrid2', value_type=int)
spaceBetweenRowsGrid2 = get_config_value(farmware_name='Grid2Grid30Sec', config_name='spaceBetweenRowsGrid2', value_type=float)
spaceBetweenColsGrid2 = get_config_value(farmware_name='Grid2Grid30Sec', config_name='spaceBetweenColsGrid2', value_type=float)
startXGrid2 = get_config_value(farmware_name='Grid2Grid30Sec', config_name='startXGrid2', value_type=float)
startYGrid2 = get_config_value(farmware_name='Grid2Grid30Sec', config_name='startYGrid2', value_type=float)
startZGrid2 = get_config_value(farmware_name='Grid2Grid30Sec', config_name='startZGrid2', value_type=float)
alternateInBetweenGrid2 = get_config_value(farmware_name='Grid2Grid30Sec', config_name='alternateInBetweenGrid2', value_type=int)

device.log(message='Done params', message_type='success')

device.move_absolute(
device.assemble_coordinate(100, 100, 0),
100,
device.assemble_coordinate(0, 0, 0))

# Initialise row (X) and column (Y) indexes for all grids
rowGrid1Index = 0
colGrid1Index = 0
rowGrid2Index = 0
colGrid2Index = 0

# Initialise the current Position Found flags to not found
currentPositionGrid1Found = False
currentPositionGrid2Found = False

# Set constant Z positions
zPosGrid1 = startZGrid1
zPosGrid2 = startZGrid2
 def move_abs(self, speed=None):
     if speed:
         self.set_speed(speed)
     device.move_absolute(self.coordinate_node, self.speed,
                          self.offset_node)
Exemple #6
0
            grid2Coordinates.append(gridPosition2)

# Check the number of items in both lists are the same
device.log(message='grid1Coordinates: ' + str(len(grid1Coordinates)) + ' grid2Coordinates:' + str(len(grid2Coordinates)), message_type='success')           

# Now move 
for plant in range(numberOfPlants):
    if canMove == True :
        # 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',
Exemple #7
0
        and (xIndex >= xAxisCount - 1)) :               # on the last x position as an alternateInBetween which has 1 less x position
            yPosGrid1 = yPosGrid1 + spaceBetweenYGrid1  # Bump up the Y position to the next row
            xPosGrid1 = startXGrid1                     # Set the X position back to the start of a non alternateInBetween
            device.log(message='alternateInBetweenGrid1 last row', message_type='success')

        if (startOfXSlopeGrid1 != 0) and (sineOfAngleXGrid1 != 0) :
            hypotenuseGrid1 = xPosGrid1 - startOfXSlopeGrid1
            addToZHeightGrid1 = sineOfAngleXGrid1 * hypotenuseGrid1

        if canMove :
            device.move_absolute(
                {
                    'kind': 'coordinate',
                    'args': {'x': xPosGrid1, 'y': yPosGrid1, 'z': addToZHeightGrid1}
                },
                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)

        # Grid 2
        if alternateInBetweenGrid2 == 1 :
            if yIndex > 0 and (yIndex % 2) > 0 :
                xPosGrid2 = startXGrid2 + (spaceBetweenXGrid2 * 0.5) + (spaceBetweenXGrid2 * xIndex)
            else :
Exemple #8
0
A simple Farmware example that tells FarmBot to log a new message including the provided input.
'''

from farmware_tools import get_config_value, device

INPUT_VALUE = get_config_value(
    farmware_name='Hello Farmware Test', config_name='input', value_type=str)
device.log(message='Hello Farmware! Test input was: {}'.format(
    INPUT_VALUE), message_type='success')
device.log(message="Message 1 Test", message_type="success")
device.log(message="Message 2 Test", message_type="success")
device.log(message="Message 3 Test", message_type="success")
device.log(message="Message 4 Test", message_type="success")
device.log(message="Message 5 Test", message_type="success")
zero = device.assemble_coordinate(0, 0, 0)
one = device.assemble_coordinate(10, 10, 0)
two = device.assemble_coordinate(20, 20, 0)
three = device.assemble_coordinate(30, 30, 0)
four = device.assemble_coordinate(40, 40, 0)
five = device.assemble_coordinate(50, 50, 0)

device.move_absolute(one, 100, zero)

device.move_absolute(two, 100, zero)

device.move_absolute(three, 100, zero)

device.move_absolute(four, 100, zero)

device.move_absolute(five, 100, zero)
Exemple #9
0
z_height = get_config_value('Move To Safe', 'safe_z')

pos_x = device.get_current_position('x')
pos_y = device.get_current_position('y')
pos_z = z_height

device.log('Moving to ' + str(pos_x) + ', ' + str(pos_y) + ', ' + str(pos_z),
           'success', ['toast'])

device.move_absolute(
    {
        'kind': 'coordinate',
        'args': {
            'x': pos_x,
            'y': pos_y,
            'z': pos_z
        }
    }, 100, {
        'kind': 'coordinate',
        'args': {
            'x': 0,
            'y': 0,
            'z': 0
        }
    })

device.log('success!!', 'success', ['toast'])

if __name__ == '__main__':
    farmware_name = 'move_to_safe'
Exemple #10
0
 def move_abs(self, speed=100):
     device.move_absolute(self.coordinate_node, speed, self.offset_node)
Exemple #11
0
#!/usr/bin/env python
'''
 ' Single Axis
'''

import os
from farmware_tools import device
from farmware_tools import app
from farmware_tools import get_config_value

# create Celery coordinate node
coord = device.assemble_coordinate(0, 0, 0)
# apply currrent positions to coordinate node
for axis in coord['args']:
    coord['args'][axis] = device.get_current_position(axis)
# get the desired axis to modify and set the coordinate node to the desired value
single_axis = get_config_value('Single Axis', 'axis', str).lower()
coord['args'][single_axis] = int(get_config_value('Single Axis', 'pos'))

#log = 'Axis: {}, Coordinate: {}'.format(single_axis, coord)
log = "Moving '%s' axis to %d" % (single_axis.upper(),
                                  coord['args'][single_axis])
device.log(log, 'info', ['toast'])
# perform the move
device.move_absolute(coord, 100, device.assemble_coordinate(0, 0, 0))
def move_absolute(position,offset,speed):
    as_position= device.assemble_coordinate(position[0],position[1],position[2])
    as_offset=device.assemble_coordinate(offset[0],offset[1],offset[2])
    device.move_absolute(as_position, speed=speed, offset=as_offset)