MIT License

技术解读

以下内容由 GitRead 中文社区 编辑团队基于项目 README 与官方资料整理, 结合中文开发者的常见使用场景补充技术选型建议。具体以项目官方文档为准。

深度技术分析:asv-drones - 地面站控制应用开源实现

项目背景与痛点

在无人机领域,有效的地面站控制对于任务的安全运行至关重要。特别是在多自动驾驶平台如ArduPilot和PX4的场景下,如何提供一个兼具易用性和强大功能的地面站控制应用成为了一个痛点。ASV Soft 开发的 asv-drones 项目旨在填补这一需求,为用户提供一个开源的、集成了多个自动驾驶平台的地面站控制工具。

核心技术揭秘

asv-drones 的设计充分利用了现代软件架构的最佳实践,采用了一系列技术栈和设计模式来实现高效稳定的功能。下面我们将深入探讨这个项目的架构和技术细节。

graph TD A[用户发起请求] --> B("解析请求") B --> C{"有效性校验"} C -->|"通过"| D[路由到对应模块] C -->|"失败"| E[返回错误] D --> F[不同模块处理请求] F --> G[状态更新与反馈] G --> H[结果返回用户]

上图展示了 asv-drones 的大致数据流:从收到用户请求开始,经过解析、有效性校验,到路由至相应的功能模块进行处理,最后向用户返回结果和状态更新。这样的设计保证了系统的高扩展性和模块化特性,使得一个单一的软件可以支持多个自动驾驶平台的控制需求。

功能亮点与差异

相比于市面上的其他地面站控制应用,asv-drones 拥有以下显著特点:

  • 跨平台支持:不仅支持主要的自动驾驶平台(如ArduPilot和PX4),还能够轻易地扩展到其他平台。
  • 开源设计:开源本质鼓励了社区参与,用户可以轻松地修改和扩展功能,以满足特定需求。
  • 模块化设计:高度模块化的系统架构使得添加或替换特定功能成为可能,有效降低了系统维护的复杂性。

应用场景与落地建议

在将 asv-drones 集成到生产环境时,需要考虑以下几点:

  1. 环境配置:确保所有的依赖组件和库版本都准确无误,这可能涉及到复杂的系统配置。
  2. 可靠性测试:鉴于无人机任务的高要求,务必进行彻底的功能和压力测试。
  3. 团队学习曲线:由于这是一个开源项目,团队成员可能需要时间来熟悉其内部机制和最佳实践。

此项目适合的业务场景涵盖了无人机编队飞行、农田监测、物流配送等多种领域,特别是需要高度自定义和灵活控制的应用场景。

综合评价

asv-drones 在为无人机提供一个全面且灵活的地面站控制应用上,展现出强大的潜力。其开源特性、模块化设计和广泛的平台兼容性是它的主要优点。然而,项目的持续发展依赖于活跃的社区支持,这可能对新用户带来一定的学习曲线挑战。对于有经验的开发者来说,这是一个值得探索的宝藏。

关于

GitHub 原始描述(英文)

Open source implementation of ground control station application for ArduPilot and PX4 autopilot

描述取自 GitHub 官方 API,保持仓库作者书写的原文。

简要分析

热度分
304
价值分
146
活跃状态
活跃

语言占比

Batchfile
C#
Inno Setup
NSIS
Shell

README

Asv.Drones

Asv.Drones NuGet version Asv.Drones.Api NuGet version Build and tests Documentation GitHub Packages

asv-drones

Documentation and Packages

Read the Asv.Drones documentation for getting started, development, and documentation publishing.

Packages are available on NuGet as Asv.Drones and Asv.Drones.Api, and on GitHub Packages as Asv.Drones and Asv.Drones.Api.

GitHub Packages links require a signed-in GitHub account. The NuGet packages are publicly accessible.

The build workflow validates the desktop application and launcher. This repository currently has no automated test project; the workflow reports this explicitly and runs test projects when they are present.

1. Introduction

Asv.Drones: Empowering Innovation in Unmanned Aerial Systems

Welcome to Asv.Drones, an advanced and modular open-source application designed to revolutionize the field of Unmanned Aerial Systems (UAS). Committed to fostering innovation and collaboration, Asv.Drones is not just a drone application; it’s a community-driven platform that opens the doors to limitless possibilities.

