RobotecAI / ros2-for-unity

High-performance ROS2 solution for Unity3D
Apache License 2.0
448 stars 58 forks source link

No ROS environment sourced. #32

Closed lpacademy0712 closed 2 years ago

lpacademy0712 commented 2 years ago

I have strictly followed the instructions in readme, and there are no errors reported during the period. However, "no ROS environment sourced." appeared during the initial test Problems. I'm sure I've run "source / opt / ROS / foxy / setup. bash" in the command window. Who can tell me how to operate to avoid such mistakes? I'm a novice, please give me a detailed operation description, thank you!

lpacademy0712 commented 2 years ago

2022-01-26 23-43-29屏幕截图 2022-01-26 23-44-08屏幕截图

lpacademy0712 commented 2 years ago

![Uploading 2022-01-27 00-09-13屏幕截图.png…]()

lpacademy0712 commented 2 years ago

![Uploading 2022-01-27 00-09-13屏幕截图.png…]()

pijaro commented 2 years ago

Hello, thank you for using ros2-for-unity!

Did you include source /opt/ROS/foxy/setup.bash line in ~/.profile file? If yes - did you restart ubuntu?

If you did not use profile file, then how did you launch the editor? If you run source /opt/ROS/foxy/setup.bash in a console then you have to run the editor within the same console or it won't use the sourced variables. To launch editor in console window:

<PATH_TO_UNITY_EDITOR> -projectPath <PATH_TO_PROJECT>

Unity Editor is most commonly installed in ~/Unity/Hub/Editor/<VERSION>/Editor/Unity.

adamdbrw commented 2 years ago

Also please make sure to restart UnityHub since it holds env variables which were set at the time it was started.

adamdbrw commented 2 years ago

@lpacademy0712 did any of our advice help?

adamdbrw commented 2 years ago

@lpacademy0712 a friendly bump, do you still have issue with this?

giorgiozannini commented 2 years ago

Good evening, I'm not the original poster but I'm having a similar problem. After sourcing ~/ros2_foxy/install/setup.bash and running the editor from command line and adding an empty object for the Ros2UnityComponent and dragging the Listener and Talker to the Camera and Light objects I do not get anymore the Ros2 sourcing error but instead: Running with a support ROS2 version: foxy but the talker and listener nodes throw a: NullReferenceException: object reference not set to an instance of an object: ROS2.ROS2TalkerExample.Update () (at Assets/Ros2ForUnity/Scripts/Ros2TalkerExample.cs:38) Could you kindly help me out? Thanks a lot for the code and the help!

pijaro commented 2 years ago

@giorgiozannini I'm looking into it :+1:

giorgiozannini commented 2 years ago

Thanks a lot!!!

pijaro commented 2 years ago

@giorgiozannini Current example scripts require ROS2UnityComponent to be in the same game object. We can see that this is definitely not optimal, we will change it in a near future.

And indeed, this isn't obvious with the current version of the readme. We will address it. Meanwhile please try to move ROS2UnityComponent to a game object with examples script (or move them all to one script).

giorgiozannini commented 2 years ago

It works! thanks a lot for your help, I wish you a wonderful rest of the day! Giorgio

pijaro commented 2 years ago

Glad I could help :smiley:

Closing since the issue is resolved.