Skip to content

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.

Notifications You must be signed in to change notification settings

0xopsdev/unity-drone-model

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

image

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

Tojinbo 3D Model

The Tojinbo 3D model was created with the generous support of the following individuals:

This model could not have been completed without their invaluable assistance. We deeply appreciate their contributions to Hakoniwa's OSS initiatives.

For instructions on integrating the Tojinbo 3D model into the Hakoniwa Drone Simulator, please refer to this guide.

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/meta0xflip/unity-drone-model.git

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

cd unity-drone-model/

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

https://github.com/meta0xflip/unity-drone-model/releases

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

The directory structure will be as follows:

unity-drone-model/DroneApp<OS>

Launching the Unity Application

Run the following command directly under the 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/meta0xflip/unity-drone-model.git

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

cd 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: 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"
        }
      ]
    }
  ]
}

About

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.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published