Key Features:

  1. Plugins: Asv.Drones supports plugins that extend the application without modifying its core. Plugins are loaded from the plugins directory and use the Asv.Drones.Plugin. assembly prefix.

  2. Open Source Philosophy: Transparency and collaboration lie at the heart of Asv.Drones. The entire application, along with its constituent modules, is open source. This means that not only can users benefit from the software, but they can also actively contribute to its enhancement and evolution.

  3. Community Collaboration: Asv.Drones thrives on community collaboration. Developers, enthusiasts and innovators are encouraged to contribute, share insights and collectively shape the future of unmanned aerial systems.

Embark on a journey of exploration, experimentation and innovation with Asv.Drones. Whether you’re a developer, researcher or drone enthusiast, this open-source platform invites you to redefine the possibilities of unmanned aerial systems.

win flight-many packet-viewer connections settings

Plugins overview:

  • Asv.Drones.Gbs (Ground Base Station Service): This module provides a robust ground base station service, ensuring seamless communication between the drone and the operator on the ground. Open source nature encourages customization for specific ground station requirements.

Main Libraries Overview:

  • Asv.Gnss (GNSS Library): The Asv.Gnss module is a comprehensive GNSS library that parses RTCMv2, RTCMv3 and NMEA protocols. It goes a step further by providing control over receivers through SBF, ComNav and UBX protocols, all tailored for .NET environments.

  • Asv.Mavlink (MAVLink Library for .NET 10.0): For seamless communication and control, Asv.MAVLink is a dedicated library compatible with .NET 10.0. It ensures that your drone’s communication adheres to the MAVLink protocol standards.

  • Asv.Common: Asv.Common serves as the backbone, offering common types and extensions for all Asv-based libraries. It streamlines development, ensuring consistency and efficiency across different modules.

  • Asv.Avalonia: Asv.Avalonia is a custom framework built on top of Avalonia. It defines the fundamental rules for cross-platform applications and allows for their rapid assembly. Out of the box, the framework provides an event system for ViewModels, a powerful undo/redo mechanism for various user actions, a theme with diverse styles, a cross-platform dialog system and more. Asv.Avalonia features various additional modules that extend its functionality.

2. Different Sets of Components

Asv.Drones can work with different combinations of its components.

Example of Usage with GBS

Ground Base Station Integration: Asv.Drones offers seamless integration with ground base stations through our proprietary implementation called Asv.Drones.Gbs. Built to operate via the MAVLink protocol, Asv.Drones.Gbs allows users to remotely manage and monitor drone operations from a centralized platform. Moreover, any other ground base station software compatible with MAVLink can seamlessly interface with our application, ensuring flexibility and interoperability across different systems (development of additional UI controls may be required). With Asv.Drones.Gbs, users can plan missions, monitor telemetry data and adjust flight parameters with ease. To connect to a GBS, create a new connection (usually TCP) in the connection settings.

gbs-packets gbs-widget

3. Getting Started

Setting Up the Development Environment

To ensure a smooth development experience, follow the steps below to set up your development environment:

3.1 Prerequisites

  • Operating System: This project is compatible with Windows, macOS and Linux. Ensure that your development machine runs one of these supported operating systems.
  • IDE (Integrated Development Environment): We recommend using Visual Studio or JetBrains Rider as your IDE for C# development.
  • Make sure to install the necessary extensions and plugins for a better development experience.

3.2 .NET Installation

  • This project is built using .NET 10.0. We recommend installing .NET 10.0 by following the instructions provided on the official .NET website.

    # Check your current .NET version
    dotnet --version
    

3.3 Version Control

  • If you haven’t already, install a version control system such as Git to track changes and collaborate with other developers.

3.4 Clone the Repository

  • Clone the project repository to your local machine using the following command:

    git clone https://github.com/asv-soft/asv-drones.git
    

3.5 Restore Dependencies

  • Navigate to the src directory and restore the dependencies for the desktop project. There are three possible platform directories to build and debug our app: Asv.Drones.Desktop, Asv.Drones.Android, Asv.Drones.iOS. Currently, we support only the desktop platform.

    cd asv-drones/src
    dotnet restore Asv.Drones.Desktop/Asv.Drones.Desktop.csproj
    

3.6 Build and Run

  • Build the desktop project:

    dotnet build Asv.Drones.Desktop/Asv.Drones.Desktop.csproj
    
  • Run the desktop project:

    dotnet run --project Asv.Drones.Desktop/Asv.Drones.Desktop.csproj
    

Congratulations! Your development environment is now set up, and you are ready to start contributing to the project. If you encounter any issues during the setup process, refer to the project’s documentation or reach out to the development team for assistance.

