FAIRINO México
Soporte técnico

Base de conocimiento

Ejemplo de pick and place (SDK de Python)

Los ejemplos están escritos sobre la versión de software 3.8.2; algunas funciones y argumentos pueden cambiar, pero la estructura de fondo se mantiene.

TEN EN CUENTA QUE ESTO ES UN ESQUEMA O GUÍA, NO UN PROGRAMA LISTO PARA CORRER. VALIDA LA SEGURIDAD DE LOS PUNTOS Y DE LOS MOVIMIENTOS ANTES DE EJECUTAR CUALQUIER CÓDIGO EN EL ROBOT.

from fairino import Robot

import time

# Term index at bottom

#############################################

# Point table; {name: joint_pos} dictionary #

#############################################

points = {

 'home': [0, -90, 90, -90, -90, 0],

 'pick_pt_hover': [-50.469, -61.425, 97.799, -126.37, -90, -50.469],

 'place_pt_hover': [38.045, -48.84, 76.11, -117.27, -90, 38.045]

}

def pick_obj(robot: Robot.RPC):

 robot.MoveJ(points['home'], tool=0, user=0, vel=20, acc=20) # Move the robot home first to avoid unplanned trajectories

 robot.MoveJ(points['pick_pt_hover'], tool=0, user=0,vel=20, acc=20) # Move robot to hover point of target pick position

 e, curr = robot.GetActualTCPPose() # Gets the current CARTESIAN POSITION of the robot in format (error, [x,y,z,rx,ry,rz])

 curr[2] -= 50 # subtract 50 from the z of the current position, this will be our target

 robot.MoveGripper(1, 1000, 50, 50, 5000, 0) # Open gripper_1 to 100.0% at 50% speed, 50% force, with a timeout of 5 seconds

 time.sleep(2)

 robot.MoveL(curr, tool=0, user=0,vel=20, acc=20) # Move 50mm DOWN to target obj to grab

 robot.MoveGripper(1, 0, 50, 50, 5000, 0) # Close gripper_1 to 0.0% at 50% speed, 50% force, with a timeout of 5 seconds

 time.sleep(2)

 e, hover_as_cart = robot.GetForwardKin(points['pick_pt_hover']) # Gets the CARTESIAN coordinates of the hover position we came from

 robot.MoveL(hover_as_cart, tool=0, user=0, vel=20, acc=20) # Move LINEARLY back to hover point

 return

def place_obj(robot: Robot.RPC):

 robot.MoveJ(points['home'], tool=0, user=0,vel=20, acc=20) # Move the robot home first to avoid unplanned trajectories

 robot.MoveJ(points['place_pt_hover'], tool=0, user=0,vel=20, acc=20) # Move robot to hover point of target drop position

 e, curr = robot.GetActualTCPPose() # Gets the current CARTESIAN POSITION of the robot in format (error, [x,y,z,rx,ry,rz])

 curr[2] -= 50 # subtract 50 from the z of the current position. This will be manipulated to become our target

 robot.MoveL(curr, tool=0, user=0,vel=20, acc=20) # Move 50mm DOWN to target obj to grab

 robot.MoveGripper(1, 1000, 50, 50, 5000, 0) # Open gripper_1 to 100.0% at 50% speed, 50% force, with a timeout of 5 seconds

 time.sleep(2)

 e, hover_as_cart = robot.GetForwardKin(points['place_pt_hover']) # Gets the CARTESIAN coordinates from the joint values of the hover position we came from

 robot.MoveL(hover_as_cart, tool=0, user=0,vel=20, acc=20) # Move LINEARLY back to hover point

 return

def go_home(robot: Robot.RPC):

 error = robot.MoveJ(points['home'], tool=0, user=0,vel=20, acc=20) # Move back home

 return error

def main():

 robot = Robot.RPC('192.168.58.2') # Replace IP with your robot IP

 robot.ActGripper(1, 1) # Activate the gripper connected at the end of arm

 pick_obj(robot) # Runs routine to grab the object

 go_home(robot) # Return home to avoid any collisions before next routine

 place_obj(robot) # Runs the drop routine

 go_home(robot) # return home

if name == "__main__":

 main()

"""

 Term Index:

 - Hover point: a location that sets the robot slightly above target position. This is meant to

 avoid collisions with the target when moving and to ensure accurate and controlled approach.

 """

Traducido de la documentación de Fairino. Ante cualquier duda de seguridad, valida contra el manual del equipo y con tu asesor antes de mover el robot.

¿Sigues atorado?

Escríbenos con el número de serie y lo que ya intentaste. Contesta alguien que ha instalado estos equipos.

Pedir soporte