Documentation/P600 UAV WikiEnglish · Allspark2
Browse documentation
Software Overview

Onboard Code Package

The P600 onboard feature package is located in the HOME directory and is named p600 experiment.

7 min read · English documentation

The P600 onboard feature package is located in the HOME directory and is named p600_experiment.

p600_experiment Onboard Code Package

1722999827460.jpg

    1. The build files generated by compiling the project
    1. The devel files generated by compiling the project
    1. Executable build scripts (from top to bottom):
    • Compile the mission package code
    • Compile all package code
    • Compile the spirecv-ros package code
    1. README.md
    1. Package source-code directory, src
    1. Location of the P600 onboard code

Source-Code Directory, src

The src source-code directory contains all packages. Each package is relatively independent. Only the launch files for the UAV control code are stored directly in this code repository. The other vision, gimbal, Prometheus, and related modules are included in the software project as Git submodules to simplify code-version management.

1723000952578.jpg

    1. Blue Sea Optoelectronics LiDAR driver submodule (unused; the UAV currently uses a SLAMTEC LiDAR)
    1. Gimbal SDK driver submodule (unused)
    1. Mission-control implementation code
    1. One-click launch files and parameter configuration files
    1. Prometheus submodule
    1. RealSense driver submodule (unused)
    1. SLAMTEC LiDAR driver submodule
    1. spirecv-ros vision submodule

p600_experiment Package

1723003183623.jpg

    1. Configuration-parameter folder containing LiDAR filtering, MAVROS configuration parameters, Prometheus control configuration parameters, camera configuration parameters, and more.
    1. Basic launch folder containing communication-node and UAV-control launch files.
    1. Obstacle-avoidance planning launch folder containing mainly the LiDAR driver launch file, LiDAR filtering launch file, LiDAR-to-OctoMap launch file, OctoMap EGO-Planner launch file, and depth-based EGO-Planner launch files not used by this model.
    1. Vision launch folder containing mainly the G1 gimbal launch file, GX40 gimbal launch file, QR-code vision detection and tracking launch file, YOLO vision detection and tracking launch file, QR-code landing-control launch file, and YOLO tracking-control launch file.
    1. Scripts for one-click launch from the ground station. These combine the preceding launch files by feature into shell scripts. They are generally used from the ground station but can also be run in a terminal.
    1. Startup scripts, primarily for the communication node, which starts by default at boot to communicate with the ground station.
Configuration-Parameter Folder

1723003465193.jpg

    1. LiDAR filtering configuration parameters for setting the LiDAR filtering range and TF tree.
    1. MAVROS configuration parameters for setting the PX4 plug-in allowlist/denylist and PX4 parameters.
    1. Mission configuration parameters for adjusting parameter changes when the tracking distance is modified in real time from the ground station during visual tracking. No change is required by default.
    1. Prometheus control configuration parameters for setting the sensor pose relative to the UAV, trajectory-control parameters, and outdoor UAV control parameters such as takeoff altitude, geofence, and safe speed.
    1. Camera configuration parameters, primarily camera calibration parameters.
Basic Launch Folder

1723012053237.jpg

The main source code used is in the Prometheus submodule.

    1. Communication-node launch file
    1. UAV-control-node launch file
Obstacle-Avoidance Planning Launch Folder

1723012471183.jpg

The main source code used is in the Prometheus submodule, Blue Sea Optoelectronics LiDAR driver submodule, SLAMTEC LiDAR driver submodule, and RealSense driver submodule.

    1. Configuration parameters used during planning
    1. Depth-image-to-OctoMap launch file (unused because this model does not have a depth camera)
    1. Two EGO-Planner launch files: one for planning from depth information (unused), and one for planning from OctoMap.
    1. LiDAR filtering launch file.
    1. LiDAR driver launch files: the Blue Sea Optoelectronics 50C LiDAR driver launch file (unused) and SLAMTEC S3 LiDAR driver launch file.
    1. RViz launch file.
Vision Launch Folder

1723013597409.jpg

