From bb02446ae59e644b7d7ee585e25f1f9bcd2d712c Mon Sep 17 00:00:00 2001 From: Steve Pham <82231385+spham-amzn@users.noreply.github.com> Date: Tue, 19 Nov 2024 03:48:11 -0800 Subject: [PATCH 01/10] Fix ROS2 Project Template (#790) * Fix templated DemoLevel prefab by restoring concrete component name to templated component name * Replace autoexec.cfg with load_level.setreg * Bump revision number Signed-off-by: Steve Pham <82231385+spham-amzn@users.noreply.github.com> --- .../Template/Levels/DemoLevel/DemoLevel.prefab | 2 +- .../Template/Registry/load_level.setreg | 9 +++++++++ Templates/Ros2ProjectTemplate/Template/autoexec.cfg | 1 - 3 files changed, 10 insertions(+), 2 deletions(-) create mode 100644 Templates/Ros2ProjectTemplate/Template/Registry/load_level.setreg delete mode 100644 Templates/Ros2ProjectTemplate/Template/autoexec.cfg diff --git a/Templates/Ros2ProjectTemplate/Template/Levels/DemoLevel/DemoLevel.prefab b/Templates/Ros2ProjectTemplate/Template/Levels/DemoLevel/DemoLevel.prefab index c00b55b7a..0bb41d427 100644 --- a/Templates/Ros2ProjectTemplate/Template/Levels/DemoLevel/DemoLevel.prefab +++ b/Templates/Ros2ProjectTemplate/Template/Levels/DemoLevel/DemoLevel.prefab @@ -268,7 +268,7 @@ "$type": "GenericComponentWrapper", "Id": 2318932367744128274, "m_template": { - "$type": "R2PTSampleComponent", + "$type": "${SanitizedCppName}SampleComponent", "goals": [ "Entity_[549827034797]", "Entity_[545532067501]" diff --git a/Templates/Ros2ProjectTemplate/Template/Registry/load_level.setreg b/Templates/Ros2ProjectTemplate/Template/Registry/load_level.setreg new file mode 100644 index 000000000..f43e361c4 --- /dev/null +++ b/Templates/Ros2ProjectTemplate/Template/Registry/load_level.setreg @@ -0,0 +1,9 @@ +{ + "O3DE": { + "Autoexec": { + "ConsoleCommands": { + "LoadLevel": "demolevel" + } + } + } +} diff --git a/Templates/Ros2ProjectTemplate/Template/autoexec.cfg b/Templates/Ros2ProjectTemplate/Template/autoexec.cfg deleted file mode 100644 index e730d9c94..000000000 --- a/Templates/Ros2ProjectTemplate/Template/autoexec.cfg +++ /dev/null @@ -1 +0,0 @@ -LoadLevel levels/demolevel/demolevel.spawnable From 7633820cfc799ae23ba6e43ea016b541a9f39c67 Mon Sep 17 00:00:00 2001 From: Patryk Antosz Date: Wed, 20 Nov 2024 09:03:36 +0100 Subject: [PATCH 02/10] Improved ROS2 FrameConversion script 2310->2409 (#789) Added if statement for 'remove' override operations Signed-off-by: Patryk Antosz --- Gems/ROS2/Code/Source/Frame/Conversions/FrameConversion.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Gems/ROS2/Code/Source/Frame/Conversions/FrameConversion.py b/Gems/ROS2/Code/Source/Frame/Conversions/FrameConversion.py index dd7c2e3e2..a9b6740d5 100644 --- a/Gems/ROS2/Code/Source/Frame/Conversions/FrameConversion.py +++ b/Gems/ROS2/Code/Source/Frame/Conversions/FrameConversion.py @@ -47,6 +47,8 @@ def search_for_components(item, foundComponents, insidePatches=False): "m_template/Joint Name" ]): item["path"] = item["path"].replace("m_template", "ROS2FrameConfiguration") + if item["op"] == "remove" and "ROS2FrameComponent" in item["path"]: + item["path"] = item["path"].replace("ROS2FrameComponent", "ROS2FrameEditorComponent") for key, value in item.items(): search_for_components(value, foundComponents, insidePatches) From 7a1783a2de859e423d287f629d4c257b0a7655e2 Mon Sep 17 00:00:00 2001 From: Steve Pham <82231385+spham-amzn@users.noreply.github.com> Date: Thu, 14 Nov 2024 15:49:49 -0800 Subject: [PATCH 03/10] Add ROS2 dependency to the ROS2 project template' s project gem Signed-off-by: Steve Pham <82231385+spham-amzn@users.noreply.github.com> --- Templates/Ros2FleetRobotTemplate/Template/Gem/gem.json | 1 + Templates/Ros2ProjectTemplate/Template/Gem/gem.json | 1 + Templates/Ros2RoboticManipulationTemplate/Template/Gem/gem.json | 1 + 3 files changed, 3 insertions(+) diff --git a/Templates/Ros2FleetRobotTemplate/Template/Gem/gem.json b/Templates/Ros2FleetRobotTemplate/Template/Gem/gem.json index 2dc1f96b6..a8762c271 100644 --- a/Templates/Ros2FleetRobotTemplate/Template/Gem/gem.json +++ b/Templates/Ros2FleetRobotTemplate/Template/Gem/gem.json @@ -21,6 +21,7 @@ "requirements": "", "documentation_url": "", "dependencies": [ + "ROS2>=3.1.0" ], "compatible_engines": [ "o3de-sdk>=1.2.0", diff --git a/Templates/Ros2ProjectTemplate/Template/Gem/gem.json b/Templates/Ros2ProjectTemplate/Template/Gem/gem.json index c00215902..2cef09954 100644 --- a/Templates/Ros2ProjectTemplate/Template/Gem/gem.json +++ b/Templates/Ros2ProjectTemplate/Template/Gem/gem.json @@ -24,5 +24,6 @@ ], "documentation_url": "", "dependencies": [ + "ROS2>=3.1.0" ] } diff --git a/Templates/Ros2RoboticManipulationTemplate/Template/Gem/gem.json b/Templates/Ros2RoboticManipulationTemplate/Template/Gem/gem.json index d55f5a462..4d972f70a 100644 --- a/Templates/Ros2RoboticManipulationTemplate/Template/Gem/gem.json +++ b/Templates/Ros2RoboticManipulationTemplate/Template/Gem/gem.json @@ -25,5 +25,6 @@ "compatible_engines": [ ], "engine_api_dependencies":[ + "ROS2>=3.1.0" ] } From d7cb971e9ccfbb670beb674e4b468b7b2a059970 Mon Sep 17 00:00:00 2001 From: Steve Pham <82231385+spham-amzn@users.noreply.github.com> Date: Tue, 19 Nov 2024 07:25:28 -0800 Subject: [PATCH 04/10] Fix mislocated dependency setting Signed-off-by: Steve Pham <82231385+spham-amzn@users.noreply.github.com> --- Templates/Ros2RoboticManipulationTemplate/Template/Gem/gem.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Templates/Ros2RoboticManipulationTemplate/Template/Gem/gem.json b/Templates/Ros2RoboticManipulationTemplate/Template/Gem/gem.json index 4d972f70a..522c2836f 100644 --- a/Templates/Ros2RoboticManipulationTemplate/Template/Gem/gem.json +++ b/Templates/Ros2RoboticManipulationTemplate/Template/Gem/gem.json @@ -21,10 +21,10 @@ "requirements": "", "documentation_url": "", "dependencies": [ + "ROS2>=3.1.0" ], "compatible_engines": [ ], "engine_api_dependencies":[ - "ROS2>=3.1.0" ] } From 36102aeeaf10b335af46b6796f504d2631961c6b Mon Sep 17 00:00:00 2001 From: Jan Hanca Date: Tue, 26 Nov 2024 16:52:27 +0100 Subject: [PATCH 05/10] Remove unused_variable warnings when release mode (#798) Signed-off-by: Jan Hanca --- .../Code/Source/RobotImporter/RobotImporterWidget.cpp | 8 +++----- .../SDFormat/Hooks/ROS2SkidSteeringModelHook.cpp | 5 ++--- 2 files changed, 5 insertions(+), 8 deletions(-) diff --git a/Gems/ROS2/Code/Source/RobotImporter/RobotImporterWidget.cpp b/Gems/ROS2/Code/Source/RobotImporter/RobotImporterWidget.cpp index c3ba307ba..987eadf43 100644 --- a/Gems/ROS2/Code/Source/RobotImporter/RobotImporterWidget.cpp +++ b/Gems/ROS2/Code/Source/RobotImporter/RobotImporterWidget.cpp @@ -656,7 +656,6 @@ namespace ROS2 { const auto filePath = m_robotDescriptionPage->GetModifiedUrdfName(); const auto& streamData = m_modifiedUrdfWindow->GetUrdfData(); - bool success = false; AZ::IO::FileIOBase* fileIo = AZ::IO::FileIOBase::GetInstance(); AZ::IO::FixedMaxPathString resolvedPath; if (fileIo == nullptr || !fileIo->ResolvePath(filePath.c_str(), resolvedPath.data(), resolvedPath.capacity() + 1)) @@ -667,11 +666,10 @@ namespace ROS2 resolvedPath.c_str(), AZ::IO::SystemFile::SF_OPEN_CREATE | AZ::IO::SystemFile::SF_OPEN_CREATE_PATH | AZ::IO::SystemFile::SF_OPEN_WRITE_ONLY)) { - AZ::IO::SizeType bytesWritten = fileHandle.Write(streamData.data(), streamData.size()); - success = (bytesWritten == streamData.size()); + [[maybe_unused]] const AZ::IO::SizeType bytesWritten = fileHandle.Write(streamData.data(), streamData.size()); + AZ_Warning( + "onSaveModifiedUrdfPressed", (bytesWritten == streamData.size()), "Cannot save the output file %s", filePath.c_str()); } - - AZ_Warning("onSaveModifiedUrdfPressed", success, "Cannot save the output file %s", filePath.c_str()); } void RobotImporterWidget::onShowModifiedUrdfPressed() diff --git a/Gems/ROS2/Code/Source/RobotImporter/SDFormat/Hooks/ROS2SkidSteeringModelHook.cpp b/Gems/ROS2/Code/Source/RobotImporter/SDFormat/Hooks/ROS2SkidSteeringModelHook.cpp index 3a5fe53b4..236c903f3 100644 --- a/Gems/ROS2/Code/Source/RobotImporter/SDFormat/Hooks/ROS2SkidSteeringModelHook.cpp +++ b/Gems/ROS2/Code/Source/RobotImporter/SDFormat/Hooks/ROS2SkidSteeringModelHook.cpp @@ -103,7 +103,6 @@ namespace ROS2::SDFormat if (element->HasElement("wheel_separation") && element->HasElement("wheel_diameter")) { // ROS 2 version of either libgazebo_ros_skid_steer_drive.so or libgazebo_ros_diff_drive.so - const auto wheelPairs = element->Get("num_wheel_pairs", 1).first; int dataCount = 0; auto wheelSeparation = element->GetElement("wheel_separation"); @@ -120,10 +119,9 @@ namespace ROS2::SDFormat } else { - constexpr float epsilon = 0.001f; AZ_Warning( "CreateVehicleConfiguration", - AZ::IsClose(configuration.m_wheelbase, wheelSeparation->Get(), epsilon), + AZ::IsClose(configuration.m_wheelbase, wheelSeparation->Get()), "Different wheel separation distances in one model are not supported."); } @@ -138,6 +136,7 @@ namespace ROS2::SDFormat wheelSeparation = wheelSeparation->GetNextElement("wheel_separation"); wheelDiameter = wheelDiameter->GetNextElement("wheel_diameter"); } + [[maybe_unused]] const auto wheelPairs = element->Get("num_wheel_pairs", 1).first; AZ_Warning( "CreateVehicleConfiguration", wheelPairs == configuration.m_axles.size(), From 682f5fab1f0a827709db6d609eff367d56442992 Mon Sep 17 00:00:00 2001 From: Mateusz Wasilewski Date: Fri, 20 Dec 2024 14:36:48 +0100 Subject: [PATCH 06/10] Move Joint Tracjectory State to TrajectoryComponent (#808) Signed-off-by: Mateusz Wasilewski --- .../FollowJointTrajectoryActionServer.cpp | 13 ------------- .../FollowJointTrajectoryActionServer.h | 8 -------- .../Manipulation/JointsTrajectoryComponent.cpp | 13 ++++++------- .../Source/Manipulation/JointsTrajectoryComponent.h | 2 +- 4 files changed, 7 insertions(+), 29 deletions(-) diff --git a/Gems/ROS2/Code/Source/Manipulation/FollowJointTrajectoryActionServer.cpp b/Gems/ROS2/Code/Source/Manipulation/FollowJointTrajectoryActionServer.cpp index 2036385e5..28eb67380 100644 --- a/Gems/ROS2/Code/Source/Manipulation/FollowJointTrajectoryActionServer.cpp +++ b/Gems/ROS2/Code/Source/Manipulation/FollowJointTrajectoryActionServer.cpp @@ -23,16 +23,6 @@ namespace ROS2 AZStd::bind(&FollowJointTrajectoryActionServer::GoalAcceptedCallback, this, AZStd::placeholders::_1)); } - JointsTrajectoryRequests::TrajectoryActionStatus FollowJointTrajectoryActionServer::GetGoalStatus() const - { - return m_goalStatus; - } - - void FollowJointTrajectoryActionServer::SetGoalSuccess() - { - m_goalStatus = JointsTrajectoryRequests::TrajectoryActionStatus::Succeeded; - } - void FollowJointTrajectoryActionServer::CancelGoal(std::shared_ptr result) { AZ_Assert(m_goalHandle, "Invalid goal handle!"); @@ -50,7 +40,6 @@ namespace ROS2 { AZ_Trace("FollowJointTrajectoryActionServer", "Goal succeeded\n"); m_goalHandle->succeed(result); - m_goalStatus = JointsTrajectoryRequests::TrajectoryActionStatus::Succeeded; } } @@ -102,7 +91,6 @@ namespace ROS2 return rclcpp_action::CancelResponse::REJECT; } - m_goalStatus = JointsTrajectoryRequests::TrajectoryActionStatus::Cancelled; return rclcpp_action::CancelResponse::ACCEPT; } @@ -149,6 +137,5 @@ namespace ROS2 m_goalHandle = goalHandle; // m_goalHandle->execute(); // No need to call this, as we are already executing the goal due to ACCEPT_AND_EXECUTE - m_goalStatus = JointsTrajectoryRequests::TrajectoryActionStatus::Executing; } } // namespace ROS2 diff --git a/Gems/ROS2/Code/Source/Manipulation/FollowJointTrajectoryActionServer.h b/Gems/ROS2/Code/Source/Manipulation/FollowJointTrajectoryActionServer.h index 2d3eb11f5..a3928984a 100644 --- a/Gems/ROS2/Code/Source/Manipulation/FollowJointTrajectoryActionServer.h +++ b/Gems/ROS2/Code/Source/Manipulation/FollowJointTrajectoryActionServer.h @@ -32,17 +32,10 @@ namespace ROS2 //! server documentation FollowJointTrajectoryActionServer(const AZStd::string& actionName, const AZ::EntityId& entityId); - //! Return trajectory action status. - //! @return Status of the trajectory execution. - JointsTrajectoryRequests::TrajectoryActionStatus GetGoalStatus() const; - //! Cancel the current goal. //! @param result Result to be passed to through action server to the client. void CancelGoal(std::shared_ptr result); - //! Sets the goal status to success - void SetGoalSuccess(); - //! Report goal success to the action server. //! @param result Result which contains success code. void GoalSuccess(std::shared_ptr result); @@ -56,7 +49,6 @@ namespace ROS2 using TrajectoryActionStatus = JointsTrajectoryRequests::TrajectoryActionStatus; AZ::EntityId m_entityId; - TrajectoryActionStatus m_goalStatus = TrajectoryActionStatus::Idle; rclcpp_action::Server::SharedPtr m_actionServer; std::shared_ptr m_goalHandle; diff --git a/Gems/ROS2/Code/Source/Manipulation/JointsTrajectoryComponent.cpp b/Gems/ROS2/Code/Source/Manipulation/JointsTrajectoryComponent.cpp index a4d8b46cd..ed21dd17c 100644 --- a/Gems/ROS2/Code/Source/Manipulation/JointsTrajectoryComponent.cpp +++ b/Gems/ROS2/Code/Source/Manipulation/JointsTrajectoryComponent.cpp @@ -12,8 +12,8 @@ #include #include #include -#include #include +#include namespace ROS2 { @@ -92,7 +92,7 @@ namespace ROS2 AZ::Outcome JointsTrajectoryComponent::StartTrajectoryGoal( TrajectoryGoalPtr trajectoryGoal) { - if (m_trajectoryInProgress) + if (m_goalStatus == JointsTrajectoryRequests::TrajectoryActionStatus::Executing) { auto result = JointsTrajectoryComponent::TrajectoryResult(); result.error_code = JointsTrajectoryComponent::TrajectoryResult::INVALID_GOAL; @@ -107,7 +107,7 @@ namespace ROS2 } m_trajectoryGoal = *trajectoryGoal; m_trajectoryExecutionStartTime = rclcpp::Time(ROS2::ROS2Interface::Get()->GetROSTimestamp()); - m_trajectoryInProgress = true; + m_goalStatus = JointsTrajectoryRequests::TrajectoryActionStatus::Executing; return AZ::Success(); } @@ -186,13 +186,13 @@ namespace ROS2 AZ::Outcome JointsTrajectoryComponent::CancelTrajectoryGoal() { m_trajectoryGoal.trajectory.points.clear(); - m_trajectoryInProgress = false; + m_goalStatus = JointsTrajectoryRequests::TrajectoryActionStatus::Cancelled; return AZ::Success(); } JointsTrajectoryRequests::TrajectoryActionStatus JointsTrajectoryComponent::GetGoalStatus() { - return m_followTrajectoryServer->GetGoalStatus(); + return m_goalStatus; } void JointsTrajectoryComponent::FollowTrajectory(const uint64_t deltaTimeNs) @@ -205,7 +205,6 @@ namespace ROS2 result->error_string = "User Cancelled"; result->error_code = FollowJointTrajectoryActionServer::FollowJointTrajectory::Result::SUCCESSFUL; m_followTrajectoryServer->CancelGoal(result); - m_followTrajectoryServer->SetGoalSuccess(); return; } @@ -219,7 +218,7 @@ namespace ROS2 AZ_TracePrintf("JointsManipulationComponent", "Goal Concluded: all points reached\n"); auto successResult = std::make_shared(); //!< Empty defaults to success. m_followTrajectoryServer->GoalSuccess(successResult); - m_trajectoryInProgress = false; + m_goalStatus = JointsTrajectoryRequests::TrajectoryActionStatus::Succeeded; return; } diff --git a/Gems/ROS2/Code/Source/Manipulation/JointsTrajectoryComponent.h b/Gems/ROS2/Code/Source/Manipulation/JointsTrajectoryComponent.h index 5c6ac6c91..5f214b3aa 100644 --- a/Gems/ROS2/Code/Source/Manipulation/JointsTrajectoryComponent.h +++ b/Gems/ROS2/Code/Source/Manipulation/JointsTrajectoryComponent.h @@ -64,9 +64,9 @@ namespace ROS2 AZStd::string m_followTrajectoryActionName{ "arm_controller/follow_joint_trajectory" }; AZStd::unique_ptr m_followTrajectoryServer; TrajectoryGoal m_trajectoryGoal; + TrajectoryActionStatus m_goalStatus = TrajectoryActionStatus::Idle; rclcpp::Time m_trajectoryExecutionStartTime; ManipulationJoints m_manipulationJoints; - bool m_trajectoryInProgress{ false }; builtin_interfaces::msg::Time m_lastTickTimestamp; //!< ROS 2 Timestamp during last OnTick call }; } // namespace ROS2 From 0c039ebcb645e3e9b424f3558c21a5a8ae6bf7a0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Pe=C5=82ka?= Date: Fri, 20 Dec 2024 14:37:22 +0100 Subject: [PATCH 07/10] Removed reference to non-existing file in template (#802) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Michał Pełka --- .../Ros2ProjectTemplate/Docker/Dockerfile | 114 ----------------- .../Docker/LaunchNavStack.bash | 15 --- .../Docker/LaunchSimulation.bash | 22 ---- .../Ros2ProjectTemplate/Docker/README.md | 119 ------------------ .../Ros2ProjectTemplate/Docker/cleanup.bash | 43 ------- Templates/Ros2ProjectTemplate/template.json | 4 - 6 files changed, 317 deletions(-) delete mode 100644 Templates/Ros2ProjectTemplate/Docker/Dockerfile delete mode 100755 Templates/Ros2ProjectTemplate/Docker/LaunchNavStack.bash delete mode 100755 Templates/Ros2ProjectTemplate/Docker/LaunchSimulation.bash delete mode 100644 Templates/Ros2ProjectTemplate/Docker/README.md delete mode 100755 Templates/Ros2ProjectTemplate/Docker/cleanup.bash diff --git a/Templates/Ros2ProjectTemplate/Docker/Dockerfile b/Templates/Ros2ProjectTemplate/Docker/Dockerfile deleted file mode 100644 index 78e84d48f..000000000 --- a/Templates/Ros2ProjectTemplate/Docker/Dockerfile +++ /dev/null @@ -1,114 +0,0 @@ -# Copyright (c) Contributors to the Open 3D Engine Project. -# For complete copyright and license terms please see the LICENSE at the root of this distribution. -# -# SPDX-License-Identifier: Apache-2.0 OR MIT -# - -ARG ROS_VERSION=jazzy - -FROM ros:${ROS_VERSION}-ros-base - -# Argument to determining the image type ('simulation' or 'navstack') -ARG IMAGE_TYPE=simulation # Default to 'simulation' - -# Arguments for the source repos needed for the Ros2Template sample docker -ARG O3DE_REPO=https://github.com/o3de/o3de.git -ARG O3DE_BRANCH=main - -ARG O3DE_EXTRAS_REPO=https://github.com/o3de/o3de-extras.git -ARG O3DE_EXTRAS_BRANCH=main - -# Additional argument to control build concurrency -ARG CMAKE_JOBS=8 - -ENV WORKSPACE=/data/workspace - -ENV PROJECT_PATH=/data/workspace/Ros2Project - -WORKDIR $WORKSPACE - -RUN apt-get update && apt-get upgrade -y - -# Install packages needed for cloning and building from the source repos -RUN apt-get install -y --no-install-recommends \ - git \ - git-lfs \ - clang \ - ninja-build \ - cmake \ - libglu1-mesa-dev \ - libxcb-xinerama0 \ - libxcb-xinput0 \ - libxcb-xinput-dev \ - libxcb-xfixes0-dev \ - libxcb-xkb-dev \ - libxkbcommon-dev \ - libxkbcommon-x11-dev \ - libfontconfig1-dev \ - libcurl4-openssl-dev \ - libsdl2-dev \ - zlib1g-dev \ - mesa-common-dev \ - libssl-dev libxcb-icccm4 \ - libxcb-image0 \ - libxcb-keysyms1 \ - libxcb-render-util0 \ - libxcb-randr0 \ - libnvidia-gl-470 \ - ufw \ - ros-${ROS_DISTRO}-slam-toolbox \ - ros-${ROS_DISTRO}-navigation2 \ - ros-${ROS_DISTRO}-nav2-bringup \ - ros-${ROS_DISTRO}-pointcloud-to-laserscan \ - ros-${ROS_DISTRO}-gazebo-msgs \ - ros-${ROS_DISTRO}-ackermann-msgs \ - ros-${ROS_DISTRO}-rmw-cyclonedds-cpp \ - ros-${ROS_DISTRO}-control-toolbox \ - ros-${ROS_DISTRO}-nav-msgs \ - ros-${ROS_DISTRO}-desktop - - -# Copy script used to remove build artifacts -COPY cleanup.bash /data/workspace/cleanup.bash - -# Clone and register O3DE repos -RUN if [ "${IMAGE_TYPE}" = "simulation" ]; then \ - cd $WORKSPACE && \ - git clone --recursive $O3DE_REPO && \ - git -C $WORKSPACE/o3de checkout $O3DE_BRANCH &&\ - git -C $WORKSPACE/o3de lfs install && \ - git -C $WORKSPACE/o3de lfs pull && \ - $WORKSPACE/o3de/python/get_python.sh && \ - $WORKSPACE/o3de/scripts/o3de.sh register -ep $WORKSPACE/o3de && \ - git clone $O3DE_EXTRAS_REPO && \ - git -C $WORKSPACE/o3de-extras checkout $O3DE_EXTRAS_BRANCH && \ - $WORKSPACE/o3de/scripts/o3de.sh register -gp $WORKSPACE/o3de-extras/Gems/ROS2 && \ - $WORKSPACE/o3de/scripts/o3de.sh register -gp $WORKSPACE/o3de-extras/Gems/RosRobotSample && \ - $WORKSPACE/o3de/scripts/o3de.sh register -gp $WORKSPACE/o3de-extras/Gems/WarehouseAssets && \ - $WORKSPACE/o3de/scripts/o3de.sh register -gp $WORKSPACE/o3de-extras/Gems/WarehouseSample; \ - elif [ "${IMAGE_TYPE}" = "navstack" ]; then \ - cd $WORKSPACE && \ - git clone $O3DE_EXTRAS_REPO && \ - git -C $WORKSPACE/o3de-extras checkout $O3DE_EXTRAS_BRANCH; \ - else \ - echo "Unsupported IMAGE_TYPE: ${IMAGE_TYPE}" && exit 1; \ - fi - -# Build and cleanup in the same layer to reduce the size -RUN if [ "${IMAGE_TYPE}" = "simulation" ]; then \ - . /opt/ros/${ROS_DISTRO}/setup.sh && \ - $WORKSPACE/o3de/scripts/o3de.sh create-project --project-path $PROJECT_PATH --template-path $WORKSPACE/o3de-extras/Templates/Ros2ProjectTemplate && \ - cmake -B $PROJECT_PATH/build/linux -S $PROJECT_PATH -G "Ninja Multi-Config" -DLY_STRIP_DEBUG_SYMBOLS=TRUE -DLY_DISABLE_TEST_MODULES=ON && \ - cmake --build $PROJECT_PATH/build/linux --config profile --target Ros2Project Editor Ros2Project.Assets Ros2Project.GameLauncher -j $CMAKE_JOBS && \ - $WORKSPACE/cleanup.bash ; \ - fi - -COPY LaunchSimulation.bash /data/workspace/LaunchSimulation.bash -COPY LaunchNavStack.bash /data/workspace/LaunchNavStack.bash - -ENV RMW_IMPLEMENTATION=rmw_cyclonedds_cpp -ENV LAUNCH_FULLSCREEN_OPT=0 -ENV NVIDIA_VISIBLE_DEVICES all -ENV NVIDIA_DRIVER_CAPABILITIES all - -ENTRYPOINT ["/bin/bash"] diff --git a/Templates/Ros2ProjectTemplate/Docker/LaunchNavStack.bash b/Templates/Ros2ProjectTemplate/Docker/LaunchNavStack.bash deleted file mode 100755 index ece16e22e..000000000 --- a/Templates/Ros2ProjectTemplate/Docker/LaunchNavStack.bash +++ /dev/null @@ -1,15 +0,0 @@ -#!/bin/bash - -# Copyright (c) Contributors to the Open 3D Engine Project. -# For complete copyright and license terms please see the LICENSE at the root of this distribution. -# -# SPDX-License-Identifier: Apache-2.0 OR MIT -# - -unset LD_LIBRARY_PATH - -source /opt/ros/$ROS_DISTRO/setup.bash - -cd /data/workspace/o3de-extras/Templates/Ros2ProjectTemplate/Template/Examples/slam_navigation/launch - -ros2 launch navigation.launch.py diff --git a/Templates/Ros2ProjectTemplate/Docker/LaunchSimulation.bash b/Templates/Ros2ProjectTemplate/Docker/LaunchSimulation.bash deleted file mode 100755 index 47a41eaa5..000000000 --- a/Templates/Ros2ProjectTemplate/Docker/LaunchSimulation.bash +++ /dev/null @@ -1,22 +0,0 @@ -#!/bin/bash - -# Copyright (c) Contributors to the Open 3D Engine Project. -# For complete copyright and license terms please see the LICENSE at the root of this distribution. -# -# SPDX-License-Identifier: Apache-2.0 OR MIT -# - -unset LD_LIBRARY_PATH - -source /opt/ros/$ROS_DISTRO/setup.bash - -export LD_LIBRARY_PATH=/data/workspace/Ros2Project/build/linux/bin/profile:$LD_LIBRARY_PATH - -if [ -d /data/workspace/Ros2Project/build/linux/bin/profile ] -then - cd /data/workspace/Ros2Project/build/linux/bin/profile - ./Ros2Project.GameLauncher -r_fullscreen=$LAUNCH_FULLSCREEN_OPT -bg_ConnectToAssetProcessor=0 > /data/workspace/simulation_launch.log 2>&1 -else - echo "Simulation not installed on this image" -fi - diff --git a/Templates/Ros2ProjectTemplate/Docker/README.md b/Templates/Ros2ProjectTemplate/Docker/README.md deleted file mode 100644 index 21f936eb3..000000000 --- a/Templates/Ros2ProjectTemplate/Docker/README.md +++ /dev/null @@ -1,119 +0,0 @@ -# Docker scripts for running the O3DE Ros2Project based on O3DE Ros2ProjectTemplate - -The following Dockerfiles defined in this path will prepare the appropriate ROS2 package (Ubuntu 20.04/Focal + Galactic or Ubuntu 22.04/Jammy + Iron) based environment and build the components necessary to run the O3DE demo project simulator through the O3DE engine using the Ros2Project template. - -## Prerequisites - -* [Hardware requirements of o3de](https://www.o3de.org/docs/welcome-guide/requirements/) -* Ubuntu 20.04 (Focal) or 22.04 (Jammy) -* At least 60 GB of free disk space -* Docker 24.0 installed and configured - * **Note** It is recommended to have Docker installed correctly and in a secure manner so that the docker commands in this guide do not require elevated privileges (sudo) to run them. See [Docker Engine post-installation steps](https://docs.docker.com/engine/install/linux-postinstall/) for more details. -* [NVidia container toolkit](https://docs.nvidia.com/datacenter/cloud-native/container-toolkit/install-guide.html#docker) - -## Building the Docker Image - -By default, the docker script provided in this template will build a docker image to run the Ros2Project sample using Ubuntu 22.04 (jammy) with the ROS2 Iron distribution. All obsolete source code, git artifacts, and build artifacts will be removed by the 'cleanup.bash' script when completed. - -Run the following command to build the docker image with a default configuration: - -``` -docker build -t o3de_ros2project:latest -f Dockerfile . -``` - -**Note** -The above command example tags specific commits for O3DE, and the ROS2 gem repos based on known working commits. See the Advanced Options section below for more information. - -This will create a docker image named 'o3de_ros2project' with the tag 'latest' that contains both the simulation launcher and the navigation stack. - -It will also contain helper scripts that will launch either the simulation (LaunchSimulation.bash) or the RViz2 (LaunchNavStack.bash). - -You can also create a separate docker image that only contains the navigation stack and RViz2 by supplying the argument `IMAGE_TYPE` and setting it to 'navstack': - -``` -docker build --build-arg IMAGE_TYPE=navstack -t o3de_ros2project_nav:latest . -``` - -ROS2 allows for communication across multiple docker images running on the same host, provided that they specify the 'bridge' network type when launching. - -## Running the Docker Image - -Launching O3DE applications in a Docker container requires GPU acceleration support. (Make sure that the [nvidia-docker 2](https://docs.nvidia.com/datacenter/cloud-native/container-toolkit/install-guide.html#docker) is installed.) - -### Direct Access to the X Server -The simulation docker image should be launched before bringing up the robot application. To run the robot application, first, allow the container root user to access the running X server for display - -``` -xhost +local:root -``` - -Then launch the built simulation docker image with the following command - -``` -docker run --rm --network="bridge" --gpus all -e DISPLAY=:1 -v /tmp/.X11-unix:/tmp/.X11-unix -it o3de_ros2project:latest /data/workspace/LaunchSimulation.bash -``` - -Once the simulation is up and running, launch the navigation stack inside the simulation docker image, which will bring up RViz to control the robot. - -``` -docker run --rm --network="bridge" --gpus all -e DISPLAY=:1 -v /tmp/.X11-unix:/tmp/.X11-unix -it o3de_ros2project:latest /data/workspace/LaunchNavStack.bash - -``` - -If you created a separate docker image 'o3de_ros2project_nav:latest', which only contains the navigation stack and RViz2, you can launch it using that image, provided that the simulation docker image 'o3de_ros2project' is running. - -``` -docker run --rm --network="bridge" --gpus all -e DISPLAY=:1 -v /tmp/.X11-unix:/tmp/.X11-unix -it o3de_ros2project_nav:latest /data/workspace/LaunchNavStack.bash -``` -Make sure to revoke access to the X server when the simulation ends. - -``` -xhost -local:root -``` - -### Running using Rocker - -Alternatively, you can use [Rocker](https://github.com/osrf/rocker) to run a GPU-accelerated docker image. - -Launch the built simulation docker image with the following rocker command - -``` -rocker --x11 --nvidia o3de_ros2project:latest /data/workspace/LaunchSimulation.bash -``` - -Once the simulation is up and running, launch the robot application docker image, which will bring up RViz to control the robot. - -``` -rocker --x11 --nvidia o3de_ros2project:latest /data/workspace/LaunchNavStack.bash -``` - -## Advanced Options - -### Target ROS2 Distribution -The Docker script defaults to building an image based on Ubuntu 22.04 (jammy) and the ROS2 Iron distribution. This can be overridden with a combination if the `ROS_VERSION` and `UBUNTU_VERSION` arguments. - -| ROS2 Distro | Repository | -|---------------|-------------------------------------------| -| galactic | ROS_VERSION=galactic UBUNTU_VERSION=focal | -| humble | ROS_VERSION=humble UBUNTU_VERSION=jammy | -| iron | ROS_VERSION=iron UBUNTU_VERSION=jammy | - -### Custom source repos and branches - -The Dockerscripts use the following arguments to determine the repository to pull the source: - -| Argument | Repository | Default | -|-----------------------|----------------------------|----------------------------------------------| -| O3DE_REPO | O3DE | https://github.com/o3de/o3de.git | -| O3DE_EXTRAS_REPO | O3DE Extras | https://github.com/o3de/o3de-extras.git | - -In addition to repositories, the following arguments target the branch, commit, or tag to pull from their corresponding repository: - -| Argument | Repository | Default | -|-------------------------|----------------------------------|-------------| -| O3DE_BRANCH | O3DE | 2305.0 | -| O3DE_EXTRAS_BRANCH | O3DE Extras | 2305.0 | - -### Optimizing the build process ### -The docker script provides a cmake-specific argument override to control the number of parallel jobs that can be used during the build of the docker image. `CMAKE_JOBS` sets the maximum number of concurrent jobs cmake will run during its build process and defaults to 8 jobs. This number can be adjusted to better suit the hardware which is running the docker image build. - diff --git a/Templates/Ros2ProjectTemplate/Docker/cleanup.bash b/Templates/Ros2ProjectTemplate/Docker/cleanup.bash deleted file mode 100755 index cb4e5e30f..000000000 --- a/Templates/Ros2ProjectTemplate/Docker/cleanup.bash +++ /dev/null @@ -1,43 +0,0 @@ -#!/bin/bash - -# Copyright (c) Contributors to the Open 3D Engine Project. -# For complete copyright and license terms please see the LICENSE at the root of this distribution. -# -# SPDX-License-Identifier: Apache-2.0 OR MIT -# - -# Delete obsolete files after the build of the code and assets are complete - -DELETE_LIST=(~/.o3de/3rdParty/ \ - o3de/.git \ - o3de/AutomatedTesting \ - o3de/python/downloaded_packages \ - o3de/Code \ - o3de/Gems \ - Ros2Project/build/linux/Azcg/ \ - Ros2Project/build/linux/CMake \ - Ros2Project/build/linux/CMakeFiles/ \ - Ros2Project/build/linux/External/ \ - Ros2Project/build/linux/Testing/ \ - Ros2Project/build/linux/_deps/ \ - Ros2Project/build/linux/cmake \ - Ros2Project/build/linux/lib/ \ - Ros2Project/build/linux/o3de/ \ - Ros2Project/build/linux/packages/ \ - Ros2Project/build/linux/runtime_dependencies/ - Ros2Project/build/linux/bin/profile/EditorPlugins \ - Ros2Project/build/linux/bin/profile/Editor \ - Ros2Project/build/linux/bin/profile/AssetProcessor \ - Ros2Project/build/linux/bin/profile/AssetProcessorBatch \ - Ros2Project/build/linux/bin/profile/MaterialEditor \ - Ros2Project/build/linux/bin/profile/AssetBuilder \ - Ros2Project/build/linux/bin/profile/MaterialCanvas ) - -for i in ${DELETE_LIST[@]} -do - echo "Deleting /data/workspace/$i" - rm -rf $i -done - -exit 0 - diff --git a/Templates/Ros2ProjectTemplate/template.json b/Templates/Ros2ProjectTemplate/template.json index 2f41fa37b..8b836d5c7 100644 --- a/Templates/Ros2ProjectTemplate/template.json +++ b/Templates/Ros2ProjectTemplate/template.json @@ -402,10 +402,6 @@ "file": "ShaderLib/viewsrg.srgi", "isTemplated": true }, - { - "file": "autoexec.cfg", - "isTemplated": false - }, { "file": "game.cfg", "isTemplated": false From 400227ebbd2d30a27330ecfc781a9efb8a1d7674 Mon Sep 17 00:00:00 2001 From: Artur Kamieniecki Date: Thu, 23 Jan 2025 15:58:08 +0100 Subject: [PATCH 08/10] Fix bug where joints werent clearing in JointPositionEditorComponent (#814) Signed-off-by: Artur Kamieniecki --- .../ROS2/Code/Include/ROS2/ROS2GemUtilities.h | 13 +++++++- .../Code/Source/Frame/ROS2FrameComponent.cpp | 24 ++++---------- .../Code/Source/Manipulation/JointUtils.cpp | 31 +++++++++++++++++++ .../Code/Source/Manipulation/JointUtils.h | 19 ++++++++++++ .../JointsManipulationEditorComponent.cpp | 5 ++- .../JointsPositionsEditorComponent.cpp | 6 +++- Gems/ROS2/Code/ros2_editor_files.cmake | 2 ++ 7 files changed, 79 insertions(+), 21 deletions(-) create mode 100644 Gems/ROS2/Code/Source/Manipulation/JointUtils.cpp create mode 100644 Gems/ROS2/Code/Source/Manipulation/JointUtils.h diff --git a/Gems/ROS2/Code/Include/ROS2/ROS2GemUtilities.h b/Gems/ROS2/Code/Include/ROS2/ROS2GemUtilities.h index 7652da825..d592f1d09 100644 --- a/Gems/ROS2/Code/Include/ROS2/ROS2GemUtilities.h +++ b/Gems/ROS2/Code/Include/ROS2/ROS2GemUtilities.h @@ -9,13 +9,25 @@ #include #include +#include #ifdef ROS2_EDITOR #include #endif + namespace ROS2 { namespace Utils { + //! Checks whether the entity has a component of the given type + //! @param entity pointer to entity + //! @param typeId type of the component + //! @returns true if entity has component with given type + inline bool HasComponentOfType(const AZ::Entity* entity, const AZ::Uuid typeId) + { + auto components = AZ::EntityUtils::FindDerivedComponents(entity, typeId); + return !components.empty(); + } + /// Create component for a given entity in safe way. /// @param entityId entity that will own component /// @param componentType Uuid of component to create @@ -26,7 +38,6 @@ namespace ROS2 /// We should use that that we are not sure if we access eg ROS2FrameComponent in game mode or from Editor /// @param entity pointer to entity eg with GetEntity() /// @return pointer to component with type T - template ComponentType* GetGameOrEditorComponent(const AZ::Entity* entity) { diff --git a/Gems/ROS2/Code/Source/Frame/ROS2FrameComponent.cpp b/Gems/ROS2/Code/Source/Frame/ROS2FrameComponent.cpp index 20c99557d..b48f8bfa0 100644 --- a/Gems/ROS2/Code/Source/Frame/ROS2FrameComponent.cpp +++ b/Gems/ROS2/Code/Source/Frame/ROS2FrameComponent.cpp @@ -8,7 +8,6 @@ #include "ROS2FrameSystemComponent.h" #include -#include #include #include #include @@ -21,6 +20,9 @@ #include #include #include +#include +#include +#include #include #include @@ -68,17 +70,6 @@ namespace ROS2 // Found the component! return component; } - - //! Checks whether the entity has a component of the given type - //! @param entity pointer to entity - //! @param typeId type of the component - //! @returns true if entity has component with given type - static bool CheckIfEntityHasComponentOfType(const AZ::Entity* entity, const AZ::Uuid typeId) - { - auto components = AZ::EntityUtils::FindDerivedComponents(entity, typeId); - return !components.empty(); - } - } // namespace Internal AZ::JsonSerializationResult::Result JsonFrameComponentConfigSerializer::Load( @@ -160,12 +151,9 @@ namespace ROS2 // Otherwise it'll be dynamic when it has joints and it's not a fixed joint. else { - const bool hasJoints = Internal::CheckIfEntityHasComponentOfType( - m_entity, AZ::Uuid("{B01FD1D2-1D91-438D-874A-BF5EB7E919A8}")); // Physx::JointComponent; - const bool hasFixedJoints = Internal::CheckIfEntityHasComponentOfType( - m_entity, AZ::Uuid("{02E6C633-8F44-4CEE-AE94-DCB06DE36422}")); // Physx::FixedJointComponent - const bool hasArticulations = Internal::CheckIfEntityHasComponentOfType( - m_entity, AZ::Uuid("{48751E98-B35F-4A2F-A908-D9CDD5230264}")); // Physx::ArticulationComponent + const bool hasJoints = Utils::HasComponentOfType(m_entity, PhysX::JointComponent::TYPEINFO_Uuid()); + const bool hasFixedJoints = Utils::HasComponentOfType(m_entity, PhysX::FixedJointComponent::TYPEINFO_Uuid()); + const bool hasArticulations = Utils::HasComponentOfType(m_entity, PhysX::ArticulationLinkComponent::TYPEINFO_Uuid()); m_isDynamic = (hasJoints && !hasFixedJoints) || hasArticulations; } diff --git a/Gems/ROS2/Code/Source/Manipulation/JointUtils.cpp b/Gems/ROS2/Code/Source/Manipulation/JointUtils.cpp new file mode 100644 index 000000000..ac6aeb238 --- /dev/null +++ b/Gems/ROS2/Code/Source/Manipulation/JointUtils.cpp @@ -0,0 +1,31 @@ +/* + * Copyright (c) Contributors to the Open 3D Engine Project. + * For complete copyright and license terms please see the LICENSE at the root of this distribution. + * + * SPDX-License-Identifier: Apache-2.0 OR MIT + * + */ + +#include "JointUtils.h" + +#include +#include +#include +#include +#include +#include + +namespace ROS2::JointUtils +{ + + bool HasNonFixedJoints(const AZ::Entity* entity) + { + const bool hasPrismaticJoints = Utils::HasComponentOfType(entity, PhysX::EditorPrismaticJointComponent::TYPEINFO_Uuid()); + const bool hasBallJoints = Utils::HasComponentOfType(entity, PhysX::EditorBallJointComponent::TYPEINFO_Uuid()); + const bool hasHingeJoints = Utils::HasComponentOfType(entity, PhysX::EditorHingeJointComponent::TYPEINFO_Uuid()); + const bool hasArticulations = Utils::HasComponentOfType(entity, PhysX::EditorArticulationLinkComponent::TYPEINFO_Uuid()); + const bool hasJoints = hasPrismaticJoints || hasBallJoints || hasHingeJoints || hasArticulations; + + return hasJoints; + } +} // namespace ROS2::Utils diff --git a/Gems/ROS2/Code/Source/Manipulation/JointUtils.h b/Gems/ROS2/Code/Source/Manipulation/JointUtils.h new file mode 100644 index 000000000..2273784d1 --- /dev/null +++ b/Gems/ROS2/Code/Source/Manipulation/JointUtils.h @@ -0,0 +1,19 @@ +/* + * Copyright (c) Contributors to the Open 3D Engine Project. + * For complete copyright and license terms please see the LICENSE at the root of this distribution. + * + * SPDX-License-Identifier: Apache-2.0 OR MIT + * + */ + +#pragma once + +#include + +namespace ROS2::JointUtils +{ + //! Check if the entity has any of the non fixed joint or articulation components. + //! @param entity Entity to check. + //! @return True if the entity has any of the joint or articulation components. + bool HasNonFixedJoints(const AZ::Entity* entity); +} // namespace ROS2::Utils diff --git a/Gems/ROS2/Code/Source/Manipulation/JointsManipulationEditorComponent.cpp b/Gems/ROS2/Code/Source/Manipulation/JointsManipulationEditorComponent.cpp index 7429856ad..8d7cfe989 100644 --- a/Gems/ROS2/Code/Source/Manipulation/JointsManipulationEditorComponent.cpp +++ b/Gems/ROS2/Code/Source/Manipulation/JointsManipulationEditorComponent.cpp @@ -7,6 +7,7 @@ */ #include "JointsManipulationEditorComponent.h" +#include "JointUtils.h" #include "JointsManipulationComponent.h" #include #include @@ -108,8 +109,10 @@ namespace ROS2 azrtti_cast(Utils::GetGameOrEditorComponent(entity)); AZ_Assert(frameEditorComponent, "ROS2FrameEditorComponent does not exist!"); + const bool hasNonFixedJoints = JointUtils::HasNonFixedJoints(entity); + AZStd::string jointName(frameEditorComponent->GetJointName().GetCStr()); - if (!jointName.empty()) + if (!jointName.empty() && hasNonFixedJoints) { m_initialPositions.emplace_back(AZStd::make_pair(jointName, configBackup[jointName])); } diff --git a/Gems/ROS2/Code/Source/Manipulation/JointsPositionsEditorComponent.cpp b/Gems/ROS2/Code/Source/Manipulation/JointsPositionsEditorComponent.cpp index f08747bca..8730ee08d 100644 --- a/Gems/ROS2/Code/Source/Manipulation/JointsPositionsEditorComponent.cpp +++ b/Gems/ROS2/Code/Source/Manipulation/JointsPositionsEditorComponent.cpp @@ -9,6 +9,7 @@ #include "JointsPositionsEditorComponent.h" #include "JointPositionsSubscriptionHandler.h" +#include "JointUtils.h" #include "JointsPositionsComponent.h" #include @@ -76,14 +77,17 @@ namespace ROS2 AZ::Crc32 JointsPositionsEditorComponent::FindAllJoints() { + m_jointNames.clear(); AZStd::function getAllJointsHierarchy = [&](const AZ::Entity* entity) { auto* frameEditorComponent = azrtti_cast(Utils::GetGameOrEditorComponent(entity)); AZ_Assert(frameEditorComponent, "ROS2FrameEditorComponent does not exist!"); + const bool hasNonFixedJoints = JointUtils::HasNonFixedJoints(entity); + AZStd::string jointName(frameEditorComponent->GetJointName().GetCStr()); - if (!jointName.empty()) + if (!jointName.empty() && hasNonFixedJoints) { m_jointNames.emplace_back(jointName); } diff --git a/Gems/ROS2/Code/ros2_editor_files.cmake b/Gems/ROS2/Code/ros2_editor_files.cmake index f0bfe1474..2cbe99b49 100644 --- a/Gems/ROS2/Code/ros2_editor_files.cmake +++ b/Gems/ROS2/Code/ros2_editor_files.cmake @@ -18,6 +18,8 @@ set(FILES Source/Manipulation/JointsPositionsEditorComponent.h Source/Manipulation/JointsManipulationEditorComponent.cpp Source/Manipulation/JointsManipulationEditorComponent.h + Source/Manipulation/JointUtils.cpp + Source/Manipulation/JointUtils.h Source/RobotImporter/FixURDF/FixURDF.cpp Source/RobotImporter/FixURDF/FixURDF.h Source/RobotImporter/Pages/ModifiedURDFWindow.cpp From 11a1efff5fdac1098ed958cc6977938efa5f5889 Mon Sep 17 00:00:00 2001 From: Jan Hanca Date: Thu, 23 Jan 2025 16:01:20 +0100 Subject: [PATCH 09/10] Disable ROS2OdometrySensor for Articulation links (#817) Signed-off-by: Jan Hanca --- .../Code/Source/Odometry/ROS2OdometrySensorComponent.cpp | 7 ++++++- .../Code/Source/Odometry/ROS2OdometrySensorComponent.h | 8 ++++---- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/Gems/ROS2/Code/Source/Odometry/ROS2OdometrySensorComponent.cpp b/Gems/ROS2/Code/Source/Odometry/ROS2OdometrySensorComponent.cpp index 0e9cb83b5..84011ef07 100644 --- a/Gems/ROS2/Code/Source/Odometry/ROS2OdometrySensorComponent.cpp +++ b/Gems/ROS2/Code/Source/Odometry/ROS2OdometrySensorComponent.cpp @@ -6,10 +6,10 @@ * */ +#include "ROS2OdometrySensorComponent.h" #include #include #include -#include "ROS2OdometrySensorComponent.h" #include #include @@ -55,6 +55,11 @@ namespace ROS2 required.push_back(AZ_CRC_CE("ROS2Frame")); } + void ROS2OdometrySensorComponent::GetIncompatibleServices(AZ::ComponentDescriptor::DependencyArrayType& incompatible) + { + incompatible.push_back(AZ_CRC("ArticulationLinkService")); + } + void ROS2OdometrySensorComponent::OnOdometryEvent(AzPhysics::SceneHandle sceneHandle) { if (m_bodyHandle == AzPhysics::InvalidSimulatedBodyHandle) diff --git a/Gems/ROS2/Code/Source/Odometry/ROS2OdometrySensorComponent.h b/Gems/ROS2/Code/Source/Odometry/ROS2OdometrySensorComponent.h index 27ca208c4..d70ee84b8 100644 --- a/Gems/ROS2/Code/Source/Odometry/ROS2OdometrySensorComponent.h +++ b/Gems/ROS2/Code/Source/Odometry/ROS2OdometrySensorComponent.h @@ -10,10 +10,10 @@ #include #include #include -#include -#include #include #include +#include +#include namespace ROS2 { @@ -21,14 +21,14 @@ namespace ROS2 //! It constructs and publishes an odometry message, which contains information about vehicle velocity and position in space. //! This is a ground truth "sensor", which can be helpful for development and machine learning. //! @see nav_msgs package. - class ROS2OdometrySensorComponent - : public ROS2SensorComponentBase + class ROS2OdometrySensorComponent : public ROS2SensorComponentBase { public: AZ_COMPONENT(ROS2OdometrySensorComponent, "{61387448-63AA-4563-AF87-60C72B05B863}", SensorBaseType); ROS2OdometrySensorComponent(); ~ROS2OdometrySensorComponent() = default; static void GetRequiredServices(AZ::ComponentDescriptor::DependencyArrayType& required); + static void GetIncompatibleServices(AZ::ComponentDescriptor::DependencyArrayType& incompatible); static void Reflect(AZ::ReflectContext* context); ////////////////////////////////////////////////////////////////////////// // Component overrides From 2d55ec84a7b82b0f48ed32323185c2941a429347 Mon Sep 17 00:00:00 2001 From: Artur Kamieniecki Date: Fri, 17 Jan 2025 12:18:00 +0100 Subject: [PATCH 10/10] Fix PostProcessFeatureProcessor view aliasing (#818) Signed-off-by: Artur Kamieniecki Add update view alias function Signed-off-by: Artur Kamieniecki --- Gems/ROS2/Code/Source/Camera/CameraSensor.cpp | 20 ++++++++++++++++++- Gems/ROS2/Code/Source/Camera/CameraSensor.h | 9 ++++++++- 2 files changed, 27 insertions(+), 2 deletions(-) diff --git a/Gems/ROS2/Code/Source/Camera/CameraSensor.cpp b/Gems/ROS2/Code/Source/Camera/CameraSensor.cpp index da6ea6710..9deb853ff 100644 --- a/Gems/ROS2/Code/Source/Camera/CameraSensor.cpp +++ b/Gems/ROS2/Code/Source/Camera/CameraSensor.cpp @@ -158,15 +158,33 @@ namespace ROS2 m_passHierarchy.push_back("CopyToSwapChain"); m_pipeline->SetDefaultView(m_view); - const AZ::RPI::ViewPtr targetView = m_scene->GetDefaultRenderPipeline()->GetDefaultView(); + UpdateViewAlias(); + + Camera::CameraNotificationBus::Handler::BusConnect(); + } + + void CameraSensor::OnCameraRemoved(const AZ::EntityId& cameraEntityId) + { + UpdateViewAlias(); + } + + void CameraSensor::OnActiveViewChanged(const AZ::EntityId& cameraEntityId) + { + UpdateViewAlias(); + } + + void CameraSensor::UpdateViewAlias() + { if (auto* fp = m_scene->GetFeatureProcessor()) { + const AZ::RPI::ViewPtr targetView = m_scene->GetDefaultRenderPipeline()->GetDefaultView(); fp->SetViewAlias(m_view, targetView); } } CameraSensor::~CameraSensor() { + Camera::CameraNotificationBus::Handler::BusDisconnect(); if (m_scene) { if (auto* fp = m_scene->GetFeatureProcessor()) diff --git a/Gems/ROS2/Code/Source/Camera/CameraSensor.h b/Gems/ROS2/Code/Source/Camera/CameraSensor.h index 43096f9d5..380169352 100644 --- a/Gems/ROS2/Code/Source/Camera/CameraSensor.h +++ b/Gems/ROS2/Code/Source/Camera/CameraSensor.h @@ -10,6 +10,7 @@ #include "CameraPublishers.h" #include #include +#include #include #include #include @@ -20,7 +21,7 @@ namespace ROS2 { //! Class to create camera sensor using Atom renderer //! It creates dedicated rendering pipeline for each camera - class CameraSensor + class CameraSensor : public Camera::CameraNotificationBus::Handler { public: //! Initializes rendering pipeline for the camera sensor. @@ -40,6 +41,12 @@ namespace ROS2 [[nodiscard]] const CameraSensorDescription& GetCameraSensorDescription() const; private: + // CameraNotificationBus overrides + void OnCameraRemoved(const AZ::EntityId& cameraEntityId) override; + void OnActiveViewChanged(const AZ::EntityId& cameraEntityId) override; + + void UpdateViewAlias(); + AZStd::vector m_passHierarchy; AZ::RPI::ViewPtr m_view; AZ::RPI::Scene* m_scene = nullptr;