Quick Start Guide
Important
Recommended Installation Methods
Use HEAR-CLI for automated installation - it handles all dependencies and configuration automatically:
Development/Local Setup:
hear-cli local_machine run_program --p petal_app_manager_prepare_sitlProduction/Drone Deployment:
hear-cli target_machine copy_run_program --p petal_app_manager_prepare_armProduction/Drone Testing and Development:
hear-cli target_machine copy_run_program --p petal_app_manager_update_arm
Development Installation
Using HEAR-CLI (Recommended)
For local development and debugging, use the SITL (Software In The Loop) setup:
hear-cli local_machine run_program --p petal_app_manager_prepare_sitl
What this command does:
Installs all dependencies: Python 3.11 (Miniforge), PDM, Redis 7.2+
Creates development directory:
~/petal-app-manager-dev/Clones all repositories:
petal-app-manager(main framework)LeafSDK(mission planning SDK)mavlink(MAVLink protocol with custom messages)petal-flight-log(flight log management)petal-leafsdk(LeafSDK integration for mission plan execution)petal-qgc-mission-server(QGroundControl integration)petal-user-journey-coordinator(user journey management)petal-warehouse(data warehousing)
Configures development environment: Sets up PDM virtual environments for each component
Creates ``.env`` file: Pre-configured for development use
Installs development dependencies: All petals in editable mode
Note
The SITL setup creates a complete development environment with all petals linked for cross-development.
Development Directory Structure
The development setup creates the following repository structure with editable installations:
![digraph dev_structure {
rankdir=LR;
node [shape=folder, style=filled];
// Main development directory
dev_root [label="~/petal-app-manager-dev/", fillcolor=lightyellow, shape=box];
// Repositories
pam [label="petal-app-manager/\n(Main Framework)", fillcolor=lightblue];
leafsdk [label="LeafSDK/\n(Mission SDK)", fillcolor=lightgreen];
mavlink [label="mavlink/\n(Protocol)", fillcolor=orange];
pymavlink [label="mavlink/pymavlink/\n(Python Library)", fillcolor=orange];
// Petals
flight_log [label="petal-flight-log/\n(Flight Logs)", fillcolor=palegreen];
warehouse [label="petal-warehouse/\n(Data Warehouse)", fillcolor=palegreen];
leafsdk_petal [label="petal-leafsdk/\n(SDK Integration)", fillcolor=palegreen];
journey [label="petal-user-journey-coordinator/\n(Mission Coord)", fillcolor=palegreen];
qgc [label="petal-qgc-mission-server/\n(QGC Server)", fillcolor=palegreen];
// Directory structure
dev_root -> pam;
dev_root -> leafsdk;
dev_root -> mavlink;
dev_root -> flight_log;
dev_root -> warehouse;
dev_root -> leafsdk_petal;
dev_root -> journey;
dev_root -> qgc;
mavlink -> pymavlink [label="contains", style=dotted];
// Editable installations (development dependencies)
pam -> flight_log [label="editable\ninstall", color=blue, style=bold];
pam -> warehouse [label="editable\ninstall", color=blue, style=bold];
pam -> leafsdk_petal [label="editable\ninstall", color=blue, style=bold];
pam -> journey [label="editable\ninstall", color=blue, style=bold];
pam -> leafsdk [label="editable\ninstall", color=blue, style=bold];
pam -> pymavlink [label="file://\ninstall", color=red, style=bold];
// Legend
subgraph cluster_legend {
label="Legend";
style=filled;
color=lightgray;
rankdir=TB;
leg_edit_a [label="", shape=point, width=0];
leg_edit_b [label="editable install (changes reflect immediately)", shape=plaintext];
leg_file_a [label="", shape=point, width=0];
leg_file_b [label="file:// install (requires rebuild)", shape=plaintext];
leg_contains_a [label="", shape=point, width=0];
leg_contains_b [label="contains", shape=plaintext];
leg_edit_a -> leg_edit_b [color=blue, style=bold, arrowhead=vee];
leg_file_a -> leg_file_b [color=red, style=bold, arrowhead=vee];
leg_contains_a -> leg_contains_b [style=dotted, arrowhead=vee];
}
}](../_images/graphviz-c4e0678acb74b197dde8361a9ac2cca45ac75a77.png)
Development Repository Structure and Dependencies
Key Structure Points:
Main Framework (
petal-app-manager): Central application that loads all petalsEditable Installations: Changes to petal code are immediately reflected without reinstallation
pymavlink: Installed via
file://path (not editable) from the mavlink submodule. You must rebuild if changes are made usingpdm install -G dev --force-rebuild pymavlink.Independent Petals: Each petal has its own virtual environment for isolated testing
Typical File Locations:
~/petal-app-manager-dev/
├── LeafSDK/
│ ├── src/leafsdk/ # SDK source code
│ └── tests/ # SDK tests
├── mavlink/
│ ├── pymavlink/ # Python MAVLink library
│ │ ├── generator/ # Message generator
│ │ └── dialects/ # MAVLink dialects
│ ├── message_definitions/ # Python MAVLink library
│ │ └── v1.0/ # Message definitions (.xml)
├── petal-app-manager/
│ ├── src/petal_app_manager/
│ │ ├── api/ # REST API endpoints
│ │ ├── plugins/ # Petal loader
│ │ └── proxies/ # Backend proxies
│ ├── docs/ # This documentation
│ └── tests/ # Framework tests
├── petal-flight-log/
│ ├── src/petal_flight_log/ # Flight log handling
│ └── tests/
├── petal-warehouse/
│ ├── src/petal_warehouse/ # Data warehousing
│ └── tests/
├── petal-leafsdk/
│ ├── src/petal_leafsdk/ # Mission execution
│ └── tests/
├── petal-user-journey-coordinator/
│ ├── src/petal_user_journey_coordinator/
│ └── tests/
└── petal-qgc-mission-server/
├── src/petal_qgc_mission_server/
└── tests/
Manual Development Setup
If you need to set up manually (requires dependencies from previous section):
1. Create Development Directory
mkdir -p ~/petal-app-manager-dev
cd ~/petal-app-manager-dev
2. Clone Repositories
# Core framework
git clone https://github.com/DroneLeaf/petal-app-manager.git
git clone https://github.com/DroneLeaf/LeafSDK.git
git clone --recurse-submodules https://github.com/DroneLeaf/leaf-mavlink.git mavlink
# Petals
git clone https://github.com/DroneLeaf/petal-flight-log.git
git clone https://github.com/DroneLeaf/petal-leafsdk.git
git clone https://github.com/DroneLeaf/petal-qgc-mission-server.git
git clone https://github.com/DroneLeaf/petal-user-journey-coordinator.git
git clone https://github.com/DroneLeaf/petal-warehouse.git
3. Set Up Main Application
cd petal-app-manager
# Configure PDM to use Python 3.11
pdm use -f /usr/bin/python3.11
# Install development dependencies (includes all petals in editable mode)
pdm install -G dev
Production Installation
Using HEAR-CLI (Recommended)
For deployment to drone companion computers or production systems:
hear-cli target_machine copy_run_program --p petal_app_manager_prepare_arm
What this command does:
Installs system dependencies: Python 3.11 (pyenv), PDM, Redis 7.2+
Sets up production environment:
~/.droneleaf/petal-app-manager/Configures for production: Optimized for resource-constrained systems
Installs only production petals: Core functionality without development tools
Creates systemd service: Auto-start on boot
Configures ``.env`` file: Production-ready configuration
Warning
This command is designed for deployment to target machines (companion computers on drones). It requires HEAR-CLI to be configured with target machine credentials.
Custom Version Installation (Field Testing)
For testing specific combinations of Petal App Manager and petals on drones without creating formal releases:
hear-cli target_machine copy_run_program --p petal_app_manager_update_arm
Interactive Version Selection
This command prompts you to specify versions for each component, allowing flexible combinations for field testing:
droneleaf@ubuntu:~/HEAR_CLI$ hear-cli target_machine copy_run_program --p petal_app_manager_update_arm
Enter petal-app-manager version 😎 (v0.1.41): v0.1.42
Enter petal-flight-log version 😎 (v0.1.6): master
Enter petal-warehouse version 😎 (v0.1.7): dev
Enter petal-leafsdk version 😎 (v0.2.0):
Enter petal-user-journey-coordinator version 😎 (v0.1.2):
⭐ program will run in your target_machine, Are you sure? 😎 [y/n] (y):
Version Specification Options
Git Tags:
v0.1.42,v0.2.0(stable releases)Branch Names:
master,dev,feature/new-functionality(development versions)Commit SHA:
abc123ef(specific commits)Empty/Default: Press Enter to use the default version shown in parentheses
Use Cases for Custom Versions
Feature Testing: Deploy a development branch of a specific petal while keeping others stable
Bug Fixes: Test a hotfix branch before creating an official release
Integration Testing: Combine multiple development branches for comprehensive testing
Rollback Testing: Test with older versions to isolate issues
What this command does:
Prompts for each component version: Interactive selection for precise control
Downloads specified versions: Clones exact git references (tags/branches/commits)
Updates existing installation: Replaces current versions without full reinstall
Preserves configuration: Keeps existing
.envandproxies.yamlfilesRestarts services: Automatically restarts Petal App Manager with new versions
Tip
Development Workflow: Use this command to test your development branches on actual hardware before merging to main or creating releases. It’s perfect for validating changes in real-world conditions.
Note
This command requires HEAR-CLI to be configured with credentials for the target drone/companion computer.
Manual Production Installation
For manual production setup:
1. Create Production Directory
sudo mkdir -p ~/.droneleaf
sudo chmod -R 777 ~/.droneleaf
cd ~/.droneleaf
2. Clone Main Repository
git clone https://github.com/DroneLeaf/petal-app-manager.git
cd petal-app-manager
3. Install Production Dependencies
# Configure PDM
pdm use -f /usr/bin/python3.11
# Install production dependencies only
pdm install -G prod
Environment Configuration
The .env file contains all configuration for Petal App Manager:
Automatic Configuration
Both HEAR-CLI methods automatically create a .env file. For manual setups, create:
Note
All environment variables use the PETAL_ prefix to avoid conflicts with other applications.
cat > .env << 'EOF'
# .env file for Petal App Manager configuration
# General configuration
PETAL_LOG_LEVEL=INFO
PETAL_LOG_TO_FILE=true
PETAL_LOG_DIR=logs
# MAVLink configuration
PETAL_MAVLINK_ENDPOINT=udp:127.0.0.1:14551
PETAL_MAVLINK_BAUD=115200
PETAL_MAVLINK_MAXLEN=200
PETAL_MAVLINK_WORKER_SLEEP_MS=1
PETAL_MAVLINK_WORKER_THREADS=4
PETAL_MAVLINK_HEARTBEAT_SEND_FREQUENCY=5.0
PETAL_ROOT_SD_PATH=fs/microsd/log
# Cloud configuration
PETAL_ACCESS_TOKEN_URL=http://localhost:3001/session-manager/access-token
PETAL_SESSION_TOKEN_URL=http://localhost:3001/session-manager/session-token
PETAL_S3_BUCKET_NAME=devhube21f2631b51e4fa69c771b1e8107b21cb431a-dev
PETAL_CLOUD_ENDPOINT=https://api.droneleaf.io
# Local database configuration
PETAL_LOCAL_DB_HOST=localhost
PETAL_LOCAL_DB_PORT=3000
# Redis configuration
PETAL_REDIS_HOST=localhost
PETAL_REDIS_PORT=6379
PETAL_REDIS_DB=0
PETAL_REDIS_UNIX_SOCKET_PATH=/var/run/redis/redis-server.sock
PETAL_REDIS_HEALTH_MESSAGE_RATE=3.0
# Data operations URLs
PETAL_GET_DATA_URL=/drone/onBoard/config/getData
PETAL_SCAN_DATA_URL=/drone/onBoard/config/scanData
PETAL_UPDATE_DATA_URL=/drone/onBoard/config/updateData
PETAL_SET_DATA_URL=/drone/onBoard/config/setData
# MQTT client
PETAL_TS_CLIENT_HOST=localhost
PETAL_TS_CLIENT_PORT=3004
PETAL_CALLBACK_HOST=localhost
PETAL_CALLBACK_PORT=3005
PETAL_POLL_INTERVAL=1.0
PETAL_ENABLE_CALLBACKS=true
PETAL_MQTT_HEALTH_CHECK_INTERVAL=10.0
# Proxy connection retry configuration
PETAL_MQTT_RETRY_INTERVAL=10.0
PETAL_CLOUD_RETRY_INTERVAL=10.0
PETAL_MQTT_STARTUP_TIMEOUT=5.0
PETAL_CLOUD_STARTUP_TIMEOUT=5.0
PETAL_MQTT_SUBSCRIBE_TIMEOUT=5.0
# Petal User Journey Coordinator configuration
PETAL_DEBUG_SQUARE_TEST=false
EOF
Key Configuration Options
PETAL_LOG_LEVEL: Set toDEBUGfor development,INFOfor productionPETAL_LOG_DIR: Directory for log files (default:logs, production:/home/droneleaf/.droneleaf/petal-app-manager)PETAL_MAVLINK_ENDPOINT: UDP endpoint for MAVLink communicationPETAL_REDIS_UNIX_SOCKET_PATH: Path to Redis UNIX socketPETAL_CLOUD_ENDPOINT: DroneLeaf cloud API endpoint
Running the Application
Development Mode
cd ~/petal-app-manager-dev/petal-app-manager
# Activate PDM virtual environment
source .venv/bin/activate
# Run with auto-reload for development
uvicorn petal_app_manager.main:app --reload --host 0.0.0.0 --port 9000 --log-level info --no-access-log --http h11
Development Mode with Debugging (VSCode)
A VSCode launch configuration is provided for debugging with breakpoint support:
# Location: ~/petal-app-manager-dev/petal-app-manager/.vscode/launch.json
To use the debugger:
Open the project in VSCode:
code ~/petal-app-manager-dev/petal-app-managerPress
F5or go to Run and Debug panel (Ctrl+Shift+D)Select “Petal App Manager” from the launch configuration dropdown
Click the green play button or press
F5
The application will start with the debugger attached, allowing you to:
Set breakpoints in your code
Inspect variables and call stacks
Step through code execution
Hot-reload on file changes (
--reloadflag is enabled)
Tip
Debugging Petals: Since petals are installed in editable mode, you can also set breakpoints
in petal code (e.g., ~/petal-app-manager-dev/petal-flight-log/src/petal_flight_log/).
To debug a petal, open the petal files in the petal-app-manager workspace in VSCode
(they are linked via editable installation), then set breakpoints and run the debugger.
Changes to petal code will be reflected immediately due to editable installation.
Production Mode
cd ~/.droneleaf/petal-app-manager
# Activate PDM virtual environment
source .venv/bin/activate
# Run in production mode
uvicorn petal_app_manager.main:app --host 0.0.0.0 --port 9000 --log-level info --no-access-log --http h11
Background Service (Production)
The ARM installation script sets up a systemd service for automatic startup:
# Check service status
sudo systemctl status petal-app-manager
# Start/stop service
sudo systemctl start petal-app-manager
sudo systemctl stop petal-app-manager
# Enable/disable auto-start
sudo systemctl enable petal-app-manager
sudo systemctl disable petal-app-manager
Verifying the Installation
1. Check Application Health
# Test basic connectivity
curl http://localhost:9000/health
# Expected response:
# {"status": "ok"}
2. Access API Documentation
Open your browser and navigate to:
Swagger UI: http://localhost:9000/docs
ReDoc: http://localhost:9000/redoc
3. Check Proxy Status
# Test detailed connectivity
curl http://localhost:9000/health/detailed
// Expected response:
{
"status": "healthy",
"timestamp": "..."
"proxies": {
"redis": {
"status": "healthy",
},
"mavlink": {
"status": "healthy",
},
}
}
4. Test Redis Connection
# Direct Redis test
redis-cli -s /var/run/redis/redis-server.sock ping
# Should return: PONG
5. Check Logs
# View application logs (if logging to file is enabled)
tail -f app.log
# Or check individual component logs
ls -la app-*.log
6. Verify Petals Loading
# Check available petals
curl http://localhost:9000/petals/
# Expected: List of loaded petals
Quick Development Workflow
Once installed, here’s the typical development workflow:
# 1. Navigate to development directory
cd ~/petal-app-manager-dev/petal-app-manager
# 2. Activate environment
source .venv/bin/activate
# 3. Start application with auto-reload
uvicorn petal_app_manager.main:app --reload --host 0.0.0.0 --port 9000 --log-level info --no-access-log --http h11
# 4. In another terminal, start documentation auto-build
cd docs
sphinx-autobuild . _build/html
# 5. Open browser tabs:
# - http://localhost:9000/docs (API documentation)
# - http://127.0.0.1:8000 (documentation preview)
Tip
VSCode Integration: The development setup includes a .vscode/launch.json configuration.
Press F5 in VSCode to start debugging with breakpoint support.
Troubleshooting
Common Issues After Installation
Python 3.11 not found: Ensure symlinks were created and PATH is updated
PDM command not found: Check that
~/.local/binis in your PATHRedis connection failed: Verify Redis service is running and socket permissions are correct
Port 9000 already in use: This may occur if you’re trying to run Petal App Manager using
uvicornwhile the systemd service is currently running. For debugging, you may want to stop the service first withsudo systemctl stop petal-app-manager. Alternatively, kill the conflicting process. You may use the commandsudo lsof -i :9000to identify the process using the port.Application errors or unexpected behavior: Check the
app.logfile in thepetal-app-managerdirectory (~/petal-app-manager-dev/petal-app-manager/app.logor~/.droneleaf/petal-app-manager/app.log) for detailed error messages and stack traces that can help troubleshoot issues.
Getting Help
Check the Known Issues section for common problems
View application logs for detailed error messages
Ensure all dependencies are properly installed from the previous section