pyzenbo.py_zenbo_sdk module

class pyzenbo.py_zenbo_sdk.PyZenbo(destination, on_state_change_callback=None, on_result_callback=None)

Bases: object

Python Zenbo SDK, this SDK provides a interface to zenbo robot features.

motion = <pyzenbo.modules.motion.Motion object>

Provides body movement and head control.

pyzenbo.modules.motion()

robot = <pyzenbo.modules.dialog_system.DialogSystem object>

Class that can be used to make Zenbo speak and listen, and to change the facial expressions.

pyzenbo.modules.dialog_system()

utility = <pyzenbo.modules.utility.Utility object>

Provides composite functions.

pyzenbo.modules.utility()

wheelLights = <pyzenbo.modules.wheel_lights.WheelLights object>

Control wheel lights.

pyzenbo.modules.wheel_lights()

vision = <pyzenbo.modules.vision_control.VisionControl object>

Provides visual functions.

pyzenbo.modules.vision_control()

lineFollower = <pyzenbo.modules.line_follower.LineFollower object>

Provides line follower control functions.

pyzenbo.modules.line_follower()

sensor = <pyzenbo.modules.sensor.Sensor object>

Provides sensor relate functions.

pyzenbo.modules.sensor()

system = <pyzenbo.modules.system.System object>

Provides system relate functions.

pyzenbo.modules.system()

media = <pyzenbo.modules.media.Media object>

Provides media relate functions.

pyzenbo.modules.media()

property on_state_change_callback

Called when command state change in waiting queue.

Usage
def on_state_change(serial, cmd, error, state):
    msg = 'on_state_change serial:{}, cmd:{}, error:{}, state:{}'
    print(msg.format(serial, cmd, error_code.code_to_description(error), state))

sdk = pyzenbo.connect(host_ip)
sdk.on_state_change_callback = on_state_change
property on_result_callback

Called when a robot command sending result.

Usage
def on_result(**kwargs):
    print('on_result', kwargs)

sdk = pyzenbo.connect(host_ip)
sdk.on_result_callback = on_result
property on_vision_callback

Called when vision service sending result.

Usage
def on_vision_callback(**kwargs):
    print('on_vision_callback', kwargs)

sdk = pyzenbo.connect(host_ip)
sdk.on_vision_callback = on_vision_callback
release()

Release all robot API resource. After finished using SDK, must call this function to disconnect the connection.

Returns

None

cancel_command(command, sync=True, timeout=None)

Cancel specific robot motion/utility command.

Usage
sdk = pyzenbo.connect(host_ip)
sdk.motion.move_body(10, 0, 0, 2, sync=False)
sdk.cancel_command(zenbo_command.MOTION_MOVE_BODY)
Parameters
  • command – specifies the command number to cancel

  • sync – True if this command is blocking

  • timeout – maximum blocking time in second, None means infinity

Returns

serial number of the command, if command is blocking also return a dict, it include two key, ‘state’ indicate execute result and ‘error’ will contain error code

cancel_command_by_serial(serial, sync=True, timeout=None)

Cancel specific robot motion/utility command by using the serial number.

Usage
sdk = pyzenbo.connect(host_ip)
serial = sdk.motion.move_body(10, 0, 0, 2, sync=False)[0]
sdk.cancel_command_by_serial(serial)
Parameters
  • serial – specifies the command serial number to cancel

  • sync – True if this command is blocking

  • timeout – maximum blocking time in second, None means infinity

Returns

serial number of the command, if command is blocking also return a dict, it include two key, ‘state’ indicate execute result and ‘error’ will contain error code

cancel_command_all(sync=True, timeout=None)

Cancel all robot motion/utility commands

Usage
sdk = pyzenbo.connect(host_ip)
sdk.motion.move_body(10, 0, 0, 2, sync=False)
sdk.cancel_command_all()
Parameters
  • sync – True if this command is blocking

  • timeout – maximum blocking time in second, None means infinity

Returns

serial number of the command, if command is blocking also return a dict, it include two key, ‘state’ indicate execute result and ‘error’ will contain error code

get_connection_state()

Get current connection state.

Socket state
Init: 0
Connected: 1
Disconnected: 2
Retry_1: 3
Retry_2: 4
Retry_3: 5
Failed: 6
Closed: 7
Returns

a tuple it contain sender state and receive state