o3de / o3de-extras

Other
63 stars 63 forks source link

ROS2 Manipulation crashes as the game mode starts #796

Open fjnn opened 4 days ago

fjnn commented 4 days ago

Describe the bug I have installed O3DE using .deb on my Ubuntu 24.04 and I have ROS2 Jazzy. I created a new project using ROS2 Manipulation template. There were a few missing gems (ROS2, WarehouseAssets and WarehouseAutomation) and I added them using the editor. My project was successfully built and I can see the Panda robot in the editor.

However, when I press the "Play Game (Ctrl+G)" or in full mode, the editor crashes. No crash report, no log, nothing to provide here. Since I run O3DE via terminal, I see that i enters the game mode, but nothing shows up.

PS. I am very new to O3DE and I assume that I need to run the simulation to see the relevant ROS topics right? Or am I missing something?

jhanca-robotecai commented 4 days ago

I can confirm the problem on Ubuntu 24.04 with ROS 2 Jazzy when using o3de binaries.

Ubuntu 24.04 with ROS 2 Jazzy (the manipulation template):

Ubuntu 22.04 with ROS 2 Humble (the manipulation template):

From what I know o3de binaries are built on Ubuntu 22.04...

michalpelka commented 3 days ago

@jhanca-robotecai please check if the issue is not caused by camera pipeline modification. Modify registry to :

{
    "O3DE":
    {
        "InputSystem":
        {
            "Mouse":
            {
                "CaptureMouseCursor": false
            }
        },
        "ROS2":
        {
            "SteadyClock" : true,
            "Camera":
            {
                "AllowPipelineModification": false
            }
        }
    }
}
jhanca-robotecai commented 2 days ago

The registry does not change anything, camera is not a problem. The template is not a problem either.

I managed to replicate the issue with an empty project with ROS2 Gem and a single entity with ROS 2 Frame component.

fjnn commented 2 days ago

Update: I see here that for ROS2 projects, we need to build O3DE from source: https://docs.o3de.org/docs/user-guide/interactivity/robotics/project-configuration/

I am trying doing it right now although I have other issues on that as I created another issue #797 I would like to keep this issue open since it would be nice be able to create ROS2 projects via debian installation.

jhanca-robotecai commented 2 days ago

The issue should stay open until it is solved.

There is no reason to build O3DE from the source in many cases. The gem should work with o3de-sdk. I can confirm it works correctly with Ubuntu 22.04 and ROS 2 Humble. I can also confirm it does not in the case of Ubuntu 24.04 and ROS 2 Jazzy. I am trying to debug it, it looks like a problem with the ROS 2 Clock implementation:

<14:33:45> Entered game mode
Process 12422 stopped
* thread #1, name = 'o3de.editor', stop reason = signal SIGSEGV: address not mapped to object (fault address: 0x10)
    frame #0: 0x00007ffed91efd5e libROS2.Editor.so`ROS2::ROS2Clock::GetROSTimestamp() const [inlined] std::__uniq_ptr_impl<ROS2::ITimeSource, std::default_delete<ROS2::ITimeSource>>::_M_ptr(this=0x0000000000000010) const at unique_ptr.h:199:51
   196        _GLIBCXX23_CONSTEXPR
   197        pointer&   _M_ptr() noexcept { return std::get<0>(_M_t); }
   198        _GLIBCXX23_CONSTEXPR
-> 199        pointer    _M_ptr() const noexcept { return std::get<0>(_M_t); }
   200        _GLIBCXX23_CONSTEXPR
   201        _Dp&       _M_deleter() noexcept { return std::get<1>(_M_t); }
   202        _GLIBCXX23_CONSTEXPR
jhanca-robotecai commented 2 days ago

More debugging info, as someone else might want to try to debug the issue as well. Very strange.

The problem is caused by the ROS2EditorSystemComponent, which should activate ROS2SystemComponent when the game mode starts (this way ROS2 clock does not run in the Editor). To do that, the component handles OnStartPlayInEditorBegin() notification from EditorEntityContextNotificationBus. This method is not called when running the binary on Ubuntu 24.04 (we tried OnStartPlayInEditor() as well). It is called when running the same binary package on Ubuntu 22.04 or when building o3de engine from source on Ubuntu 24.04.