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.
-
robot
= <pyzenbo.modules.dialog_system.DialogSystem object>¶ Class that can be used to make Zenbo speak and listen, and to change the facial expressions.
-
utility
= <pyzenbo.modules.utility.Utility object>¶ Provides composite functions.
-
wheelLights
= <pyzenbo.modules.wheel_lights.WheelLights object>¶ Control wheel lights.
-
vision
= <pyzenbo.modules.vision_control.VisionControl object>¶ Provides visual functions.
-
lineFollower
= <pyzenbo.modules.line_follower.LineFollower object>¶ Provides line follower control functions.
-
sensor
= <pyzenbo.modules.sensor.Sensor object>¶ Provides sensor relate functions.
-
system
= <pyzenbo.modules.system.System object>¶ Provides system relate functions.
-
media
= <pyzenbo.modules.media.Media object>¶ Provides media relate functions.
-
property
on_state_change_callback
¶ Called when command state change in waiting queue.
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.
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.
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.
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.
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
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 stateInit: 0Connected: 1Disconnected: 2Retry_1: 3Retry_2: 4Retry_3: 5Failed: 6Closed: 7- Returns
a tuple it contain sender state and receive state
-