DynoRobotics / UnityRos2

77 stars 22 forks source link

How to solve 'UnsatisfiedLinkError: librcl.so' ? #5

Closed b2220333 closed 5 years ago

b2220333 commented 5 years ago

I can not find 2018.3.6f1 on Unity Hub 1.5.0, so I use 2018.3.14f1.

I open Turtlebot3NavigationDemo scene and click the play button, and it shows errors:

UnsatisfiedLinkError: librcl.so
ROS2.Utils.DllLoadUtilsUnix.LoadLibraryNoSuffix (System.String fileName) (at <7c5753d3542344c3a4e47d09c768d276>:0)
rclcs.NativeMethods..cctor () (at <6c64258d7ee947c7b2100cf5d200ba13>:0)
Rethrow as TypeInitializationException: The type initializer for 'rclcs.NativeMethods' threw an exception.
LaserScanPublisher..ctor () (at Assets/Scripts/Ros/Sensors/LaserScanPublisher.cs:47)

This error shows on many items on unity3d.

I am able to find librcl.so by

sam@sam-ub1804:~$ locate librcl.so
/opt/ros/crystal/lib/librcl.so
sam@sam-ub1804:~$ 

How to solve this problem? Thank you~

Sam

samiamlabs commented 5 years ago

A possible reason for this error is that flatpack apps like UnityHub (.appimage) don't pick up environment variables properly on all operating systems. When you have installed a release of Unity you should be able to open the Unity editor directly in a terminal from the install path with the workspace sourced. Hopefully this will fix the linking problem.

This project was developed mainly on Windows 10 and support added to xenial. Have not tried running it on bionic yet except for compiling the release. There may still be some cross platform issues that I need to fix.

Will try to get the example project running on my system with bionic later today and make sure that it works.

samiamlabs commented 5 years ago

I got it running on xenial by starting the Unity Editor using UnityHub, so I don't think you will need to start the editor directly in the terminal as I suggested earlier.

Are you sure you followed the instruction: "Make sure you open Unity(Hub) in a terminal with everything sourced"? Maybe that instruction could be better written. Unity needs to be started with the correct environment variables set by running setup.bash in order for the linker to find all ROS2 related libraries.

b2220333 commented 5 years ago

I have tried run UnityHub on terminal with ROS2 environments:

sam@sam-ub1804:~/code/unity3d$ source ~/code/unity3d/ros2_unity_ws/install/setup.bash
sam@sam-ub1804:~/code/unity3d$ ros2
usage: ros2 [-h] Call `ros2 <command> -h` for more detailed usage. ...

ros2 is an extensible command-line tool for ROS 2.

optional arguments:
  -h, --help            show this help message and exit

Commands:
  daemon     Various daemon related sub-commands
  launch     Run a launch file
  lifecycle  Various lifecycle related sub-commands
  msg        Various msg related sub-commands
  multicast  Various multicast related sub-commands
  node       Various node related sub-commands
  param      Various param related sub-commands
  pkg        Various package related sub-commands
  run        Run a package specific executable
  security   Various security related sub-commands
  service    Various service related sub-commands
  srv        Various srv related sub-commands
  topic      Various topic related sub-commands

  Call `ros2 <command> -h` for more detailed usage.
sam@sam-ub1804:~/code/unity3d$ ls
ros2_unity_ws  standalone-unity-ws-0.0.1-beta-linux-bionic-amd64.tar.bz2  UnityHubSetup.AppImage
sam@sam-ub1804:~/code/unity3d$ ./UnityHubSetup.AppImage 

However, it appears the same problem. 2019-05-29 14-30-18 的螢幕擷圖

How could I check everything that needed? Thank you~

samiamlabs commented 5 years ago

Can you verify that you are starting the example project like in the video below @b2220333 (sorry about the video quality...): https://www.youtube.com/watch?v=HJxrYHRNP4s&feature=youtu.be

If you still have the same issue you can try starting it like this: https://www.youtube.com/watch?v=OyS1op-w9mw&feature=youtu.be

b2220333 commented 5 years ago

Wow, method1 still have problem, but method2 works!

~/Unity/Hub/Editor/2018.3.14f1/Editor/Unity

sam@sam-ub1804:~$ ros2 topic list
/ExecuteMissionTask_command
/amcl_pose
/cmd_vel
/joint_commands
/joint_states
/move_base_simple/goal
/odom
/parameter_events
/plan
/rosout
/scan
/tf
/tf_static
sam@sam-ub1804:~$ 

Thank you very much! Sam