The main source code used is in the spirecv-ros vision submodule and mission-control implementation code. Launch filenames containing gimbal are for the G1 gimbal, while filenames containing gimbalx are for the GX40 gimbal.

    1. Control launch files for monocular-camera QR-code tracking and YOLO tracking (unused because this model uses a gimbal).
    1. QR-code vision detection and tracking launch files for the G1 and GX40.
    1. QR-code landing control launch files for the G1 and GX40.
    1. YOLO vision detection and tracking launch files for the G1 and GX40.
    1. Gimbal driver launch files for the G1 and GX40.
    1. YOLO tracking control launch files for the G1 and GX40.
    1. GX40 QR-code vision detection and tracking launch file (an early GX40 gimbal adaptation test script; unused).
Scripts for One-Click Launch from the Ground Station

1723014414467.jpg

These scripts combine the various launch files above by feature and provide one-click launch from the ground station. During debugging, they can also be run from a terminal. Script filenames containing gimbal are for the G1 gimbal, while filenames containing gimbalx are for the GX40 gimbal.

    1. QR-code landing feature script, which launches the gimbal launch file, QR-code vision detection and tracking file, and QR-code landing control file.
    1. YOLO tracking feature script, which launches the gimbal launch file, YOLO vision detection and tracking file, and YOLO tracking control file.
    1. LiDAR EGO-PLANNER obstacle-avoidance feature script, which launches the LiDAR driver, LiDAR data filtering, LiDAR-to-OctoMap, EGO-Planner planning, and RViz display launch files. Filenames containing S3 are for the SLAMTEC S3 LiDAR; filenames without S3 are for the Blue Sea 50C LiDAR (not installed on this model and unused).
    1. UAV control feature script, which includes the UAV control launch file.
Startup Scripts

1723014853862.jpg

These are primarily for the communication node, which starts by default at boot to communicate with the ground station.

    1. Early EGO test file, which is no longer used.
    1. Communication-node startup script.

mission Package

1723015191082.jpg

This package primarily contains UAV control code that operates in conjunction with vision detection and tracking results.

    1. Monocular QR-code tracking-control implementation: aruco_tracking.cpp
    1. Monocular circular-frame traversal-control implementation: circle_crossing.cpp
    1. Gimbal QR-code landing-control implementation: gimbal_aruco_landing.cpp
    1. Gimbal YOLO tracking-control implementation: gimbal_yolov5_tracking.cpp
    1. Related header-file implementations:
    • Communication-node custom message conversion: custom_data_segment_msg.hpp
    • Detection target-distance conversion and other implementations: mission_utils.h
    • Prompt-message printing implementation: printf_utils.h
    1. Monocular YOLO tracking-control implementation: yolov5_tracking.cpp

Note: None of the monocular control code has been tested. Exercise caution if you need to use it.

Prometheus Package

For details, refer to the Prometheus Wiki User Manual. image.png

Prometheus.png

    1. Build scripts: scripts for compiling all Prometheus modules or an individual module
    1. Experiment packages: location of the experiment packages provided by Prometheus; the P450 flagship experiment package is stored and managed separately on the onboard computer
    1. Prometheus feature-module packages: includes the communication module, future UAV competition modules, target-detection module, and more
    1. Script files
    1. Simulation modules

spirecv-ros Package

1723017427788.jpg

This package integrates the gimbal ROS driver package and vision detection and tracking features.

    1. cv_bridge package, which connects ROS image messages to OpenCV images. Because spirecv-ros uses a specially adapted OpenCV version, it must be recompiled.
    1. README.md user manual
    1. Vision-gimbal ros-msg interface files
    1. Gimbal ROS driver source code (primarily gimbal_server.cpp), ROS vision detection and tracking source code, and more
    1. Vision-gimbal ros-srv interface files

Gimbal feature compatibility

GX40 Amov G1
Automatic rotating search Supported Supported
Three-axis hybrid control Supported Supported
Zoom Supported Not supported
Maximum resolution 4k@30fps
1080P@30fps
SCGA(1280 * 1024)@30fps
1.3M(1280 * 960)@30fps
720P@30fps
4K@24/25/30/fps
2.7K@24/25/30/48/50/60fps
1080P@24/25/30/48/50/60/120fps
720P@24f/25/30/48/50/60/120/240fps
Video recording and photography Supported Supported
Data feedback types Automatic feedback, interactive feedback Automatic feedback
IMU angular velocity available Supported Not supported
Gimbal tracking Supported Supported
Yaw follow Supported Supported
Attitude hold Supported Not supported
Video output interface Ethernet port Ethernet port

