Skip to content

Unity-based drone simulator for seamless integration with PX4, offering realistic flight dynamics and visualization. Designed for flexible simulations with support for external game engines and headless operation capabilities.

Notifications You must be signed in to change notification settings

toppers/hakoniwa-unity-drone-model

Repository files navigation

English | 日本語

Here is the English version of your GitHub README:


This repository contains a drone simulator created with Unity that is compatible with PX4.

The simulator can be used for real-time drone flight simulation and testing flight control algorithms.

For those who want to use the Hakoniwa Drone Simulator on native Windows, please refer to this.

Table of Contents

Hakoniwa Drone Model

The drone model created in Unity is an original Hakoniwa model and is a quadcopter type (as shown below).

image

Unity assets of the Hakoniwa Drone Model H1 are based on data provided by Mr. Hodaka Nakamura of Ida B. Wells-Barnett High School. We want to express our deepest gratitude for his awesome contribution :D

Integration with PX4

To integrate this drone simulator with PX4, the hakoniwa-px4sim repository is required. For detailed instructions on how to integrate with PX4, please read the documentation at the following link:

https://github.com/toppers/hakoniwa-px4sim

Supported Environments

  • Intel-based Mac
  • Arm-based Mac
  • Ubuntu
  • Windows 10/11

Usage Instructions

The Hakoniwa Drone Model for Unity can be used in two ways:

  1. Using the Unity Application
  2. Using the Unity Editor

For the first method, there is no setup hassle as you use a pre-built application.

For the second method, you will use the Unity Editor, which requires some setup.

Using the Unity Application

Required Environment for Using the Unity Application

No specific Unity environment is required.

Installation Instructions for Using the Unity Application

Clone the repository as follows:

git clone --recursive https://github.com/toppers/hakoniwa-unity-drone-model.git

Once the cloning is complete, navigate to the directory as follows:

cd hakoniwa-unity-drone-model/

Download the application suitable for your environment from the following site:

https://github.com/toppers/hakoniwa-unity-drone-model/releases

Unzip the downloaded file under the hakoniwa-unity-drone-model directory.

The directory structure will be as follows:

hakoniwa-unity-drone-model/DroneApp<OS>

Launching the Unity Application

Run the following command directly under the hakoniwa-unity-drone-model directory:

bash ./plugin/activate_app.bash DroneApp<OS>

For the Windows native app, double-click DroneWinNative/model.exe.

If successful, the Unity application will launch.

Using the Unity Editor

Required Environment for Using the Unity Editor

  • Homebrew (Mac only)
  • Unity Hub
  • Unity (compatible with your CPU architecture)
    • Version 2022.3.5f1 or later

Installation Instructions for Using the Unity Editor

Clone the repository as follows:

git clone --recursive https://github.com/toppers/hakoniwa-unity-drone-model.git

Once the cloning is complete, navigate to the directory as follows:

cd hakoniwa-unity-drone-model/

Then, install the necessary Unity modules.

For MacOS/Ubuntu and WSL2:

bash install.bash 

For Windows:

bash install.bash win

Launching Unity

Open the project in Unity Hub.

Note: Ensure that the Unity Editor version matches your CPU architecture.

Target folder: hakoniwa-unity-drone-model\plugin\plugin-srcs

If a message about "Opening Project in Non-Matching Editor Installation" appears, click "Continue."

In the following dialog, click Continue.

image

Next, ignore the following dialog.

image

If successful, you will see this.

image

Upon initial launch, there may be many errors in the console due to the following reasons. Please follow the links to address them sequentially:

Preparing the Simulation Environment

Double-click the Unity scene (Assets/Scenes/ApiDemo) as shown below.

image

Generating Configuration Files

Click Window -> Hakoniwa -> Generate.

Screenshot

If successful, you will see JSON logs in the console without any error logs.

Screenshot

For Windows, this operation must be repeated after every machine reboot.

Configuration Files

The generated configuration files will be located directly under hakoniwa-unity-drone-model\plugin\plugin-srcs.

The output of custom.json is as follows:

{
  "robots": [
    {
      "name": "DroneTransporter",
      "rpc_pdu_readers": [],
      "rpc_pdu_writers": [],
      "shm_pdu_readers": [
        {
          "type": "hako_mavlink_msgs/HakoHilActuatorControls",
          "org_name": "drone_motor",
          "name": "DroneTransporter_drone_motor",
          "class_name": "Hakoniwa.PluggableAsset.Communication.Pdu.Raw.RawPduReader",
          "conv_class_name": "Hakoniwa.PluggableAsset.Communication.Pdu.Raw.RawPduReaderConverter",
          "channel_id": 0,
          "pdu_size": 112,
          "write_cycle": 1,
          "method_type": "SHM"
        },
        {
          "type": "geometry_msgs/Twist",
          "org_name": "drone_pos",
          "name": "DroneTransporter_drone_pos",
          "class_name": "Hakoniwa.PluggableAsset.Communication.Pdu.Raw.RawPduReader",
          "conv_class_name": "Hakoniwa.PluggableAsset.Communication.Pdu.Raw.RawPduReaderConverter",
          "channel_id": 1,
          "pdu_size":

 72,
          "write_cycle": 1,
          "method_type": "SHM"
        },
        {
          "type": "hako_msgs/ManualPosAttControl",
          "org_name": "drone_manual_pos_att_control",
          "name": "DroneTransporter_drone_manual_pos_att_control",
          "class_name": "Hakoniwa.PluggableAsset.Communication.Pdu.Raw.RawPduWriter",
          "conv_class_name": "Hakoniwa.PluggableAsset.Communication.Pdu.Raw.RawPduWriterConverter",
          "channel_id": 3,
          "pdu_size": 80,
          "write_cycle": 1,
          "method_type": "SHM"
        },
        {
          "type": "hako_msgs/HakoDroneCmdTakeoff",
          "org_name": "drone_cmd_takeoff",
          "name": "DroneTransporter_drone_cmd_takeoff",
          "class_name": "Hakoniwa.PluggableAsset.Communication.Pdu.Raw.RawPduWriter",
          "conv_class_name": "Hakoniwa.PluggableAsset.Communication.Pdu.Raw.RawPduWriterConverter",
          "channel_id": 5,
          "pdu_size": 64,
          "write_cycle": 1,
          "method_type": "SHM"
        },
        {
          "type": "hako_msgs/HakoDroneCmdMove",
          "org_name": "drone_cmd_move",
          "name": "DroneTransporter_drone_cmd_move",
          "class_name": "Hakoniwa.PluggableAsset.Communication.Pdu.Raw.RawPduWriter",
          "conv_class_name": "Hakoniwa.PluggableAsset.Communication.Pdu.Raw.RawPduWriterConverter",
          "channel_id": 6,
          "pdu_size": 80,
          "write_cycle": 1,
          "method_type": "SHM"
        },
        {
          "type": "hako_msgs/HakoDroneCmdLand",
          "org_name": "drone_cmd_land",
          "name": "DroneTransporter_drone_cmd_land",
          "class_name": "Hakoniwa.PluggableAsset.Communication.Pdu.Raw.RawPduWriter",
          "conv_class_name": "Hakoniwa.PluggableAsset.Communication.Pdu.Raw.RawPduWriterConverter",
          "channel_id": 7,
          "pdu_size": 64,
          "write_cycle": 1,
          "method_type": "SHM"
        },
        {
          "type": "hako_msgs/GameControllerOperation",
          "org_name": "hako_cmd_game",
          "name": "DroneTransporter_hako_cmd_game",
          "class_name": "Hakoniwa.PluggableAsset.Communication.Pdu.Raw.RawPduWriter",
          "conv_class_name": "Hakoniwa.PluggableAsset.Communication.Pdu.Raw.RawPduWriterConverter",
          "channel_id": 8,
          "pdu_size": 136,
          "write_cycle": 1,
          "method_type": "SHM"
        },
        {
          "type": "hako_msgs/HakoCmdCamera",
          "org_name": "hako_cmd_camera",
          "name": "DroneTransporter_hako_cmd_camera",
          "class_name": "Hakoniwa.PluggableAsset.Communication.Pdu.Raw.RawPduWriter",
          "conv_class_name": "Hakoniwa.PluggableAsset.Communication.Pdu.Raw.RawPduWriterConverter",
          "channel_id": 9,
          "pdu_size": 44,
          "write_cycle": 1,
          "method_type": "SHM"
        },
        {
          "type": "hako_msgs/HakoCmdCameraMove",
          "org_name": "hako_cmd_camera_move",
          "name": "DroneTransporter_hako_cmd_camera_move",
          "class_name": "Hakoniwa.PluggableAsset.Communication.Pdu.Raw.RawPduWriter",
          "conv_class_name": "Hakoniwa.PluggableAsset.Communication.Pdu.Raw.RawPduWriterConverter",
          "channel_id": 11,
          "pdu_size": 64,
          "write_cycle": 1,
          "method_type": "SHM"
        },
        {
          "type": "hako_msgs/HakoCmdMagnetHolder",
          "org_name": "hako_cmd_magnet_holder",
          "name": "DroneTransporter_hako_cmd_magnet_holder",
          "class_name": "Hakoniwa.PluggableAsset.Communication.Pdu.Raw.RawPduWriter",
          "conv_class_name": "Hakoniwa.PluggableAsset.Communication.Pdu.Raw.RawPduWriterConverter",
          "channel_id": 13,
          "pdu_size": 40,
          "write_cycle": 1,
          "method_type": "SHM"
        }
      ],
      "shm_pdu_writers": [
        {
          "type": "hako_msgs/Collision",
          "org_name": "drone_collision",
          "name": "DroneTransporter_drone_collision",
          "class_name": "Hakoniwa.PluggableAsset.Communication.Pdu.Raw.RawPduWriter",
          "conv_class_name": "Hakoniwa.PluggableAsset.Communication.Pdu.Raw.RawPduWriterConverter",
          "channel_id": 2,
          "pdu_size": 304,
          "write_cycle": 1,
          "method_type": "SHM"
        },
        {
          "type": "hako_msgs/Disturbance",
          "org_name": "drone_disturbance",
          "name": "DroneTransporter_drone_disturbance",
          "class_name": "Hakoniwa.PluggableAsset.Communication.Pdu.Raw.RawPduWriter",
          "conv_class_name": "Hakoniwa.PluggableAsset.Communication.Pdu.Raw.RawPduWriterConverter",
          "channel_id": 4,
          "pdu_size": 32,
          "write_cycle": 1,
          "method_type": "SHM"
        },
        {
          "type": "hako_msgs/HakoCameraData",
          "org_name": "hako_camera_data",
          "name": "DroneTransporter_hako_camera_data",
          "class_name": "Hakoniwa.PluggableAsset.Communication.Pdu.Raw.RawPduWriter",
          "conv_class_name": "Hakoniwa.PluggableAsset.Communication.Pdu.Raw.RawPduWriterConverter",
          "channel_id": 10,
          "pdu_size": 102968,
          "write_cycle": 1,
          "method_type": "SHM"
        },
        {
          "type": "hako_msgs/HakoCameraInfo",
          "org_name": "hako_cmd_camera_info",
          "name": "DroneTransporter_hako_cmd_camera_info",
          "class_name": "Hakoniwa.PluggableAsset.Communication.Pdu.Raw.RawPduWriter",
          "conv_class_name": "Hakoniwa.PluggableAsset.Communication.Pdu.Raw.RawPduWriterConverter",
          "channel_id": 12,
          "pdu_size": 56,
          "write_cycle": 1,
          "method_type": "SHM"
        },
        {
          "type": "hako_msgs/HakoStatusMagnetHolder",
          "org_name": "hako_status_magnet_holder",
          "name": "DroneTransporter_hako_status_magnet_holder",
          "class_name": "Hakoniwa.PluggableAsset.Communication.Pdu.Raw.RawPduWriter",
          "conv_class_name": "Hakoniwa.PluggableAsset.Communication.Pdu.Raw.RawPduWriterConverter",
          "channel_id": 14,
          "pdu_size": 32,
          "write_cycle": 1,
          "method_type": "SHM"
        },
        {
          "type": "sensor_msgs/PointCloud2",
          "org_name": "lidar_points",
          "name": "DroneTransporter_lidar_points",
          "class_name": "Hakoniwa.PluggableAsset.Communication.Pdu.Raw.RawPduWriter",
          "conv_class_name": "Hakoniwa.PluggableAsset.Communication.Pdu.Raw.RawPduWriterConverter",
          "channel_id": 15,
          "pdu_size": 177400,
          "write_cycle": 5,
          "method_type": "SHM"
        },
        {
          "type": "geometry_msgs/Twist",
          "org_name": "lidar_pos",
          "name": "DroneTransporter_lidar_pos",
          "class_name": "Hakoniwa.PluggableAsset.Communication.Pdu.Raw.RawPduWriter",
          "conv_class_name": "Hakoniwa.PluggableAsset.Communication.Pdu.Raw.RawPduWriterConverter",
          "channel_id": 16,
          "pdu_size": 72,
          "write_cycle": 5,
          "method_type": "SHM"
        }
      ]
    }
  ]
}