Building for Android

Coming soon…

4. Code Structure

The organization of the codebase plays a crucial role in maintaining a clean, scalable and easily understandable project. This section outlines the structure of our codebase, highlighting key directories and their purposes.

4.1 Solution Organization

Our solution is organized the following way:

  • src/: This directory contains the source code of the application. The code is further organized into projects, each residing in its own subdirectory. The goal is to promote modularity and maintainability.
  src/
  ├── Asv.Drones.Launcher/
  ├── Asv.Drones.Android/
  ├── Asv.Drones.Desktop/
  ├── Asv.Drones.iOS/
  ├── Asv.Drones/
  │   ├── Core/
  │   ├── Shell/
  │   └── ...
  └── Asv.Drones.Api/
      ├── Core/
      ├── Shell/
      └── ...

4.2 Naming Conventions

Consistent naming conventions are essential for code readability. Throughout the codebase, we follow the guidelines outlined in our documentation.

These conventions contribute to a unified and coherent codebase.

By adhering to this organized structure and naming conventions, we aim to create a codebase that is easy to navigate, scalable and conducive to collaboration among developers.

5. Coding Style

Maintaining a consistent coding style across the project enhances readability, reduces errors and facilitates collaboration. The following guidelines outline our preferred coding style for C#:

Note: We have auto formatters in our project to make your life easier. Read more about them in the husky section.

5.1 C# Coding Style

5.1.1 Formatting
  • Indentation: Use tabs for indentation. Each level of indentation should consist of one tab.

  • Brace Placement: Place opening and closing braces on new lines.

    // Good
    if (condition)
    {
        // Code here
    }
    
    // Bad
    if (condition) {
        // Code here
    }
    
5.1.2 Naming Conventions
  • Pascal Case: Use Pascal case for class names, method names and property names.

    public class MyClass
    {
        public void MyMethod()
        {
            // Code here
        }
    
        public int MyProperty { get; set; }
    }
    
5.1.3 Language Features
  • Expression-bodied Members: Utilize expression-bodied members for concise one-liners.

    // Good
    public int CalculateSquare(int x) => x * x;
    
    // Bad
    public int CalculateSquare(int x)
    {
        return x * x;
    }
    
  • Null Conditional Operator: Use the null conditional operator (?.) for safe property or method access.

    // Good
    int? length = text?.Length;
    
    // Bad
    int length = (text != null) ? text.Length : 0;
    
    // or
    
    int length = text!.Length;
    
5.1.4 Special Cases

Usually you place public members after private members, but we have some exceptions:

  • Page constants: We place page ids and viewmodel ids at the top of the class.
    public const string PageId = "files.browser";
    public const MaterialIconKind PageIcon = MaterialIconKind.FolderEye;
    
5.1.5 Husky

We use husky to make sure that our code is formatted correctly before committing. You may use it for your own code.

  1. Go to the src folder
  2. run:
    dotnet tool restore
    
  3. run (use husky-unix instead of husky if you are on linux or macOS):
    dotnet r husky
    
  4. run the following command to format the code:
    dotnet husky run
    

5.2 Documentation

5.2.1 Comments
  • XML Documentation: Include XML comments for classes, methods, and properties to provide comprehensive documentation.

    /// <summary>
    /// Represents a sample class.
    /// </summary>
    public class SampleClass
    {
        /// <summary>
        /// Calculates the sum of two numbers.
        /// </summary>
        /// <param name="a">The first number.</param>
        /// <param name="b">The second number.</param>
        /// <returns>The sum of the two numbers.</returns>
        public int Add(int a, int b)
        {
            // Code here
        }
    }
    
5.2.2 Code Comments
  • Use comments sparingly and focus on explaining complex or non-intuitive code sections.

By adhering to these coding style guidelines, we aim to create code that is straightforward to read, understand, and maintain.

6. Version Control

Version control is a fundamental aspect of our development process, providing a systematic way to track changes, collaborate with team members and manage the evolution of our codebase. We use Git as our version control system.

6.1 Branching Strategy

6.1.1 Feature Branches

For each new feature or bug fix, create a dedicated feature branch. The branch name should be descriptive of the feature or issue it addresses.

# Example: Creating a new feature branch
git checkout -b feat/my-new-feature
6.1.2 Hotfix Branches

In case of critical issues in the production environment, create a hotfix branch. This allows for a quick resolution without affecting the main development branch.

# Example: Creating a hotfix branch
git checkout -b hotfix/1.0.1