Development Help

int uav_id = 1;
// Gimbal state topic
std::string gimbalStateTopic = "/uav" + std::to_string(uav_id) + "/gimbal/state";
// Gimbal control topic
std::string gimbalControlTopic = "/uav" + std::to_string(uav_id) + "/gimbal/control";
// Detected/tracked target topic
std::string gimbalTrackTopic = "/uav" + std::to_string(uav_id) + "/spirecv/target";
// Original image topic
std::string imageOriginal = "/uav" + std::to_string(uav_id) + "/gimbal/image_original";
// Gimbal photo-capture service
std::string gimbalTakePhotoServerName = "/uav" + std::to_string(uav_id) + "/gimbal_take_server";
// Local photo-capture service
std::string localTakePhotoServerName = "/uav" + std::to_string(uav_id) + "/local_take_server";
// Gimbal recording service
std::string gimbaRecordServerName = "/uav" + std::to_string(uav_id) + "/gimbal_record_server";
// Local recording service
std::string localRecordServerName = "/uav" + std::to_string(uav_id) + "/local_record_server";
// Gimbal centering service
std::string gimbalServerName = "/uav" + std::to_string(uav_id) + "/gimbal_server";
// Gimbal downward-view lock service
std::string gimbalDownwardLockName = "/uav" + std::to_string(uav_id) + "/gimbal_downward_lock";

// Gimbal serial port and type
std::string serialPotr = "/dev/ttyTHS1";
std::string gimbalType = "GX40";

// All gimbals transmit images over Ethernet. The GX40 address is 192.168.144.108 and the G1 address is 192.168.144.64.
std::string cameraName = "192.168.144.108";
// Resolution and frame rate
int cameraImageFps = 30;
int cameraHeight = 720;
int cameraWidth = 1280;

std::ostringstream paramFile;
paramFile << sv::get_home() << "/SpireCV/confs/calib_305_720.yaml";

nh.getParam("uav_id", uav_id);
nh.getParam("gimbalStateTopic", gimbalStateTopic);
nh.getParam("gimbalControlTopic", gimbalControlTopic);
nh.getParam("gimbakTrackTopic", gimbalTrackTopic);
nh.getParam("imageOriginal", imageOriginal);
nh.getParam("cameraServerName", cameraServerName);
nh.getParam("gimbalServerName", gimbalServerName);
nh.getParam("Port", serialPotr);
nh.getParam("Type", gimbalType);
nh.getParam("camera", cameraName);
nh.getParam("FPS", cameraImageFps);
nh.getParam("H", cameraHeight);
nh.getParam("W", cameraWidth);

rplidar_ros Package

1723016977421.jpg

This is the SLAMTEC LiDAR driver package.

    1. LiDAR driver-related launch files
    1. README.MD user manual
    1. RViz display-related configuration
    1. Related script files
    1. LiDAR SDK interface source code
    1. LiDAR driver launch-file source code

gimbal-sdk-ros Package

1723016469177.jpg

This is the gimbal driver package. This driver package is unused because the G1 and GX40 drivers are integrated into spirecv-ros.

    1. Related driver launch files.
    1. Gimbal ros-msg interface files.
    1. Gimbal control and image source code.
    1. Gimbal ros-srv interface files.

bluesea2 Package

bluesea2.png

This is the Blue Sea Optoelectronics LiDAR driver package. This driver package is unused.

    1. Configuration files
    1. Package driver launch files, including launch files for different LiDAR models. The P450 flagship UAV uses a 50C LiDAR.
    1. Package source-code files.
    1. ros-srv interface files

realsense-ros Package

realsense-ros.png

This package includes the depth-camera driver, communication and data exchange between the depth camera and ROS, and model description files. This driver package is unused.

    1. Drivers, communication, and data exchange for the depth camera
    1. URDF (Unified Robot Description Format) descriptions for the depth-camera model.