edvart-ros / unity_asv_sim

Simulation platform for Unmanned/Autonomous surface vehicles implemented in Unity, with ROS 2 integration.
36 stars 6 forks source link

MissingReferenceException: The variable simplifiedMesh of Submersion doesn't exist anymore. #24

Open david-dorf opened 4 months ago

david-dorf commented 4 months ago

Thanks again for making this simulator, looks great and has a lot of potential. Would be interested in contributing!

Steps to reproduce: Run with the wiki recommended version of Unity and Ubuntu 24.04.

Possibly related: Large waves seem to cause boat to sink and float in the air dramatically.

Full error log in Unity:

MissingReferenceException: The variable simplifiedMesh of Submersion doesn't exist anymore. You probably need to reassign the simplifiedMesh variable of the 'Submersion' script in the inspector. UnityEngine.Object+MarshalledUnityObject.TryThrowEditorNullExceptionObject (UnityEngine.Object unityObj, System.String parameterName) (at /home/bokken/build/output/unity/unity/Runtime/Export/Scripting/UnityEngineObject.bindings.cs:710) UnityEngine.Bindings.ThrowHelper.ThrowNullReferenceException (System.Object obj) (at /home/bokken/build/output/unity/unity/Runtime/Export/Scripting/BindingsHelpers.cs:61) UnityEngine.Mesh.get_canAccess () (at <2339a4d0488949fd9e12ae0fed749682>:0) UnityEngine.Mesh.GetAllocArrayFromChannel[T] (UnityEngine.Rendering.VertexAttribute channel, UnityEngine.Rendering.VertexAttributeFormat format, System.Int32 dim) (at /home/bokken/build/output/unity/unity/Runtime/Export/Graphics/Mesh.cs:40) UnityEngine.Mesh.GetAllocArrayFromChannel[T] (UnityEngine.Rendering.VertexAttribute channel) (at /home/bokken/build/output/unity/unity/Runtime/Export/Graphics/Mesh.cs:54) UnityEngine.Mesh.get_vertices () (at /home/bokken/build/output/unity/unity/Runtime/Export/Graphics/Mesh.cs:141) WaterInteraction.Submerged..ctor (UnityEngine.Mesh simplifiedHullMesh, System.Boolean debug) (at Assets/Scripts/Physics/Processing/SubmersionLib.cs:58) Submersion.Start () (at Assets/Scripts/Physics/Processing/Submersion.cs:37)

Screencast from 2024-07-19 19-53-15.webm

edvart-ros commented 4 months ago

Are you talking about the unrealistic behaviour in the video, or are you talking about the physics exploding? I had a lot of issues with exploding whenever the boat would hit the water too hard. This often occured when I was trying to simulate hydrodynamic damping forces without fake damping (e.g unity's built-in linear and angular damping) with default time-steps. Still, would only happen with very large waves or big drops (see https://en.wikipedia.org/wiki/Stiff_equation).

The model isnt perfect, and the more extreme the ocean state - the less realistic it looks. It's hard to model, and this was the best I was able to implement in time for my thesis submittal 😅 . You can always tweak the parameters, but you'll only get so far.

I'm glad people are having a go with the project. Unfortunately, I totally do not have the capacity to actively maintain it. If someone finds it useful, that's great, and I'm happy to provide some advice on issues that come up.

edvart-ros commented 4 months ago

If anyone wants to improve the physics model, the thing that's missing is some kind of "slamming force" (See Jacques kerner's article: https://www.gamedeveloper.com/programming/water-interaction-model-for-boats-in-video-games-part-2). Slamming behaviour is weird, and I didn't have time to implement a force that accounts for violent slamming-related forces. To implement this, one would have to somehow model how harshly the boat is colliding with the ocean. Kerner presents a way to do this.

luis-robotic commented 4 months ago

Hi edvart-ros, that's a really nice project. I am interested in contributing too but I am quite new in Unity. I was searching for the TF representation on RVIZ2. How can I visualize it? Is it included in some of the example scenes?

edvart-ros commented 4 months ago

TF is not published automatically, only sensor outputs. You could make your own URDF representing the robot (corresponding to the one in Unity) and do standard ros-side TF publishing. That's essentially what's done here: https://github.com/edvart-ros/unity_asv_sim/wiki/Setting-up-and-configuring-sensors#visualizing-the-sensor-data-in-rviz