6.2 Commit Messages

Write clear and concise commit messages that convey the purpose of the change. Follow these guidelines:

  • Start with a verb in the imperative mood (e.g., “Add,” “Fix,” “Update”).
  • Keep messages short but descriptive.
  • Use present tense.
  • Use feat, fix or chore prefixes to indicate the type of change.

Example:

# Good
git commit -m "feat: add user authentication feature"

# Bad
git commit -m "Updated stuff"

6.3 Pull Requests

Before merging changes into the main branch, create a pull request (PR). This allows for code review and ensures that changes adhere to coding standards.

  • Assign reviewers to the PR.
  • Include a clear description of the changes.
  • Ensure that automated tests pass before merging.

6.4 Merging Strategy

Adopt a merging strategy based on the nature of the changes:

  • Feature Branches: Merge feature branches into the main branch after code review and approval.
  • Release Branches: Merge release branches into the main branch and tag the commit for the release.
# Example: Merging a feature branch
git checkout main
git merge --no-ff feat/my-new-feature

6.5 Repository Hosting

Our Git repository is hosted on GitHub. Ensure that you have the necessary permissions and follow the best practices for repository management.

By following these version control practices, we aim to maintain a well-organized and collaborative development process.

7. Build and Deployment

The build and deployment processes are crucial parts of our development workflow. This section outlines the steps for building the project and deploying it using GitHub Actions.

7.1 Build Process

To compile the project, use the following command:

dotnet build

This command compiles the code and produces executable binaries.

7.2 Deployment using GitHub Releases

Our application is deployed using GitHub Actions.

The latest release can be found here.

8. Contributing

We welcome contributions from the community to help enhance and improve our project. Before contributing, please take a moment to review this guide.

8.1 Code Reviews

All code changes undergo a review process to ensure quality and consistency. Here are the steps to follow:

  1. Fork the Repository: Start by forking the repository to your own GitHub account.

  2. Create a Feature Branch: Create a new branch for your feature or bug fix.

    git checkout -b feat/my-feature
    
  3. Commit Changes: Make your changes, commit them with clear and concise messages, and push the branch to your forked repository.

    git commit -m "feat: add new feature"
    git push origin feat/my-feature
    
  4. Squash your commit: Squash your commits into a single commit before submitting a pull request.

   git rebase -i main
   
    # squash your commits into a single commit by leaving the first line as "pick" and changing the rest to "squash"
   
   git push --force-with-lease
  1. Open a Pull Request (PR): Submit a pull request to the main repository, detailing the changes made and any relevant information. Ensure your PR adheres to the established coding standards.

  2. Code Review: Participate in the code review process by responding to feedback and making necessary adjustments. Addressing comments promptly helps streamline the review process.

  3. Merge: Once the code review is complete and the changes are approved, your pull request will be merged into the main branch.

8.2 Submitting Changes

Before submitting changes, ensure the following:

  • Coding Standards: Adhere to the coding standards and guidelines outlined in this document.

  • Tests: If applicable, include tests for your changes and ensure that existing tests pass.

  • Documentation: Update relevant documentation, including code comments and external documentation, to reflect your changes.

8.3 Communication

For larger changes or feature additions, it’s beneficial to discuss the proposed changes beforehand. Engage with the community through:

  • Opening an Issue: Discuss your proposed changes by opening an issue. This provides an opportunity for community input before investing significant time in development.

  • Joining Discussions: Participate in existing discussions related to the project. Your insights and feedback are valuable.

8.4 Contributor License Agreement (CLA)

By contributing to this project, you agree that your contributions will be licensed under the project’s license. If a Contributor License Agreement (CLA) is required, it will be provided in the repository.

We appreciate your contributions, and together we can make this project even better!

9. Code Documentation

Clear and comprehensive code documentation is essential for ensuring that developers can easily understand, use and contribute to the project. Follow these guidelines for documenting your code:

9.1 Inline Comments

Use inline comments to explain specific sections of your code, especially for complex logic or non-intuitive implementations. Follow these principles:

  • Clarity: Write comments that enhance code comprehension. If a piece of code is not self-explanatory, provide comments explaining the reasoning or intention.

  • Conciseness: Keep comments concise and to the point. Avoid unnecessary comments that do not add value.

  • Update Comments: Regularly review and update comments to reflect any changes in the code. Outdated comments can be misleading.

Example:

// Calculate the sum of two numbers
int CalculateSum(int a, int b)
{
    return a + b;
}

