SCUTTLE Robot is a modular robotics framework designed for autonomous navigation, obstacle avoidance, and intelligent mission control. The project is structured into three hierarchical levels to facilitate organization and scalability.
The architecture described in the material involves structuring the software into different levels (L1, L2, L3) and ensuring proper communication between hardware and software components. Below is a detailed breakdown of how to design the software:
The software architecture is divided into three levels:
Level 1 (L1): Hardware-specific programs that directly interact with sensors and actuators.
Level 2 (L2): Logic-defining programs that process data from L1 and send commands to actuators.
Level 3 (L3): High-level mission control programs that coordinate the overall behavior of the robot.
These programs are responsible for direct communication with the hardware. For the Raspberry Pi 4, We will used libraries like gpiozero for GPIO control and pysicktim for LIDAR communication.
-
L1_motor.py: Controls the motor drivers by generating PWM signals.
-
L1_encoder.py: Reads data from wheel encoders.
-
L1_lidar.py: Communicates with the LIDAR sensor to get distance measurements.
-
L1_gamepad.py: Reads input from the gamepad controller.
-
L1_camera.py: Captures images from the USB camera
-
L1_mpu.py: Reads data from the IMU (MPU9250) for orientation and motion data.
-
L1_bmp.py: Reads temperature and pressure data from the BMP280 sensor.
-
L1_adc.py: Reads voltage data from the ADC sensor.
These programs process data from L1 and generate commands for actuators. They handle the logic for tasks like kinematics, speed control, and obstacle detection.
-
L2_kinematics.py: Computes chassis movement based on wheel encoder data.
-
L2_speed_control.py: Generates wheel duty cycle commands based on desired speed.
-
L2_inverse_kinematics.py: Computes wheel vectors for desired movement.
-
L2_obstacle.py: Processes LIDAR data to detect obstacles.
-
L2_track_target.py: Processes camera data to track a target.
-
L2_onboard.py: Computes battery and environmental data from BMP280 and ADC sensors.
-
L2_log.py: Handles data logging for debugging and analysis.
These programs coordinate the overall mission of the robot. They receive data from L2 programs and send high-level commands.
L3_drive_mt.py: Multithreaded driving program that coordinates movement based on gamepad input or autonomous commands.
L3_follow.py: Autonomous program for following a target using camera data.
L3_avoid_obstacles.py: Autonomous program for obstacle avoidance using LIDAR data.
To ensure smooth operation, especially for tasks like driving, obstacle detection, and audio feedback, multithreading is essential. Each thread should handle a specific task, such as:
Thread 1: Driving the robot based on gamepad input or autonomous commands.
Thread 2: Obstacle detection using LIDAR data.
Thread 3: Audio feedback or text-to-speech output.
For the Raspberry Pi 4, you will use the following libraries:
gpiozero: For GPIO control.
pysicktim: For LIDAR communication.
numpy: For mathematical operations.
pygame: For gamepad input.
fastlogging: For logging data.
smbus2: For I2C communication with sensors like BMP280 and MPU9250.
scuttle_robot/
├── L1/ # Level 1: Hardware-specific programs
│ ├── L1_motor.py # Motor control interface
│ ├── L1_encoder.py # Encoder feedback processing
│ ├── L1_lidar.py # LIDAR sensor integration
│ ├── L1_gamepad.py # Gamepad input handling
│ ├── L1_camera.py # Camera module integration
│ ├── L1_mpu.py # MPU sensor processing
│ ├── L1_bmp.py # BMP sensor integration
│ └── L1_adc.py # ADC (Analog to Digital Converter) interface
│
├── L2/ # Level 2: Logic-defining programs
│ ├── L2_kinematics.py # Forward and inverse kinematics calculations
│ ├── L2_speed_control.py # Speed control logic
│ ├── L2_inverse_kinematics.py # Inverse kinematics for movement planning
│ ├── L2_obstacle.py # Obstacle detection and response
│ ├── L2_track_target.py # Target tracking algorithms
│ ├── L2_onboard.py # Onboard processing logic
│ └── L2_log.py # Logging mechanisms for debugging
│
├── L3/ # Level 3: Mission control programs
│ ├── L3_drive_mt.py # Multi-threaded driving logic
│ ├── L3_follow.py # Object following behavior
│ ├── L3_avoid_obstacles.py # Obstacle avoidance strategies
│ └── L3_mission_control.py # High-level mission planning
│
├── utils/ # Utility functions and shared resources
│ ├── constants.py # Constants and configuration settings
│ └── logger.py # Logging and debugging utilities
│
└── main.py # Entry point for the SCUTTLE Robot system
- Clone the repository:
git clone https://github.com/yourusername/scuttle_robot.git
- Navigate to the project directory:
cd scuttle_robot
- Install dependencies:
pip install gpiozero smbus2 numpy pygame opencv-python
To start the SCUTTLE Robot system, run:
python main.py
sudo systemctl enable pigpiod
sudo systemctl start pigpiod
Create a Systemd Service
- Create a new service file:
sudo nano /etc/systemd/system/scuttle_robot.service
- Add the following content to the file:
[Unit]
Description=SCUTTLE Robot Application (venv)
After=network.target pigpiod.service
[Service]
Type=simple
User=pi
WorkingDirectory=/home/pi/scuttle_robot
# Use the venv's Python interpreter and your main.py
ExecStart=/home/pi/scuttle_robot/myenv/bin/python /home/pi/scuttle_robot/main.py
Restart=always
RestartSec=5
Environment=PYTHONUNBUFFERED=1
# Logging (optional)
StandardOutput=syslog
StandardError=syslog
SyslogIdentifier=scuttle_robot
[Install]
WantedBy=multi-user.target
- Save and exit the file (Ctrl + X, then Y).
- Enable the service:
sudo systemctl enable scuttle_robot.service
- Start the service:
sudo systemctl start scuttle_robot.service
- Check the status of the service:
sudo systemctl status scuttle_robot.service
Service pigpio
[Unit]
Description=pigpio daemon
After=network.target
[Service]
Type=forking
ExecStart=/usr/bin/pigpiod
Restart=always
# If pigpiod needs specific parameters, add them to the line above
# Example: ExecStart=/usr/bin/pigpiod -o -l # -o for no prompts, -l for log
[Install]
WantedBy=multi-user.target
sudo nano /etc/systemd/system/pigpiod.service
# Install RPLIDAR dependencies
sudo apt-get update
sudo apt-get install -y python3-pip python3-serial
sudo pip3 install py-rplidar
# Set up USB permissions (permanent solution)
echo 'KERNEL=="ttyUSB*", MODE="0666"' | sudo tee /etc/udev/rules.d/99-rplidar.rules
sudo udevadm control --reload-rules
sudo usermod -a -G dialout pi # Replace "pi" with your username if different