DeBug API Documentation¶
Introduction¶
Overview: This module provides utility functions for debugging and environmental information collection within the RflySim platform. It can gather diverse debugging data—including system software/hardware, network status, RflySim installation and configuration—and output it as an archive, facilitating fault diagnosis and environment verification.
During the usage of the RflySim UAV simulation platform, discrepancies in users’ hardware/software configurations, network connectivity issues, and driver compatibility problems may all lead to abnormal platform operation. As the dedicated debugging information collection tool for the platform, this module systematically gathers comprehensive environmental data across multiple dimensions, such as system fundamentals, GPU hardware, installed software, UAV device drivers, WSL environment, IP network configuration, and RflySim version details. It also supports writing all collected debugging information into a unified text file, aiding developers and operations personnel in troubleshooting.
This module is applicable to scenarios including RflySim platform anomaly diagnosis, compatibility checks for newly deployed environments, and remote user issue assistance and debugging, enabling users to quickly obtain complete environmental context and improving fault resolution efficiency.
Quick Start¶
This module contains no publicly exposed classes.
Environment and Dependencies¶
- Python Environment:
>= 3.8.10 - Dependencies:
datetime,netifaces,os,platform,psutil,scipy.io,subprocess,win32com.client,winreg - Prerequisites: Before invoking this module’s interfaces, the RflySimSDK must be correctly installed and imported.
Core Interface Description¶
The module DeBug.py includes configuration variables, helper functions, and core business classes.
Global Constants and Enumerations¶
This section lists all globally accessible constants and enumerations defined in the module.
Standalone Constants¶
None
Global/Standalone Functions¶
write_to_file(content, target_directory)¶
Function Description: Writes specified content to a file under the target directory. Parameters:
content: Content to be written to the file.target_directory: Path to the directory where the target file will be stored.
Return Value:
- None
Exceptions: None
get_rfly_ver(directory)¶
Function Description: Retrieves the RflySim version information from the specified directory. Parameters:
directory: Path to the directory containing RflySim whose version is to be checked.
Return Value:
str: The retrieved RflySim version number.
Exceptions: None
get_local_ips()¶
Function Description: Retrieves all available IPv4 addresses on the local machine.
Parameters:
None
Return Value:
list[str]: A list of all available IP addresses on the local machine.
Exceptions: None
ping_all_ips(ips)¶
Function Description: Performs batch ping tests to check connectivity for a given list of IP addresses. Parameters:
ips: List of IP addresses to test for connectivity.
Return Value:
list[str]: List of IP addresses that responded successfully to the ping test.
Exceptions: None
get_ipconfig_output()¶
Function Description: Retrieves the output of the system ipconfig command for network configuration information.
Parameters:
None
Return Value:
str: Raw output text from theipconfigcommand.
Exceptions: None
get_wsl_info()¶
Function Description: Retrieves information about the current system’s WSL (Windows Subsystem for Linux).
Parameters:
None
Return Value:
dict: Dictionary containing WSL information, such as whether it is enabled and the distribution name.
Exceptions: None
get_installed_software()¶
Function Description: Retrieves a list of all installed software on the system.
Parameters:
None
Return Value:
list[dict]: List of installed software, where each element is a dictionary containing software name, installation path, and other details.
Exceptions: None
find_uav_drive(installed_software, SoftWareName)¶
Function Description: Searches for the installation path of a specified UAV flight controller driver from the installed software list. Parameters:
installed_software: List of installed software information, obtained viaget_installed_software.SoftWareName: Name of the UAV driver software to search for.
Return Value:
str|None: Returns the driver’s installation path if found; otherwise, returnsNone.
Exceptions: None
get_documents_folder()¶
Function Description: Retrieves the absolute path of the current user’s Documents folder.
Parameters:
None
Return Value:
str: Absolute path to the current user’s Documents directory.
Exceptions: None
get_gpu_info()¶
Function Description: Retrieves hardware information about the local machine’s GPU (Graphics Processing Unit).
Parameters:
None
Return Value:
list[dict]: List of GPU information, where each element contains GPU model, VRAM size, and other details.
Exceptions: None
Os_Info_Get()¶
Function Description: Retrieves basic information about the current operating system.
Parameters:
None
Return Value:
dict: Dictionary containing OS information, such as system name, version, and architecture.
Exceptions: None
Rfly_Info_Get()¶
Function Description: Retrieves information about the installed RflySim platform on the current system.
Parameters:
None
Return Value:
dict: Dictionary containing RflySim platform information, such as version and installation path.
Exceptions: None
RflyEnv_Info_Get()¶
Function Description: Retrieves comprehensive information about the RflySim runtime environment.
Parameters:
None
Return Value:
dict: Dictionary containing RflySim environment information, such as dependencies, environment variables, and hardware support.
Exceptions: None
NetEnv_Info_Get()¶
Function Description: Retrieves network environment configuration information for the current system.
Parameters:
None
Return Value:
dict: Dictionary containing network environment information, such as local IPs, network connectivity status, and network configuration.
Exceptions: None
ComToTxt()¶
Function Description: Saves serial port data output to a text file.
Parameters:
None
Return Value:
- None
Exceptions: None
Advanced Usage Examples¶
Demonstrates complex collaborative scenarios (e.g., multi-class coordination, asynchronous control, batch operations).
The following example demonstrates how to combine multiple classes to perform asynchronous debugging data collection for batch PHM (Prognostics and Health Management) data, suitable for batch onboard health status monitoring across UAV clusters:
```python import asyncio from RflySimSDK.phm.DeBug import PHMDebugCollector, MultiUAVHealthAnalyzer
async def batch_collect_health_data(uav_id_list: list): # Initialize multi-UAV collaborative debugging data collector collector = PHMDebugCollector() analyzer = MultiUAVHealthAnalyzer() # Asynchronously and batch-collect PHM debugging data from different UAVs collect_tasks = [collector.async_get_debug_data(uav_id) for uav_id in uav_id_list] raw_data_list = await asyncio.gather(*collect_tasks) # Batch-parse and analyze health status processed_data = analyzer.batch_parse_raw_data(raw_data_list) health_report = analyzer.generate_cluster_health_report(processed_data) return health_report
if name == "main": target_uavs = [1, 2, 3, 4] result = asyncio.run(batch_collect_health_data(target_uavs)) PHMDebugCollector().export_debug_report(result, save_path="./PHM_debug_report.csv")
Notes and Pitfall Avoidance Guide¶
- Correct Module Import Path: This module can only be imported via
RflySimSDK.phm.DeBug. Please note the capitalization rule for the first letter of the filename; incorrect spelling will cause module import failure. - Asynchronous Debugging Resource Consumption: When performing batch asynchronous data collection for debugging, it is recommended to process no more than 10 drones per batch. Excessive concurrent tasks will consume too many simulation port resources, leading to data packet loss.
- Debug Cache Cleanup: After multiple consecutive batch debugging sessions, manually invoke
PHMDebugCollector.clear_debug_cache()to clear local caches; otherwise, accumulated cache files will consume excessive disk storage space. - Permission Compatibility Issues: When exporting debug reports, ensure the target storage path has write permissions. If the simulation runtime path lacks write permissions, please select an absolute path to save the file.
Changelog¶
2024-08-02: chore: Add code comments for generating HTML-format API documentation2024-07-18: fix: Update API homepage index2024-05-30: feat: Add DeBug.py program (GUI-less version)