A Python package to control a custom Robot V2 via Bluetooth Low Energy (BLE) communication. The package provides an API for controlling the robot's movements and LED colors.
This project uses Poetry for package management. Install Poetry if you haven't already.
To install the package and its dependencies, run:
poetry installThe example.py script demonstrates how to use the package to control the robot.
fromweallcode_robotimportRobotrobot=Robot("WAC")
robot.led(255, 0, 0) # Set the LED color to redrobot.move(100, 100) # Move forwardrobot.wait(2) # Wait for 2 secondsrobot.move(0, 0) # Stop the robotrobot.move(-100, 100) # Turn the robotrobot.wait(0.25) # Wait for 0.25 secondsrobot.move(100, 100) # Move forwardrobot.wait(1) # Wait for 1 secondrobot.move(0, 0) # Stop the robotrobot.move(-100, -100) # Move backwardrobot.wait(1) # Wait for 1 secondrobot.move(0, 0) # Stop the robotrobot.led(0, 0, 0) # Turn off the LEDa=robot.setKeyBinding('a').led(0, 0, 255, 1) # set LED color one button Aw=robot.setKeyBinding('w').move(100, 100) # bind move forward to key WThe Robot class is the main class to control the robot. Instantiate the class with the name of the robot.
robot=Robot("WAC")led(red: int, green: int, blue: int, duration: int): Sets the LED color. Values should be integers between 0 and 255.move(left: int, right: int, duration: int): Sets the motor speeds. Values should be integers between -100 and 100.wait(duration: float): Adds a wait command with a given duration in seconds.run(): Executes the commands in the order they were added.
The package includes development dependencies:
black: Code formatterpre-commit: Pre-commit hooks for code formatting and lintingisort: Import sorterruff: Linter
To install the development dependencies, run:
poetry install --extras devTo run the pre-commit hooks, first install them:
pre-commit installThen run:
pre-commit run --all-files- Blaine Rothrock
- Ali Karbassi