Community and Support

Questions and discussions about this project are conducted on the Hakoniwa Community Forum. Here, you can resolve doubts about the project, share ideas, and provide feedback. The latest information and updates about the project are also shared here.

If you have questions, suggestions, or want to discuss issues faced by other users, feel free to post here.

Repository Contents and License

Regarding the content

of this repository, if the license is specified in each file, follow that license. For content that is not explicitly mentioned, it is published under the TOPPERS License.

The TOPPERS License is an open-source license for projects, outlining conditions for software use, modification, and distribution. For details, refer to the link above.

Contribution Guidelines

Thank you for your interest in contributing to this project. Various forms of contributions are welcome. Below are guidelines on how to contribute to the project.

Reporting Issues

  • Report bugs and propose new features through GitHub Issues.
  • Before creating an issue, check if a similar issue already exists.
  • Provide as much information as possible when creating an issue. This includes reproduction steps, expected behavior, actual behavior, and the environment used.

Pull Requests

  • Contribute code changes such as feature additions and bug fixes through pull requests.
  • For major changes or new features, it is recommended to discuss them in a related issue beforehand.
  • Ensure consistent coding style and conventions by following the existing code style.

Communication

  • Discuss and ask questions about the project in Discussions.
  • Communicate respectfully with other contributors.

Other Contributions

  • Improvements to documentation and translations, among other non-code contributions, are also welcome.

About

Unity-based drone simulator for seamless integration with PX4, offering realistic flight dynamics and visualization. Designed for flexible simulations with support for external game engines and headless operation capabilities.

Topics

Resources

Stars

Watchers

Forks

Packages

No packages published