This is a project featuring a bot based on Raspberry Pi 4 Model B, created with the use of 3D printing technology and programmed in Python. All files needed to replicate this work are included here, including 3D models, PCB design for a custom HAT for the Raspberry Pi board, and source files.
The robot is assembled and programmed for maze traversal where the maze is represented with a black line on the floor (a textile 50 mm wide duct tape is recommended). The robot follows the left-hand wall follower algorithm and maps the maze as it traverses it. It assumes the maze is in the form of a grid. Once it finds an object in the maze, it picks it up and heads to the exit. The object used in this implementation was a 20 cm tall polystyrene duck. The settings of joint coordinates may need adjusting when using a different kind of object. If, while heading towards the exit, the robot already has the coordinates of the exit in its map, it uses Dijkstra's algorithm to find the shortest (known) path to get to it. The prices of paths are based on their length measured by counting pulses from a Hall sensor (used in combination with small magnets glued along the circumference of the track).
Once the robot finishes traversing the maze, it drops the object on the side and awaits a USB drive stick to be plugged into a USB port. The device then proceeds to upload a picture of the mapped maze. The finalization of the upload is indicated by the LED strip turning off, indicating that the USB drive stick can be safely removed.
This project relies on the following libraries:
- rpi-ws281x, pyyaml, pytest, smbus3, flexmock, rpi-lgpio, matplotlib
The following is the overall structure of the repository explained:
|
|----+ 3d-models 3D models of 3D-printable parts
| |---- fusion-360 - source files
| |---- 3mf - format for printing
|
|----+ assets Project art
|----+ files/orcapi.service Systemd file for setting up project start up on boot
|----+ orcapi Project source code
|----+ pcb KiCad project containing PCB design of a custom RPi HAT
|----+ tests Tests of project functionality
|----+ text Thesis files (.pdf and source files)
|----+ utils Helpful scripts used in the development workflow
|
|----- Makefile Contains targets for setting up environment, uploading files, etc.
|----- user-manual.pdf User manual containing assembly and installation instructions
This is an overview of the structure of the orcapi folder containing the source files of the program:
|
|----+ hardware Hardware control implementation
| |---- __init__.py
| |---- adc.py - AD converter logic
| |---- battery.py - Battery voltage measurement and LED strip color control
| |---- current.py - Electrical current measurement
| |---- dc.py - DC motor control (speed and direction control)
| |---- enums.py - Enums in relation to hardware components
| |---- i2c.py - I2C communication implementation
| |---- led.py - The control of addressable LED strip
| |---- line_detector.py - Reading line measurements from 5-channel optical sensors
| |---- odometry.py - Implementation of Hall sensor reading
| |---- servo.py - Servo motor (arm joints) control
| |---- stepper.py - Stepper motor (base of the robot arm) control
| |---- ultrasound.py - Ultrasound distance reading implementation
|
|
|---- __init__.py
|---- annotations.py - Type annotations
|---- config.yaml - The project configuration file
|---- coordinate_map.py - Implementation of local mapping
|---- exceptions.py - Project-specific exception class definition
|---- main.py
|---- robot_arm.py - Implementation of the basic robot arm routines (pick up / drop object, etc.)
|---- robot_driver.py - Implementation of maze traversal and line following based on PID
|---- utils.py - Config file parsing
This project utilizes many hardware components, many of which are of the LaskaKit_cz brand, which provides budget-friendly components and devices. The identifier of these components starts with LA. Thr following is a list of the major components used in the design:
| Part | Component | Amount | Purpose / Description |
|---|---|---|---|
| Electronics | Raspberry Pi 4 model B | 1 | Computational core of the project. |
| DC driver LA143010 | 1 | The driver for controlling the motors of the track chassis. It has the ability to control both motors at once. |
|
| Servo shield LA143009 | 1 | Used to generate PWM to control servo motors and the speed and direction of rotation of DC motors. | |
| Stepper motor driver LA143017 | 1 | Used to control the stepper motor. | |
| ADC | MCP3021 by Microchip Technology. | 2 | Each needs to have a different I2C address. Used to measure battery voltage and read electrical current readings from LA131014A. |
| Sensors | 5-channel line-following sensor LA170018 | 1 | Consists of five optical sensors TCRT5000. |
| Hall sensor SM451R | 1 | Used for odometry. | |
| Current sensor LA131014A board | 1 | Utilizes the ACS712 linear current sensor. | |
| Chassis and motors | Track chassis LA170018 | 1 | The track chassis of the tank powered by two DC motors. |
| Servo motor MG996 | 3 | Used to revolve the robot arm's joints. | |
| Servo arm for MG996 | 3 | Circular (20 mm diameter), M3 threads with 14mm span. | |
| Stepper motor LDO-42STH47-1684A | 1 | Intended to revolve the robot arm's base. | |
| LED strip | HC-F5V-90L-90LED-W-WS2813 | 1 | Based on WS2813. |
| Power supply | 7.4 V LiPo Battery C-49405 | 1 | |
| Step-down DC/DC converter LA122021 | 1 | Utilizes XL4016. | |
| On/off rocker switch | 1 | Approximately 22 x 10 mm in size. The 1901.1102 Marquardt switch fits well. | |
| Other | Cylindrical magnet | 1 | Approximately 4 mm tall and 1 mm in diameter. |
This section gives an overview of the Makefile targets. For detailed documentation of assembly and software setup, check user_manual.pdf.
To upload the project to Raspberry Pi located on the same network, use:
make upload-to-rpi
You can specify the target of transfer and destination by setting environment variables:
make upload-to-rpi \
TARGET=$TARGET \
LOGIN=$LOGIN \
LOCAL_IP=$LOCAL_IP \
DEST=$DEST
LOGIN refers to username on Raspberry Pi (use whoami to find out), LOCAL_IP refers to the IP address of the device and DEST refers to the location in the file system where to transfer files. Please note that ssh needs to be enabled on your Raspberry Pi for the file transfer to be successful. In order to find out the local IP address of your Raspberry Pi, ping can be used:
make ping-rpi
In order to set up a virtual environment and install necessary libraries, use:
make
To trigger a one-shot run of the uploaded project, use the command below. It is possible to set up automatic runs of the program upon boot so that it is no longer needed to launch runs via SSH. Check out user_manual.pdf for details.
make run
If needed, use the following to connect to the Raspberry Pi via SSH:
make connect-to-rpi
To safely turn the robot off (shut down Raspberry Pi OS) via SSH:
make shutdown
To upload the latest changes (in changes in upload targets) and run tests:
make test
To run tests again without uploading local changes instead, use:
make retest