Initialize Instance
WARNING
Due to unstable communication and other reasons, errors may occur. In most cases, you need to use the error handling mechanism to catch errors and prevent abnormal exits.
Import SDK
lebai_sdk = require('lebai_sdk')
Initialize SDK
lebai_sdk.init()
SDK Version
version = lebai_sdk.version()
Get the SDK version number
- Returns
versionVersion number
Device Discovery
WARNING
This feature is based on mDNS technology and is not supported by the JavaScript SDK for Web frontend development
devices = lebai_sdk.discover_devices(time)
Continuously discover nearby devices during the duration, after the duration ends, return the name, IP, and MAC address of all nearby devices.
Parameters
timeDuration
Returns[{"name", "ip", "mac"}]
nameDevice nameipIP addressmacMAC address
Connect Device
lebai = lebai_sdk.connect(ip, simu)
Connect to LEBAI robot arm through IP addressing
Parameters
ipIP address of LEBAI robot armsimuWhether to connect in simulation mode. Optional, default is real machine mode
Returns
lebaiRobot arm instance, subsequent methods to control the robot arm need to use this instance
Get Connection Status
connected = lebai:is_connected()
- Returns
connectedWhether in connected state
Wait for Disconnection
disconnect_reason = lebai:wait_disconnect()
Block and wait for device disconnection. Commonly used for reconnection after device disconnection
- Returns
disconnect_reasonReason for device disconnection
Example Program
disconnect_reason = lebai:wait_disconnect()
print(disconnect_reason)
lebai = lebai_sdk.connect("192.168.2.3", false)
