Python Examples

Lua API

Control task execution by sending Lua API to TCP port 5180

import socket

client = socket.socket()
client.connect(('127.0.0.1', 5180))
client.send("scene(10087)".encode())

client.close()

SDK

Control task execution by downloading and installing the SDK

lebai_sdk

import lebai_sdk

# # If you encounter RuntimeError related to event loop, try adding these 2 lines
# import nest_asyncio
# nest_asyncio.apply()

lebai_sdk.init()

def main():
    # print(lebai_sdk.discover_devices(2)) # Discover robots in the same LAN

    robot_ip = "192.168.x.x" # Set robot IP address, need to modify according to actual robot IP
    lebai = lebai_sdk.connect(robot_ip, False) # Create instance
    lebai.start_sys() # Start arm
    joint_pose = [0,-1.05,1.05,0,1.57,0] # Target joint pose data
    cartesian_pose = {'x' : -0.383, 'y' : -0.121, 'z' : 0.36, 'rz' : -1.57, 'ry' : 0, 'rx' : 1.57} # Target Cartesian pose data
    a = 0.5 # Joint acceleration (rad/s2)
    v = 0.2 # Joint velocity (rad/s)
    t = 0   # Motion time (s). When t > 0, velocity v and acceleration a parameters are invalid
    r = 0   # Blending radius (m). Used to specify path smoothing effect
    lebai.movej(joint_pose,a,v,t,r) # Joint motion https://help.lebai.ltd/sdk/motion.html#joint-motion
    a = 0.3 # Space acceleration (m/s2)
    v = 0.1 # Space velocity (m/s)
    t = 0   # Motion time (s). When t > 0, velocity v and acceleration a parameters are invalid
    r = 0   # Blending radius (m). Used to specify path smoothing effect
    lebai.movel(cartesian_pose,a,v,t,r) # Linear motion https://help.lebai.ltd/sdk/motion.html#linear-motion
    lebai.wait_move() # Wait for motion completion
    # scene_number = "10000" # Scene number to call
    # lebai.start_task(scene_number, None, None, False, 1) # Call scene
    lebai.stop_sys() # Stop arm

main()

lebai_sdk_asyncio

import asyncio
import lebai_sdk

lebai_sdk.init()

async def main():
    # print(await lebai_sdk.discover_devices(2)) # Discover robots in the same LAN

    robot_ip = "192.168.x.x" # Set robot IP address, need to modify according to actual robot IP
    lebai = await lebai_sdk.connect(robot_ip, False) # Create instance
    await lebai.start_sys() # Start arm
    joint_pose = [0,-1.05,1.05,0,1.57,0] # Target joint pose data
    cartesian_pose = {'x' : -0.383, 'y' : -0.121, 'z' : 0.36, 'rz' : -1.57, 'ry' : 0, 'rx' : 1.57} # Target Cartesian pose data
    a = 0.5 # Joint acceleration (rad/s2)
    v = 0.2 # Joint velocity (rad/s)
    t = 0   # Motion time (s). When t > 0, velocity v and acceleration a parameters are invalid
    r = 0   # Blending radius (m). Used to specify path smoothing effect
    await lebai.movej(joint_pose,a,v,t,r) # Joint motion https://help.lebai.ltd/sdk/motion.html#joint-motion
    a = 0.3 # Space acceleration (m/s2)
    v = 0.1 # Space velocity (m/s)
    t = 0   # Motion time (s). When t > 0, velocity v and acceleration a parameters are invalid
    r = 0   # Blending radius (m). Used to specify path smoothing effect
    await lebai.movel(cartesian_pose,a,v,t,r) # Linear motion https://help.lebai.ltd/sdk/motion.html#linear-motion
    await lebai.wait_move() # Wait for motion completion
    # scene_number = "10000" # Scene number to call
    # await lebai.start_task(scene_number, None, None, False, 1) # Call scene
    await lebai.stop_sys() # Stop arm

asyncio.run(main())