lucasw / ros_from_src

Build ros from source without using a PPA in a github action. Probably just copy what archlinux is doing. See also https://github.com/ros-o/ros-o
BSD 3-Clause "New" or "Revised" License
104 stars 16 forks source link

Build O3DE from source and use with ros2 rolling #41

Closed lucasw closed 5 months ago

lucasw commented 5 months ago

https://www.docs.o3de.org/

https://www.docs.o3de.org/docs/welcome-guide/setup/setup-from-github/

git clone https://github.com/o3de/o3de.git

Not sure about the source vs. pre-built sdk- does the source engine require recompiling more per-project?

This step is optional because in the “source engine” build model, the engine is built inside of every project. If you plan on working with projects, to avoid building the engine twice, consider waiting until you learn how to create and build a project, which is covered in the Project Creation section.

-> Going with source for now, just build one project

https://www.docs.o3de.org/docs/welcome-guide/setup/setup-from-github/building-linux/ https://www.docs.o3de.org/docs/user-guide/build/distributable-engine/

lucasw commented 5 months ago
cd o3de
# ~/.o3de/3rdParty/packages will be used by default
# mkdir ../o3de-packages
python/get_python.sh
cmake -B build/linux -S . -G "Ninja Multi-Config"
-- The C compiler identification is Clang 16.0.6
-- The CXX compiler identification is Clang 16.0.6
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /usr/bin/clang-16 - skipped
...
-- Using package /home/lucasw/.o3de/3rdParty/packages/OpenMesh-8.1-rev3-linux
-- Configuring done (37.6s)
-- Generating done (4.2s)
-- Build files have been written to: ..../sim/o3de/build/linux
scripts/o3de.sh register --this-engine
lucasw commented 5 months ago

Make a project

https://www.docs.o3de.org/docs/welcome-guide/create/creating-projects-using-cli/

https://www.docs.o3de.org/docs/welcome-guide/create/creating-projects-using-cli/creating-linux/

scripts/o3de.sh create-project --project-path `pwd`/../o3de_ros_project

