rcute_cozmars.robot

There are three different modes to connect and control the robot:

  • Robot executes each command sequentially in a blocking manner.
  • AsyncRobot executes commands in non-blocking manner, concurrent.futures.Future objects are returned for time-consuming commands.
  • AioRobot works with asyncio, it executes commands asynchronously in async/await style.

警告

The robot accepts only one connection the same time. If Scratch is controlling Cozmars, the Python program will not be able to connect, and vice versa

class rcute_cozmars.robot.AioRobot(serial_or_ip=None)

Async/await mode of Cozmars robot

参数:serial_or_ip (str) – IP address or serial number of Cozmars to connect. Default to None, in which case the program will automatically detect the robot on connection if there’s only one found.
on_camera_image = None

Callback funciton. After show_camera_view() is called, on_camera_image will be called every time camera feed receives an new image. The callback must take the captured image as input and return processd image.

classmethod get_animation_list()
eyes

eye animation on screen

env

Environmental Variables

touch_sensor
ir_sensors

Infrared sensors at the bottom of the robot

sonar

Sonar, namely ultrasonic distance sensor

lights

Builtin RGB LEDs on the sonar module

motors
head
lift
speaker
screen
camera
microphone
connected
latest_camera_view

latest image from show_camera_view()

hostname

Cozmars URL

ip

Cozmars’ IP address

firmware_version

Cozmars firmware version

mac

Cozmars MAC address

serial

Cozmars serial number

animate(name, *args, **kwargs)

perform animation

参数:name (str) – the name of the animation
backward(duration=None)
参数:duration (float) – duration (seconds), default is None for non-stop
close_camera_view()

Stop the background thread created in show_camera_view()

connect()
disconnect()
forward(duration=None)
参数:duration (float) – duration (seconds), default is None for non-stop
listen(**kw)

Speech recognition.

参数:lang (str) – language, default to ‘en’
返回:recognized string
返回类型:str

other paramters are the same as rcute_ai.STT.stt ‘s keyword arguments.

rcute-ai must be installed to support this function.

poweroff()
reboot()
say(txt, repeat=1, **options)

Text to speach for Cozmars V2.

rcute-ai must be installed to support this function.

参数:
  • txt (str) – text to be said
  • repeat (int, optional) – playback times, default is 1
  • options (optional) –
    • voice/lang
    • volume
    • pitch
    • speed
    • word_gap

    See rcute_ai.tts

show_camera_view()

Open camera and run a background thread showing the camera view or processed camera images if on_camera_image is set

stop()
turn_left(duration=None)
参数:duration (float) – duration (seconds), default is None for non-stop
turn_right(duration=None)
参数:duration (float) – duration (seconds), default is None for non-stop
when_called

Callback function, called when the wake word ‘R-Cute’ or Chinese ‘阿Q’ is detected.

When set, a thread will be running in background using the robot’s microphone. If set to None, the background thread will stop.

rcute-ai must be installed to support this function.

See rcute_ai.WakeWordDetector

class rcute_cozmars.robot.Robot(serial_or_ip=None)

Cozmars robot synchronization mode

参数:serial_or_ip (str) – IP address or serial number of Cozmars to connect. Default to None, in which case the program will automatically detect the robot on connection if there’s only one found.
connect()
disconnect()
animate(name, *args, **kwargs)

perform animation

参数:name (str) – the name of the animation
backward(duration=None)
参数:duration (float) – duration (seconds), default is None for non-stop
camera
close_camera_view()

Stop the background thread created in show_camera_view()

connected
env

Environmental Variables

eyes

eye animation on screen

firmware_version

Cozmars firmware version

forward(duration=None)
参数:duration (float) – duration (seconds), default is None for non-stop
classmethod get_animation_list()
head
hostname

Cozmars URL

ip

Cozmars’ IP address

ir_sensors

Infrared sensors at the bottom of the robot

