Python & VS Code — Programming Environment¶
The RflySim toolchain comes with a uniformly configured Python + VS Code programming environment, customized and optimized for unmanned system simulation and control tasks.
Python Environment¶
Version and Path¶
- Actual Version: Python 3.12 (even though the folder name is
Python38Env) - Path:
[Installation Directory]\Python38\python.exe - Package Management: Use
pipto install additional dependency packages on demand
Pre-installed Core Libraries¶
| Library | Purpose |
|---|---|
| NumPy / SciPy | Numerical computation and scientific modeling |
| Matplotlib / Seaborn | Data visualization |
| opencv-python (OpenCV) | Image processing and visual perception |
| Pandas | Structured data analysis |
| Pymavlink | Python implementation of the MAVLink protocol |
| MAVSDK | Python API for high-level control of PX4 |
| TensorFlow | Deep learning framework |
| PyTorch (torchvision) | Deep learning framework (image classification/object detection) |
Typical Application Scenarios¶
| Scenario | Specific Application |
|---|---|
| Flight log analysis | Parsing .ulg and .bag flight log files |
| State data processing | Real-time parsing of CopterSim state data |
| Visual perception development | Object detection, object tracking algorithms |
| Simulated vehicle control | Sending control commands via PX4MavCtrlV4 |
| Automated testing | Batch testing and parameter scanning scripts |
| AI/ML training | Reinforcement learning training, large model embodied intelligence integration |
About Version Updates
The Python environment of RflySim is regularly updated to follow the latest Python version to maintain compatibility with the latest AI frameworks. Some large-scale dependencies (such as GPU acceleration components) are installed online.
RflySimSDK¶
The Python SDK of RflySim is uniformly integrated under [Installation Directory]\RflySimAPIs\RflySimSDK\, and it is automatically added to the Python environment path after installation:
| Module | Function Introduction |
|---|---|
ctrl |
Core interface for flight control and data interaction with CopterSim |
comm |
Swarm network communication simulation interface |
vision |
Visual sensor data acquisition and camera control |
ue |
3D scene interaction and visualization control |
swarm |
Multi-UAV swarm control interface |
phm |
Fault injection and safety assessment interface |
# Quick import example
from RflySimSDK.ctrl import PX4MavCtrlV4
from RflySimSDK.vision import VisionCaptureApi
Custom Environment
If you want to use a custom environment such as PyCharm + Anaconda, please run RflySimSDK\ReLabPath.py first to complete path registration and link the RflySimSDK library.
VS Code Configuration¶
Recommended Installation¶
- Install Visual Studio Code
- Install the following recommended extensions:
| Extension | Purpose |
|---|---|
| Python (Official) | Python language support, debugging, and Linting |
| C/C++ | C++ code browsing and debugging |
| Remote - WSL | Direct editing and debugging in WSL Ubuntu |
| Remote - SSH | Remote connection for on-board computer development |
| MATLAB | MATLAB syntax highlighting |
| JSON | JSON configuration file editing |
Configure Python Interpreter¶
- Press
Ctrl+Shift+Pin VS Code - Search for
Python: Select Interpreter - Select the path:
[Installation Directory]\Python38\python.exe
After configuration, you can execute various RflySim visual algorithms and control scripts in run or debug mode.
Multi-terminal Integration¶
VS Code supports opening multiple terminals simultaneously in the same interface:
- PowerShell / CMD: Run Python scripts on the Windows side
- WSL Terminal: Run Linux tasks such as ROS / PX4 compilation
- SSH Terminal: Remote connection to on-board computers such as Jetson
Quick Start¶
Use the desktop shortcut RflyTools\Python38Run to register the Python environment in the current directory, and launch custom control scripts or visual algorithm modules via the command line.