In ~/.o3de/o3de_manifest.json there will be an projects and restricted entry for the project:

    "projects": [
        "<PATH>/o3de_ros_project",
cd ../o3de_ros_project
cmake -B build/linux -S . -G "Ninja Multi-Config"
cmake --build build/linux --target o3de_ros_project.GameLauncher Editor --config profile -j 4

Now go do something else for a while:

[12/1399] Building CXX object o3de/Code/Framework/AzCore/CMakeFiles/AzCore.dir/profile/Unity/unity_22_cxx.cxx.o

About half way through that crashed, taking the terminal it was in down with it, try again

lucasw commented 5 months ago

ROS2 - o3de-extras

https://github.com/o3de/o3de-extras

~/other/src/sim/o3de-extras$ $O3DE/scripts/o3de.sh register --all-gems-path `pwd`/Gems
    "external_subdirectories": [
        "/home/lucasw/other/src/sim/o3de-extras/Gems/AudioEngineWwise",
        "/home/lucasw/other/src/sim/o3de-extras/Gems/AzQtComponentsForPython",
        "/home/lucasw/other/src/sim/o3de-extras/Gems/MachineLearning",
        "/home/lucasw/other/src/sim/o3de-extras/Gems/OpenXRVk",
        "/home/lucasw/other/src/sim/o3de-extras/Gems/ProteusRobot",
        "/home/lucasw/other/src/sim/o3de-extras/Gems/ROS2",
        "/home/lucasw/other/src/sim/o3de-extras/Gems/RosRobotSample",
        "/home/lucasw/other/src/sim/o3de-extras/Gems/WarehouseAssets",
        "/home/lucasw/other/src/sim/o3de-extras/Gems/WarehouseAutomation",
        "/home/lucasw/other/src/sim/o3de-extras/Gems/WarehouseSample",
        "/home/lucasw/other/src/sim/o3de-extras/Gems/XR",
lucasw commented 5 months ago

Running the built project editor

cd o3de_ros_project
./build/linux/bin/profile/Editor
Module: Attempting to load module:/.../o3de_ros_project/build/linux/bin/profile/libEditorLib.so
Module: Success!
Module: Attempting to load module:/.../o3de_ros_project/build/linux/bin/profile/libAtomViewportDisplayInfo.so
...
AssetProcessorConnection: Trace::Warning
 /.../o3de/Code/Framework/AzFramework/AzFramework/Asset/AssetSystemComponent.cpp(694): 'virtual bool AzFramework::AssetSystem::AssetSystemComponent::WaitUntilAssetProcessorConnected(AZStd::chrono::duration<float>)'
AssetProcessorConnection: Network connection attempt failure, Connect returned error AzSockError::eASE_ECONNREFUSED
AssetProcessorConnection: ==================================================================
AssetSystem: Ping time to asset processor: 0.04 milliseconds
...
AssetCatalog: Received `AssetNotificationMessage` network message with no AssetType.  Asset "autoexec.cfg" will be registered without a type.
AssetCatalog: Received `AssetNotificationMessage` network message with no AssetType.  Asset "game.cfg" will be registered without a type.
AssetCatalog: Received `AssetNotificationMessage` network message with no AssetType.  Asset "translation/scriptcanvas_en_us.qm" will be registered without a type.
....
AssetContainer: Trace::Warning

 .../o3de/Code/Framework/AzCore/AzCore/Asset/AssetContainer.cpp(134): 'void AZ::Data::AssetContainer::AddDependentAssets(Asset<AssetData>, const AssetLoadParameters &)'
AssetContainer: Asset lightingpresets/thumbnail.lightingpreset.azasset ({4F3761EF-E279-5FDD-98C3-EF90F924FBAC}:0) references/depends on asset {A5767C6B-5DB4-5999-A717-4587BEDF5CDE}:7d0 which does not exist in the catalog and cannot be loaded.
AssetContainer: ==================================================================
Module: Attempting to load module:.../o3de_ros_project/build/linux/bin/profile/libCrySystem.so
AssetDatabase: 
==================================================================
AssetDatabase: Trace::Warning
/.../o3de/Code/Framework/AzCore/AzCore/Asset/AssetManager.cpp(2274): 'AssetHandler::LoadResult AZ::Data::AssetHandler::LoadAssetDataFromStream(const Asset<AssetData> &, AZStd::shared_ptr<AssetDataStream>, const AssetFilterCB &)'
AssetDatabase: Load time threshold exceeded: LoadAssetData call for postprocess/default.postfxlayercategories took 195 ms to load 2157 bytes (  0.0000 KB/s)
AssetDatabase: ==================================================================
Module: Success!
Segmentation fault (core dumped)

:hankey:

game launcher and unified launcher do run though (to show blank screen)


run the Editor a second time- works! :heavy_check_mark:

lucasw commented 5 months ago

With the editor launched, can load DefaultLevel (which will have panoramic background, checkerboard, and shaderball), save it, then run the UnifiedLauncher and the level will load (give it a few moments if it starts with a black screen)

lucasw commented 5 months ago

For gamepad support:

sudo apt install libevdev2
lucasw commented 5 months ago

ROS2 integration

https://www.docs.o3de.org/docs/user-guide/project-config/add-remove-gems/

cd o3de_ros_project
$O3DE/scripts/o3de.sh enable-gem -gp ~/other/src/sim/o3de-extras/Gems/ROS2 -pp `pwd`

Now ROS2 is in project.json

 "gem_names": [
        "Atom",
        "AudioSystem",
        "CameraFramework",
        "DebugDraw",
        "DiffuseProbeGrid",
        "EMotionFX",
        "EditorPythonBindings",
        "GameState",
        "ImGui",
        "LandscapeCanvas",
        "LyShine",
        "MiniAudio",
        "PhysX",
        "PrefabBuilder",
        "PrimitiveAssets",
        "ROS2",
        "RemoteTools",
        "SaveData",
        "ScriptCanvasPhysics",
        "ScriptEvents",
        "StartingPointInput",
        "TextureAtlas",
        "WhiteBox",
        "o3de_ros_project"

(was adding ROS2 to that list all it did? Maybe if the gem wasn't already in o3de_manifest it would have added it there too)

Next rebuild:

source ~/ros/ros2_rolling/install/setup.bash
cmake --build build/linux --target o3de_ros_project.GameLauncher Editor --config profile -j 4

now will see ros2 build information:

-- Python: Getting/Checking packages listed in /home/lucasw/other/src/sim/o3de-extras/Gems/ROS2/requirements.txt
-- Python: Getting/Checking packages listed in /home/lucasw/other/src/sim/o3de-extras/Gems/ROS2/requirements.txt - New packages were installed
-- Ros Distro is "rolling"
-- Found rclcpp: 27.0.0 (/home/lucasw/ros/ros2_rolling/install/rclcpp/share/rclcpp/cmake)
-- Found Python3: /usr/bin/python3 (found version "3.11.6") found components: Interpreter 
-- Found rosidl_generator_c: 4.5.1 (/home/lucasw/ros/ros2_rolling/install/rosidl_generator_c/share/rosidl_generator_c/cmake)
-- Found rosidl_generator_cpp: 4.5.1 (/home/lucasw/ros/ros2_rolling/install/rosidl_generator_cpp/share/rosidl_generator_cpp/cmake)
-- Using all available rosidl_typesupport_c: rosidl_typesupport_introspection_c;rosidl_typesupport_fastrtps_c
-- Using all available rosidl_typesupport_cpp: rosidl_typesupport_introspection_cpp;rosidl_typesupport_fastrtps_cpp
-- Found rmw_implementation_cmake: 7.3.0 (/home/lucasw/ros/ros2_rolling/install/rmw_implementation_cmake/share/rmw_implementation_cmake/cmake)
-- Found rmw_fastrtps_cpp: 8.2.0 (/home/lucasw/ros/ros2_rolling/install/rmw_fastrtps_cpp/share/rmw_fastrtps_cpp/cmake)
...

But now relaunching the Editor I don't see any ros2 components under 'add component'- I've gotten that working with the deb nightly o3de, do I have to create the project from scratch with ros2 gem enabled?

Module: Attempting to load module:/media/lucasw/terraclear04/sim/o3de_ros_project/build/linux/bin/profile/libROS2.Editor.so
Module: Failed with error:
libnav_msgs__rosidl_typesupport_fastrtps_c.so: cannot open shared object file: No such file or directory

-> no forgot to source ros2_rolling setup.bash in the terminal running the editor

lucasw commented 5 months ago

o3de_ros_lidar_2024-03-30 12-36-38

lucasw commented 5 months ago

now with a camera:

o3de_ros_lidar_camera

:rocket:

lucasw commented 5 months ago

Make a github repo to store the cleaned project in

-> https://github.com/lucasw/o3de_ros_example