# SPDX-FileCopyrightText: 2024-present Kevin Ahr <meowmeowahr@gmail.com>## SPDX-License-Identifier: GPL-3.0-or-laterimporttimefromkevinbotlibimportSerialKevinbotrobot=SerialKevinbot()robot.connect("/dev/ttyAMA2",921600,5,1)whileTrue:time.sleep(1)
examples/core/connecting.py
1 2 3 4 5 6 7 8 910111213
# SPDX-FileCopyrightText: 2024-present Kevin Ahr <meowmeowahr@gmail.com>## SPDX-License-Identifier: GPL-3.0-or-laterimporttimefromkevinbotlibimportMqttKevinbotrobot=MqttKevinbot()robot.connect("kevinbot","localhost",1883)whileTrue:time.sleep(1)
Robot Enabling and Disabling
examples/core/enable_serial.py
1 2 3 4 5 6 7 8 910111213141516171819202122
# SPDX-FileCopyrightText: 2024-present Kevin Ahr <meowmeowahr@gmail.com>## SPDX-License-Identifier: GPL-3.0-or-laterimporttimefromkevinbotlibimportSerialKevinbotrobot=SerialKevinbot()robot.connect("/dev/ttyAMA2",921600,5,1)robot.request_enable()# Ask the core to enablewhilenotrobot.get_state().enabled:# Wait until the core is enabledtime.sleep(0.01)time.sleep(3)robot.request_disable()# Ask the core to disablewhilerobot.get_state().enabled:# Wait until the core is disabledtime.sleep(0.01)time.sleep(3)# Let the user see that the robot is disabled before disconnecting
examples/core/enable.py
1 2 3 4 5 6 7 8 910111213141516171819202122
# SPDX-FileCopyrightText: 2024-present Kevin Ahr <meowmeowahr@gmail.com>## SPDX-License-Identifier: GPL-3.0-or-laterimporttimefromkevinbotlibimportMqttKevinbotrobot=MqttKevinbot()robot.connect()robot.request_enable()# Ask the core to enablewhilenotrobot.get_state().enabled:# Wait until the core is enabledtime.sleep(0.01)time.sleep(3)robot.request_disable()# Ask the core to disablewhilerobot.get_state().enabled:# Wait until the core is disabledtime.sleep(0.01)time.sleep(3)# Let the user see that the robot is disabled before disconnecting
Robot Emergency Stop
examples/core/estop_serial.py
1 2 3 4 5 6 7 8 910
# SPDX-FileCopyrightText: 2024-present Kevin Ahr <meowmeowahr@gmail.com>## SPDX-License-Identifier: GPL-3.0-or-laterfromkevinbotlibimportSerialKevinbotrobot=SerialKevinbot()robot.connect("/dev/ttyAMA2",921600,5,1)robot.e_stop()
examples/core/estop.py
1 2 3 4 5 6 7 8 910
# SPDX-FileCopyrightText: 2024-present Kevin Ahr <meowmeowahr@gmail.com>## SPDX-License-Identifier: GPL-3.0-or-laterfromkevinbotlibimportMqttKevinbotrobot=MqttKevinbot()robot.connect()robot.e_stop()
Robot State Retrieval
examples/core/state_serial.py
1 2 3 4 5 6 7 8 91011121314
# SPDX-FileCopyrightText: 2024-present Kevin Ahr <meowmeowahr@gmail.com>## SPDX-License-Identifier: GPL-3.0-or-laterimporttimefromkevinbotlibimportSerialKevinbotrobot=SerialKevinbot()robot.connect("/dev/ttyAMA2",921600,5,1)whileTrue:print(robot.get_state())# noqa: T201time.sleep(1)
examples/core/state.py
1 2 3 4 5 6 7 8 91011121314
# SPDX-FileCopyrightText: 2024-present Kevin Ahr <meowmeowahr@gmail.com>## SPDX-License-Identifier: GPL-3.0-or-laterimporttimefromkevinbotlibimportMqttKevinbotrobot=MqttKevinbot()robot.connect()whileTrue:print(robot.get_state())# noqa: T201time.sleep(1)
Robot Timestamp Retrieval MQTT Only
examples/core/timestamp.py
1 2 3 4 5 6 7 8 91011121314
# SPDX-FileCopyrightText: 2024-present Kevin Ahr <meowmeowahr@gmail.com>## SPDX-License-Identifier: GPL-3.0-or-laterimporttimefromkevinbotlibimportMqttKevinbotrobot=MqttKevinbot()robot.connect()whileTrue:print(robot.ts)# noqa: T201time.sleep(1)
Robot Uptime Retrieval
examples/core/uptimes_serial.py
1 2 3 4 5 6 7 8 9101112131415
# SPDX-FileCopyrightText: 2024-present Kevin Ahr <meowmeowahr@gmail.com>## SPDX-License-Identifier: GPL-3.0-or-laterimporttimefromkevinbotlibimportSerialKevinbotrobot=SerialKevinbot()robot.connect("/dev/ttyAMA2",921600,5,1)whileTrue:print(f"Uptime (s) : {robot.get_state().uptime}")# noqa: T201print(f"Uptime (ms): {robot.get_state().uptime_ms}")# noqa: T201time.sleep(1)
examples/core/uptimes.py
1 2 3 4 5 6 7 8 9101112131415
# SPDX-FileCopyrightText: 2024-present Kevin Ahr <meowmeowahr@gmail.com>## SPDX-License-Identifier: GPL-3.0-or-laterimporttimefromkevinbotlibimportMqttKevinbotrobot=MqttKevinbot()robot.connect()whileTrue:print(f"Uptime (s) : {robot.get_state().uptime}")# noqa: T201print(f"Uptime (ms): {robot.get_state().uptime_ms}")# noqa: T201time.sleep(1)
Battery
Robot Battery Readings
examples/battery/readings_serial.py
1 2 3 4 5 6 7 8 910111213141516
# SPDX-FileCopyrightText: 2024-present Kevin Ahr <meowmeowahr@gmail.com>## SPDX-License-Identifier: GPL-3.0-or-laterimporttimefromkevinbotlibimportSerialKevinbotrobot=SerialKevinbot()robot.connect("/dev/ttyAMA2",921600,5,1)time.sleep(3)# Wait to get dataprint(f"Voltages: {robot.get_state().battery.voltages}")# noqa: T201print(f"Raw Voltages: {robot.get_state().battery.raw_voltages}")# noqa: T201print(f"States: {robot.get_state().battery.states}")# noqa: T201
examples/battery/readings.py
1 2 3 4 5 6 7 8 910111213141516
# SPDX-FileCopyrightText: 2024-present Kevin Ahr <meowmeowahr@gmail.com>## SPDX-License-Identifier: GPL-3.0-or-laterimporttimefromkevinbotlibimportMqttKevinbotrobot=MqttKevinbot()robot.connect()time.sleep(3)# Wait to get dataprint(f"Voltages: {robot.get_state().battery.voltages}")# noqa: T201print(f"Raw Voltages: {robot.get_state().battery.raw_voltages}")# noqa: T201print(f"States: {robot.get_state().battery.states}")# noqa: T201
# SPDX-FileCopyrightText: 2024-present Kevin Ahr <meowmeowahr@gmail.com>## SPDX-License-Identifier: GPL-3.0-or-laterimporttimefromkevinbotlibimportDrivebase,SerialKevinbotrobot=SerialKevinbot()robot.connect("/dev/ttyAMA2",921600,5,1)drive=Drivebase(robot)robot.request_enable()# Ask the core to enablewhilenotrobot.get_state().enabled:# Wait until the core is enabledtime.sleep(0.01)time.sleep(1)# Wait for data to arriveprint(f"Speeds: {drive.get_powers()}")# noqa: T201print(f"Watts: {drive.get_watts()}")# noqa: T201print(f"Amps: {drive.get_amps()}")# noqa: T201
examples/drive/status.py
1 2 3 4 5 6 7 8 910111213141516171819202122
# SPDX-FileCopyrightText: 2024-present Kevin Ahr <meowmeowahr@gmail.com>## SPDX-License-Identifier: GPL-3.0-or-laterimporttimefromkevinbotlibimportDrivebase,MqttKevinbotrobot=MqttKevinbot()robot.connect()drive=Drivebase(robot)robot.request_enable()# Ask the core to enablewhilenotrobot.get_state().enabled:# Wait until the core is enabledtime.sleep(0.01)time.sleep(1)# Wait for data to arriveprint(f"Speeds: {drive.get_powers()}")# noqa: T201print(f"Watts: {drive.get_watts()}")# noqa: T201print(f"Amps: {drive.get_amps()}")# noqa: T201
# SPDX-FileCopyrightText: 2024-present Kevin Ahr <meowmeowahr@gmail.com>## SPDX-License-Identifier: GPL-3.0-or-laterimporttimefromkevinbotlibimportDrivebase,SerialKevinbotrobot=SerialKevinbot()robot.connect("/dev/ttyAMA2",921600,5,1)drive=Drivebase(robot)input("LIFT THE WHEELS OFF THE GROUND FOR THIS TEST!!! [Return] to start test")robot.request_enable()# Ask the core to enablewhilenotrobot.get_state().enabled:# Wait until the core is enabledtime.sleep(0.01)time.sleep(1)# Wait for data to arrivedrive.drive_at_power(0.2,0.2)time.sleep(3)drive.drive_at_power(0.5,0.2)time.sleep(3)drive.drive_at_power(0.2,0.5)time.sleep(3)drive.drive_at_power(0.05,0.05)time.sleep(3)# Will auto-stop on disconnect# drive.stop()
# SPDX-FileCopyrightText: 2024-present Kevin Ahr <meowmeowahr@gmail.com>## SPDX-License-Identifier: GPL-3.0-or-laterimporttimefromkevinbotlibimportDrivebase,MqttKevinbotrobot=MqttKevinbot()robot.connect()drive=Drivebase(robot)input("LIFT THE WHEELS OFF THE GROUND FOR THIS TEST!!! [Return] to start test")robot.request_enable()# Ask the core to enablewhilenotrobot.get_state().enabled:# Wait until the core is enabledtime.sleep(0.01)time.sleep(1)# Wait for data to arrivedrive.drive_at_power(0.2,0.2)time.sleep(3)drive.drive_at_power(0.5,0.2)time.sleep(3)drive.drive_at_power(0.2,0.5)time.sleep(3)drive.drive_at_power(0.05,0.05)time.sleep(3)# Will auto-stop on disconnect# drive.stop()
Eyes
Connecting
examples/eyes/connecting_serial.py
1 2 3 4 5 6 7 8 910111213
# SPDX-FileCopyrightText: 2024-present Kevin Ahr <meowmeowahr@gmail.com>## SPDX-License-Identifier: GPL-3.0-or-laterimporttimefromkevinbotlibimportSerialEyeseyes=SerialEyes()eyes.connect("/dev/ttyUSB0",115200,5)whileTrue:time.sleep(1)
examples/eyes/connecting.py
1 2 3 4 5 6 7 8 9101112131415
# SPDX-FileCopyrightText: 2024-present Kevin Ahr <meowmeowahr@gmail.com>## SPDX-License-Identifier: GPL-3.0-or-laterimporttimefromkevinbotlibimportMqttEyes,MqttKevinbotrobot=MqttKevinbot()robot.connect()eyes=MqttEyes(robot)whileTrue:time.sleep(1)
State
examples/eyes/state_serial.py
1 2 3 4 5 6 7 8 91011121314
# SPDX-FileCopyrightText: 2024-present Kevin Ahr <meowmeowahr@gmail.com>## SPDX-License-Identifier: GPL-3.0-or-laterimporttimefromkevinbotlibimportSerialEyeseyes=SerialEyes()eyes.connect("/dev/ttyUSB0",115200,5)print(eyes.get_state().model_dump_json(indent=4))# noqa: T201time.sleep(1)
examples/eyes/state.py
1 2 3 4 5 6 7 8 910111213141516
# SPDX-FileCopyrightText: 2024-present Kevin Ahr <meowmeowahr@gmail.com>## SPDX-License-Identifier: GPL-3.0-or-laterimporttimefromkevinbotlibimportMqttEyes,MqttKevinbotrobot=MqttKevinbot()robot.connect()eyes=MqttEyes(robot)print(eyes.get_state().model_dump_json(indent=4))# noqa: T201time.sleep(1)
Backlight
examples/eyes/backlight_serial.py
1 2 3 4 5 6 7 8 91011121314
# SPDX-FileCopyrightText: 2024-present Kevin Ahr <meowmeowahr@gmail.com>## SPDX-License-Identifier: GPL-3.0-or-laterimporttimefromkevinbotlibimportSerialEyeseyes=SerialEyes()eyes.connect("/dev/ttyUSB0",115200,5)foriinrange(100):eyes.set_backlight(i/100)time.sleep(0.05)
examples/eyes/backlight.py
1 2 3 4 5 6 7 8 91011121314151617
# SPDX-FileCopyrightText: 2024-present Kevin Ahr <meowmeowahr@gmail.com>## SPDX-License-Identifier: GPL-3.0-or-laterimporttimefromkevinbotlibimportMqttKevinbotfromkevinbotlib.eyesimportMqttEyesrobot=MqttKevinbot()robot.connect()eyes=MqttEyes(robot)foriinrange(100):eyes.set_backlight(i/100)time.sleep(0.05)
Motion Mode Control
examples/eyes/motions_serial.py
1 2 3 4 5 6 7 8 9101112131415161718192021
# SPDX-FileCopyrightText: 2024-present Kevin Ahr <meowmeowahr@gmail.com>## SPDX-License-Identifier: GPL-3.0-or-laterimporttimefromkevinbotlibimportEyeMotion,EyeSkin,SerialEyeseyes=SerialEyes()eyes.connect("/dev/ttyUSB0",115200,5)eyes.set_skin(EyeSkin.SIMPLE)eyes.set_motion(EyeMotion.DISABLE)time.sleep(3)eyes.set_motion(EyeMotion.LEFT_RIGHT)time.sleep(3)eyes.set_motion(EyeMotion.JUMP)time.sleep(3)
examples/eyes/motions.py
1 2 3 4 5 6 7 8 91011121314151617181920212223
# SPDX-FileCopyrightText: 2024-present Kevin Ahr <meowmeowahr@gmail.com>## SPDX-License-Identifier: GPL-3.0-or-laterimporttimefromkevinbotlibimportEyeMotion,EyeSkin,MqttEyes,MqttKevinbotrobot=MqttKevinbot()robot.connect()eyes=MqttEyes(robot)eyes.set_skin(EyeSkin.SIMPLE)eyes.set_motion(EyeMotion.DISABLE)time.sleep(3)eyes.set_motion(EyeMotion.LEFT_RIGHT)time.sleep(3)eyes.set_motion(EyeMotion.JUMP)time.sleep(3)
Skin Setting Control
examples/eyes/skins_serial.py
1 2 3 4 5 6 7 8 910111213141516171819202122
# SPDX-FileCopyrightText: 2024-present Kevin Ahr <meowmeowahr@gmail.com>## SPDX-License-Identifier: GPL-3.0-or-laterimporttimefromkevinbotlibimportEyeSkin,SerialEyeseyes=SerialEyes()eyes.connect("/dev/ttyUSB0",115200,5)eyes.set_skin(EyeSkin.TV_STATIC)time.sleep(2)eyes.set_skin(EyeSkin.SIMPLE)time.sleep(2)eyes.set_skin(EyeSkin.METAL)time.sleep(2)eyes.set_skin(EyeSkin.NEON)time.sleep(2)
examples/eyes/skins.py
1 2 3 4 5 6 7 8 9101112131415161718192021222324
# SPDX-FileCopyrightText: 2024-present Kevin Ahr <meowmeowahr@gmail.com>## SPDX-License-Identifier: GPL-3.0-or-laterimporttimefromkevinbotlibimportEyeSkin,MqttEyes,MqttKevinbotrobot=MqttKevinbot()robot.connect()eyes=MqttEyes(robot)eyes.set_skin(EyeSkin.TV_STATIC)time.sleep(2)eyes.set_skin(EyeSkin.SIMPLE)time.sleep(2)eyes.set_skin(EyeSkin.METAL)time.sleep(2)eyes.set_skin(EyeSkin.NEON)time.sleep(2)
Manual Motions Demo
examples/eyes/manual_serial.py
1 2 3 4 5 6 7 8 910111213141516171819
# SPDX-FileCopyrightText: 2024-present Kevin Ahr <meowmeowahr@gmail.com>## SPDX-License-Identifier: GPL-3.0-or-laterimportrandomimporttimefromkevinbotlibimportEyeMotion,EyeSkin,SerialEyeseyes=SerialEyes()eyes.connect("/dev/ttyUSB0",115200,5)eyes.set_skin(EyeSkin.SIMPLE)eyes.set_motion(EyeMotion.MANUAL)for_iinrange(10):eyes.set_manual_pos(random.randint(0,240),random.randint(0,240))# noqa: S311time.sleep(1)
examples/eyes/manual.py
1 2 3 4 5 6 7 8 9101112131415161718192021
# SPDX-FileCopyrightText: 2024-present Kevin Ahr <meowmeowahr@gmail.com>## SPDX-License-Identifier: GPL-3.0-or-laterimportrandomimporttimefromkevinbotlibimportEyeMotion,EyeSkin,MqttEyes,MqttKevinbotrobot=MqttKevinbot()robot.connect()eyes=MqttEyes(robot)eyes.set_skin(EyeSkin.SIMPLE)eyes.set_motion(EyeMotion.MANUAL)for_iinrange(10):eyes.set_manual_pos(random.randint(0,240),random.randint(0,240))# noqa: S311time.sleep(1)