latest_camera_view

latest image from show_camera_view()

lift
lights

Builtin RGB LEDs on the sonar module

listen(**kw)

Speech recognition.

参数:lang (str) – language, default to ‘en’
返回:recognized string
返回类型:str

other paramters are the same as rcute_ai.STT.stt ‘s keyword arguments.

rcute-ai must be installed to support this function.

mac

Cozmars MAC address

microphone
motors
poweroff()
reboot()
say(txt, repeat=1, **options)

Text to speach for Cozmars V2.

rcute-ai must be installed to support this function.

参数:
  • txt (str) – text to be said
  • repeat (int, optional) – playback times, default is 1
  • options (optional) –
    • voice/lang
    • volume
    • pitch
    • speed
    • word_gap

    See rcute_ai.tts

screen
serial

Cozmars serial number

show_camera_view()

Open camera and run a background thread showing the camera view or processed camera images if on_camera_image is set

sonar

Sonar, namely ultrasonic distance sensor

speaker
stop()
touch_sensor
turn_left(duration=None)
参数:duration (float) – duration (seconds), default is None for non-stop
turn_right(duration=None)
参数:duration (float) – duration (seconds), default is None for non-stop
when_called

Callback function, called when the wake word ‘R-Cute’ or Chinese ‘阿Q’ is detected.

When set, a thread will be running in background using the robot’s microphone. If set to None, the background thread will stop.

rcute-ai must be installed to support this function.

See rcute_ai.WakeWordDetector

class rcute_cozmars.robot.AsyncRobot(serial_or_ip=None)

Asynchronous (concurrent.futures.Future) mode of the Cozmars robot

参数:serial_or_ip (str) – IP address or serial number of Cozmars to connect. Default to None, in which case the program will automatically detect the robot on connection if there’s only one found.
animate(name, *args, **kwargs)

perform animation

参数:name (str) – the name of the animation
backward(duration=None)
参数:duration (float) – duration (seconds), default is None for non-stop
camera
close_camera_view()

Stop the background thread created in show_camera_view()

connect()
connected
disconnect()
env

Environmental Variables

eyes

eye animation on screen

firmware_version

Cozmars firmware version

forward(duration=None)
参数:duration (float) – duration (seconds), default is None for non-stop
classmethod get_animation_list()
head
hostname

Cozmars URL

ip

Cozmars’ IP address

ir_sensors

Infrared sensors at the bottom of the robot

latest_camera_view

latest image from show_camera_view()

lift
lights

Builtin RGB LEDs on the sonar module

listen(**kw)

Speech recognition.

参数:lang (str) – language, default to ‘en’
返回:recognized string
返回类型:str

other paramters are the same as rcute_ai.STT.stt ‘s keyword arguments.

rcute-ai must be installed to support this function.

mac

Cozmars MAC address

microphone
motors
poweroff()
reboot()
say(txt, repeat=1, **options)

Text to speach for Cozmars V2.

rcute-ai must be installed to support this function.

参数:
  • txt (str) – text to be said
  • repeat (int, optional) – playback times, default is 1
  • options (optional) –
    • voice/lang
    • volume
    • pitch
    • speed
    • word_gap

    See rcute_ai.tts

screen
serial

Cozmars serial number

show_camera_view()

Open camera and run a background thread showing the camera view or processed camera images if on_camera_image is set

sonar

Sonar, namely ultrasonic distance sensor

speaker
stop()
touch_sensor
turn_left(duration=None)
参数:duration (float) – duration (seconds), default is None for non-stop
turn_right(duration=None)
参数:duration (float) – duration (seconds), default is None for non-stop
when_called

Callback function, called when the wake word ‘R-Cute’ or Chinese ‘阿Q’ is detected.

When set, a thread will be running in background using the robot’s microphone. If set to None, the background thread will stop.

rcute-ai must be installed to support this function.

See rcute_ai.WakeWordDetector