toppers / hakoniwa-unity-drone-model

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.
10 stars 1 forks source link

Linux Support #29

Open andrearlotta opened 1 month ago

andrearlotta commented 1 month ago

Hey there,

First of all, thanks for your efforts on integrating Unity with PX4.

Secondly, I am trying to use your framework on Ubuntu 22, and here are my issues:

  1. Where can I find a guide to use your framework on Ubuntu?

  2. Do I need to use Docker on Ubuntu?

  3. In Unity, should I use the UDP method or the default one? Furthermore, if I switch from the default mode to UDP, the custom.json file still shows the parameter:

    "method_type": "SHM"
  4. When I try to launch the Unity build executable, the splash screen shows up, but the app crashes without showing any errors in the log file hakoniwa_core.log.

Thanks a lot in advance for your attention. I look forward to hearing from you soon.

すぐ

tmori commented 1 month ago

Hi,

Thank you for your questions and for using our framework. Here are the answers to your inquiries:

1. Guide for Using the Framework on Ubuntu

For information on running the simulation with PX4 integration, please refer to the README at https://github.com/toppers/hakoniwa-px4sim.

The PX4 installation steps are detailed here: https://github.com/toppers/hakoniwa-px4sim/tree/main/px4

The installation steps for Hakoniwa can be found here: https://github.com/toppers/hakoniwa-px4sim/tree/main/hakoniwa

We have also published the Ubuntu-compatible Unity setup today. You can find the instructions here: https://github.com/toppers/hakoniwa-unity-drone-model

2. Docker Usage on Ubuntu

Docker is not required for running the framework on Ubuntu.

3. UDP Method vs. Default Method in Unity

UDP communication settings are only necessary when using WSL2. For Ubuntu, there is no need to modify the custom.json file. Following the provided instructions to generate the configuration will work correctly.

4. Application Crash on Launch

The crash might be occurring because the Unity application is not built for Linux. We have released a Linux-compatible version of the application today. Please download and use the DroneAppLinux.zip from the following link: https://github.com/toppers/hakoniwa-unity-drone-model/releases/tag/v2.1.0

Thank you for your patience and support. If you have any further questions or issues, feel free to ask.

Best regards,

Takashi Mori

andrearlotta commented 1 month ago

Hey there, thanks for your super fast response!

I followed your guidelines. I would like to point out an issue while building the Hakoniwa module: ldopen was not a linked library. Here’s a modified version of the file that allows the build to complete correctly: Cmakelist.txt

The ./plugin/activate_app.bash file for running Unity does not allow the simulation to run on Ubuntu. This version might be correct:mod.bash

Sadly, when running the simulation, after seeing the Unity splash screen, it crashes with the following error: ./plugin/activate_app.bash: line 51: 2442370 Segmentation fault (core dumped) ./${APP_NAME}

I hope this information is useful.

Hope to hear from you soon, ありがとう Andrea

tmori commented 1 month ago

Thank you for the changes in CMakeLists.txt and mod.bash.

To confirm, could you please provide the output of the following commands?

$ cat /etc/lsb-release
$ uname -a
$ arch

For reference, here is the output from my environment:

$ cat /etc/lsb-release
DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=22.04
DISTRIB_CODENAME=jammy
DISTRIB_DESCRIPTION="Ubuntu 22.04.4 LTS"

$ uname -a
Linux tmori-20t0cto1ww 6.5.0-41-generic #41~22.04.2-Ubuntu SMP PREEMPT_DYNAMIC Mon Jun 3 11:32:55 UTC 2 x86_64 x86_64 x86_64 GNU/Linux

$ arch
x86_64

Best regards,

Takashi Mori

andrearlotta commented 1 month ago
$ cat /etc/lsb-release; uname -a; arch
DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=20.04
DISTRIB_CODENAME=focal
DISTRIB_DESCRIPTION="Ubuntu 20.04.6 LTS"
Linux bartolo2 5.15.0-52-generic #58~20.04.1-Ubuntu SMP Thu Oct 13 13:09:46 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux
x86_64

My bad, I thought I was working with Ubuntu 22; however, I am using Ubuntu 20. Do you think this is the core issue? greetings, Andrea Arlotta

tmori commented 1 month ago

My bad, I thought I was working with Ubuntu 22; however, I am using Ubuntu 20. Do you think this is the core issue? greetings,

The reason the build didn't pass is probably due to the version of Ubuntu. In Ubuntu 22, it passed without needing the dlopen link setting.

However, I believe the reason the Unity application crashes with a segmentation fault is due to an issue with the simulation execution procedure or settings.

You can check whether the settings are correct by using the hako-setup-check.bash script as described in the following document:

https://github.com/toppers/hakoniwa-px4sim/tree/main/hakoniwa#for-macubuntu

The simulation execution procedure must be carried out in the following order. The Unity application should be started after the run.bash script has been correctly executed.

  1. Terminal A

    bash ../sim/simstart.bash
  2. Terminal B

    bash run.bash
  3. Terminal for starting the Unity application

    bash ./plugin/activate_app.bash DroneAppLinux

Here is a demo of executing the above commands.

https://www.youtube.com/watch?v=kaMoEZVsVlk

Regarding the issue you pointed out with activate_app.bash, it was due to a lack of updates in the repository. I apologize for this, but it has been addressed in the following commit.

https://github.com/toppers/hakoniwa-unity-drone-model/commit/23aabb5f88672e57d07536388fe1eaf4161b5da6