9.2 XML Documentation

For classes, methods, properties and other significant code elements, use XML documentation comments to provide comprehensive information. Follow these guidelines:

  • Summary: Provide a summary that succinctly describes the purpose of the class or member.

  • Parameters: Document each parameter, specifying its purpose and any constraints.

  • Returns: If applicable, document the return value and its significance.

  • Examples: Include examples that demonstrate how to use the class or member.

Example:

/// <summary>
/// Represents a utility class for mathematical operations.
/// </summary>
public class MathUtility
{
    /// <summary>
    /// Calculates the sum of two numbers.
    /// </summary>
    /// <param name="a">The first number.</param>
    /// <param name="b">The second number.</param>
    /// <returns>The sum of the two numbers.</returns>
    public int CalculateSum(int a, int b)
    {
        return a + b;
    }
}

9.3 Consistency

Ensure consistency in your documentation style across the codebase. Consistent documentation makes it easier for developers to navigate and understand the project.

By following these documentation guidelines, we aim to create a codebase that is not only functional but also accessible and easily maintainable for all contributors.

10. Security

Ensuring the security of our software is paramount to maintaining the integrity and confidentiality of user data. Developers should adhere to best practices and follow guidelines outlined in this section.

10.1 Code Security Practices

10.1.1 Input Validation

Always validate and sanitize user input to prevent injection attacks and ensure the integrity of your application.

// Example for C#
public ActionResult ProcessUserInput(string userInput)
{
    if (string.IsNullOrWhiteSpace(userInput))
    {
        // Handle invalid input
    }

    // Process input
}
10.1.2 Authentication and Authorization

Implement secure authentication and authorization mechanisms to control access to sensitive functionalities and data. Leverage industry-standard protocols like OAuth when applicable.

10.1.3 Secure Communication

Ensure that communication between components, APIs and external services is encrypted using secure protocols (e.g., HTTPS).

10.2 Dependency Security

10.2.1 Dependency Scanning

Regularly scan and update dependencies to identify and address security vulnerabilities. Leverage tools and services that provide automated dependency analysis.

10.2.2 Minimal Dependencies

Keep dependencies to a minimum and only include libraries and packages that are actively maintained and have a good security track record.

10.3 Data Protection

10.3.1 Encryption

Sensitive data, both at rest and in transit, should be encrypted. Use strong encryption algorithms and ensure proper key management.

10.3.2 Data Backups

Implement regular data backup procedures to prevent data loss in the event of security incidents or system failures.

10.4 Secure Coding Standards

Adhere to secure coding standards to mitigate common vulnerabilities. Follow principles such as the OWASP Top Ten to address security concerns in your codebase.

10.5 Reporting Security Issues

If you discover a security vulnerability or have concerns about the security of the project, please report it privately to [email protected]. Do not disclose security-related issues publicly until they have been addressed.

10.6 Security Training

Encourage ongoing security training for all team members to stay informed about the latest security threats and best practices. Knowledgeable developers are key to maintaining a secure codebase.

By incorporating security practices into our development process, we aim to create a robust and secure software environment for our users.

11. License

This project is licensed under the terms of the MIT License. A copy of the MIT License is provided in the LICENSE file.

MIT License

MIT License

Copyright (c) 2023 Asv Soft LLC

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

Using the MIT License

The MIT License is a permissive open-source license that allows for the free use, modification and distribution of the software. It is important to review and understand the terms of the license before using, contributing to or distributing this software.

By contributing to this project, you agree that your contributions will be licensed under the MIT License.

For more details about the MIT License, please visit opensource.org/licenses/MIT.

12. Contact

If you have questions, suggestions, or need assistance with the project, we encourage you to reach out through the following channels:

12.1 Telegram Channel

Visit our Telegram channel: ASVSoft on Telegram

Feel free to join our Telegram community to engage in discussions, seek help, or share your insights.

12.2 GitHub Issues

For bug reports, feature requests or any project-related discussions, please use our GitHub Issues:

Project Issues on GitHub

Our GitHub repository is the central hub for project-related discussions and issue tracking. Please check existing issues before creating new ones to avoid duplication.

12.3 Security Concerns

If you discover a security vulnerability or have concerns about the security of the project, please report it privately to [email protected]. Do not disclose security-related issues publicly until they have been addressed.

12.4 General Inquiries

For general inquiries or if you prefer email communication, you can reach us at [email protected].

We value your feedback and contributions, and we look forward to hearing from you!

评论

暂无评论