Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cherry-picks for 2409.1 point release #784

Merged
1 change: 1 addition & 0 deletions Gems/ROS2/Code/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ ly_add_target(
Gem::Atom_RPI.Public
Gem::Atom_Feature_Common.Static
Gem::Atom_Component_DebugCamera.Static
Gem::Atom_AtomBridge.Static
Gem::StartingPointInput
Gem::PhysX5.Static
Gem::LmbrCentral.API
Expand Down
18 changes: 16 additions & 2 deletions Gems/ROS2/Code/Source/Camera/CameraSensor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
#include <Atom/RPI.Public/RenderPipeline.h>
#include <Atom/RPI.Public/Scene.h>
#include <AzCore/Math/MatrixUtils.h>
#include <AzCore/Settings/SettingsRegistry.h>
#include <AzFramework/Components/TransformComponent.h>
#include <AzFramework/Scene/SceneSystemInterface.h>
#include <PostProcess/PostProcessFeatureProcessor.h>
Expand All @@ -27,6 +28,8 @@ namespace ROS2
{
namespace Internal
{
constexpr AZStd::string_view AllowCameraPipelineModificationKey = "/O3DE/ROS2/Camera/AllowPipelineModification";

/// @FormatMappings - contains the mapping from RHI to ROS image encodings. List of supported
/// ROS image encodings lives in `sensor_msgs/image_encodings.hpp`
/// We are not including `image_encodings.hpp` since it uses exceptions.
Expand Down Expand Up @@ -107,7 +110,18 @@ namespace ROS2

void CameraSensor::SetupPasses()
{
AZ_TracePrintf("CameraSensor", "Initializing pipeline for %s\n", m_cameraSensorDescription.m_cameraName.c_str());
bool allowModification = false;
auto* registry = AZ::SettingsRegistry::Get();
AZ_Assert(registry, "No Registry available");
if (registry)
{
registry->Get(allowModification, Internal::AllowCameraPipelineModificationKey);
}
AZ_Trace(
"CameraSensor",
"Initializing pipeline for %s, pipeline modification : %s\n",
m_cameraSensorDescription.m_cameraName.c_str(),
allowModification ? "yes" : "no");

const AZ::Name viewName = AZ::Name("MainCamera");
m_view = AZ::RPI::View::CreateView(viewName, AZ::RPI::View::UsageCamera);
Expand All @@ -123,7 +137,7 @@ namespace ROS2
m_entityId.ToString().c_str());
AZ::RPI::RenderPipelineDescriptor pipelineDesc;
pipelineDesc.m_mainViewTagName = "MainCamera";
pipelineDesc.m_allowModification = true;
pipelineDesc.m_allowModification = allowModification;
pipelineDesc.m_name = m_pipelineName;

pipelineDesc.m_rootPassTemplate = GetPipelineTemplateName();
Expand Down
27 changes: 21 additions & 6 deletions Gems/ROS2/Code/Source/Frame/Conversions/FrameConversion.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

def find_and_replace(data):

def search_for_components(item, foundComponents):
def search_for_components(item, foundComponents, insidePatches=False):
if isinstance(item, dict):
if "Components" in item:
foundComponents = True
Expand All @@ -32,13 +32,28 @@ def search_for_components(item, foundComponents):
modifiedElement["ROS2FrameConfiguration"] = modifiedElement["m_template"]
del modifiedElement["m_template"]
item = modifiedElement
if "op" in item and item["op"] == "replace" and "path" in item:
item["path"] = item["path"].replace("ROS2FrameComponent/m_template", "ROS2FrameEditorComponent/ROS2FrameConfiguration")
for value in item.values():
search_for_components(value, foundComponents)

# Check if inside "Patches" section
if "Patches" in item:
insidePatches = True

# Only apply path changes inside "Patches"
if insidePatches and "op" in item and "path" in item:
# We directly look for the ROS2FrameComponent fields and replace "m_template" with "ROS2FrameConfiguration"
if any(substring in item["path"] for substring in [
"m_template/Namespace Configuration",
"m_template/Frame Name",
"m_template/Publish Transform",
"m_template/Joint Name"
]):
item["path"] = item["path"].replace("m_template", "ROS2FrameConfiguration")

for key, value in item.items():
search_for_components(value, foundComponents, insidePatches)

elif isinstance(item, list):
for element in item:
search_for_components(element, foundComponents)
search_for_components(element, foundComponents, insidePatches)

search_for_components(data, False)

Expand Down
6 changes: 6 additions & 0 deletions Gems/ROS2/Code/Source/Frame/NamespaceConfiguration.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,12 @@ namespace ROS2
{
m_namespace = ros2Namespace;
m_namespaceStrategy = strategy;

if (strategy == NamespaceStrategy::Custom)
{
m_customNamespace = ros2Namespace;
}

UpdateNamespace();
}

Expand Down
1 change: 1 addition & 0 deletions Gems/ROS2/Code/Source/Frame/ROS2FrameEditorComponent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ namespace ROS2
ec->Class<ROS2FrameEditorComponent>("ROS2 Frame", "[ROS2 Frame component]")
->ClassElement(AZ::Edit::ClassElements::EditorData, "")
->Attribute(AZ::Edit::Attributes::AppearsInAddComponentMenu, AZ_CRC_CE("Game"))
->Attribute(AZ::Edit::Attributes::AppearsInAddComponentMenu, AZ_CRC_CE("Level"))
->Attribute(AZ::Edit::Attributes::Category, "ROS2")
->Attribute(AZ::Edit::Attributes::Icon, "Editor/Icons/Components/ROS2Frame.svg")
->Attribute(AZ::Edit::Attributes::ViewportIcon, "Editor/Icons/Components/Viewport/ROS2Frame.svg")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
*/

#include "FollowingCameraComponent.h"
#include <AtomBridge/FlyCameraInputBus.h>
#include <AzCore/Serialization/EditContext.h>
#include <AzCore/Serialization/SerializeContext.h>
#include <AzFramework/Input/Devices/Keyboard/InputDeviceKeyboard.h>
Expand All @@ -29,8 +30,6 @@ namespace ROS2
{
}



void FollowingCameraComponent::Reflect(AZ::ReflectContext* reflection)
{
FollowingCameraConfiguration::Reflect(reflection);
Expand Down Expand Up @@ -89,6 +88,8 @@ namespace ROS2
if (m_configuration.m_defaultView < m_configuration.m_predefinedViews.size())
{
m_currentView = m_configuration.m_predefinedViews[m_configuration.m_defaultView];
AZ::AtomBridge::FlyCameraInputBus::EventResult(
m_disableCameraMove, m_currentView, &AZ::AtomBridge::FlyCameraInputBus::Events::GetIsEnabled);
}
InputChannelEventListener::Connect();
AZ::TickBus::Handler::BusConnect();
Expand All @@ -105,7 +106,8 @@ namespace ROS2
const AZ::Vector3 axisX = transform.GetBasisX();
const AZ::Vector3 axisY = transform.GetBasisY();

const AZ::Matrix3x3 projectionOnXY {AZ::Matrix3x3::CreateFromColumns(AZ::Vector3::CreateAxisX(), AZ::Vector3::CreateAxisY(), AZ::Vector3::CreateZero())};
const AZ::Matrix3x3 projectionOnXY{ AZ::Matrix3x3::CreateFromColumns(
AZ::Vector3::CreateAxisX(), AZ::Vector3::CreateAxisY(), AZ::Vector3::CreateZero()) };

const AZ::Vector3 newAxisZ = AZ::Vector3::CreateAxisZ(); // new axis Z points up

Expand Down Expand Up @@ -226,26 +228,29 @@ namespace ROS2
void FollowingCameraComponent::OnKeyboardEvent(const AzFramework::InputChannel& inputChannel)
{
const AzFramework::InputChannelId& channelId = inputChannel.GetInputChannelId();
if (channelId == AzFramework::InputDeviceKeyboard::Key::AlphanumericW)
{
m_opticalAxisTranslation += m_configuration.m_zoomSpeed;
m_opticalAxisTranslation = AZStd::min(m_opticalAxisTranslation, m_configuration.m_opticalAxisTranslationMin);
return;
}
if (channelId == AzFramework::InputDeviceKeyboard::Key::AlphanumericS)
{
m_opticalAxisTranslation -= m_configuration.m_zoomSpeed;
return;
}
if (channelId == AzFramework::InputDeviceKeyboard::Key::AlphanumericA)
{
m_rotationOffset -= m_configuration.m_rotationSpeed;
return;
}
if (channelId == AzFramework::InputDeviceKeyboard::Key::AlphanumericD)
if (!m_disableCameraMove)
{
m_rotationOffset += m_configuration.m_rotationSpeed;
return;
if (channelId == AzFramework::InputDeviceKeyboard::Key::AlphanumericW)
{
m_opticalAxisTranslation += m_configuration.m_zoomSpeed;
m_opticalAxisTranslation = AZStd::min(m_opticalAxisTranslation, m_configuration.m_opticalAxisTranslationMin);
return;
}
if (channelId == AzFramework::InputDeviceKeyboard::Key::AlphanumericS)
{
m_opticalAxisTranslation -= m_configuration.m_zoomSpeed;
return;
}
if (channelId == AzFramework::InputDeviceKeyboard::Key::AlphanumericA)
{
m_rotationOffset -= m_configuration.m_rotationSpeed;
return;
}
if (channelId == AzFramework::InputDeviceKeyboard::Key::AlphanumericD)
{
m_rotationOffset += m_configuration.m_rotationSpeed;
return;
}
}

// channelId is a numeric key (Key::Alphanumeric0-Key::Alphanumeric9)
Expand All @@ -256,6 +261,12 @@ namespace ROS2
m_currentView = m_configuration.m_predefinedViews[viewId];
m_lastTranslationsBuffer.clear();
m_lastRotationsBuffer.clear();
m_rotationOffset = 0.0f;
m_opticalAxisTranslation = 0.0f;

m_disableCameraMove = false; // reset value before reading
AZ::AtomBridge::FlyCameraInputBus::EventResult(
m_disableCameraMove, m_currentView, &AZ::AtomBridge::FlyCameraInputBus::Events::GetIsEnabled);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ namespace ROS2
float m_rotationOffset = 0.0f; //!< The rotation change from the input.
float m_opticalAxisTranslation = 0.0f; //!< The zoom change from the input.
AZ::EntityId m_currentView; //!< Current used view point.
bool m_disableCameraMove = false; //!< Disable camera move (used when fly camera is selected).

FollowingCameraConfiguration m_configuration; //!< The configuration of the following camera.
};
Expand Down
9 changes: 2 additions & 7 deletions Gems/ROS2/Code/Source/Spawner/ROS2SpawnerComponent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -243,14 +243,8 @@ namespace ROS2
PreSpawn(id, view, transform, spawnableName, spawnableNamespace);
};

optionalArgs.m_completionCallback = [service_handle, header, ticketName, parentId = GetEntityId()](auto id, auto view)
optionalArgs.m_completionCallback = [service_handle, header, ticketName](auto id, auto view)
{
if (!view.empty())
{
const AZ::Entity* root = *view.begin();
auto* transformInterface = root->FindComponent<AzFramework::TransformComponent>();
transformInterface->SetParent(parentId);
}
SpawnEntityResponse response;
response.success = true;
response.status_message = ticketName.c_str();
Expand All @@ -275,6 +269,7 @@ namespace ROS2

auto* transformInterface = root->FindComponent<AzFramework::TransformComponent>();
transformInterface->SetWorldTM(transform);
transformInterface->SetParent(GetEntityId());

AZStd::string instanceName = AZStd::string::format("%s_%d", spawnableName.c_str(), m_counter++);
for (AZ::Entity* entity : view)
Expand Down
4 changes: 2 additions & 2 deletions Gems/ROS2/gem.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"gem_name": "ROS2",
"version": "3.2.1",
"version": "3.1.1",
"platforms": [
"Linux"
],
Expand Down Expand Up @@ -36,5 +36,5 @@
],
"restricted": "ROS2",
"repo_uri": "https://raw.githubusercontent.com/o3de/o3de-extras/development",
"download_source_uri": "https://github.com/o3de/o3de-extras/releases/download/2.0//ros2-3.2.1-gem.zip"
"download_source_uri": "https://github.com/o3de/o3de-extras/releases/download/2.0/ros2-3.1.1-gem.zip"
}
4 changes: 2 additions & 2 deletions Projects/OpenXRTest/project.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
{
"project_name": "OpenXRTest",
"version": "1.0.0",
"version": "1.0.1",
"project_id": "{947211d5-689a-437f-8ad7-7f558edcd40a}",
"repo_uri": "https://raw.githubusercontent.com/o3de/o3de-extras/development",
"download_source_uri": "https://github.com/o3de/o3de-extras/releases/download/2.0/openxrtest-1.0.0-project.zip",
"download_source_uri": "https://github.com/o3de/o3de-extras/releases/download/2.0/openxrtest-1.0.1-project.zip",
"origin": "https://github.com/o3de/o3de-extras",
"license": "For terms please see the LICENSE*.TXT files at the root of this distribution.",
"display_name": "OpenXRTest",
Expand Down
5 changes: 4 additions & 1 deletion Templates/Multiplayer/template.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"template_name": "Multiplayer",
"version": "2.0.0",
"origin": "Open 3D Engine - o3de.org",
"license": "https://opensource.org/licenses/MIT",
"display_name": "Multiplayer",
Expand Down Expand Up @@ -1472,5 +1473,7 @@
{
"dir": "cmake"
}
]
],
"repo_uri": "https://raw.githubusercontent.com/o3de/o3de-extras/development",
"download_source_uri": "https://github.com/o3de/o3de-extras/releases/download/2.0/multiplayer-2.0.0-template.zip"
}
20 changes: 20 additions & 0 deletions Templates/Ros2FleetRobotTemplate/Template/Registry/ros2.setreg
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"O3DE":
{
"InputSystem":
{
"Mouse":
{
"CaptureMouseCursor": false
}
},
"ROS2":
{
"SteadyClock" : true,
"Camera":
{
"AllowPipelineModification": true
}
}
}
}
4 changes: 4 additions & 0 deletions Templates/Ros2FleetRobotTemplate/template.json
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,10 @@
"file": "Registry/physxsystemconfiguration.setreg",
"isTemplated": false
},
{
"file": "Registry/ros2.setreg",
"isTemplated": false
},
{
"file": "Resources/GameSDK.ico",
"isTemplated": false
Expand Down
20 changes: 20 additions & 0 deletions Templates/Ros2ProjectTemplate/Template/Registry/ros2.setreg
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"O3DE":
{
"InputSystem":
{
"Mouse":
{
"CaptureMouseCursor": false
}
},
"ROS2":
{
"SteadyClock" : true,
"Camera":
{
"AllowPipelineModification": false
}
}
}
}
8 changes: 6 additions & 2 deletions Templates/Ros2ProjectTemplate/template.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"template_name": "Ros2ProjectTemplate",
"version": "2.0.0",
"version": "2.0.1",
"origin": "Open 3D Engine Extras",
"origin_url": "https://github.com/o3de/o3de-extras",
"license": "https://github.com/o3de/o3de-extras/tree/development/Templates/Ros2ProjectTemplate/Template/LICENSE.txt",
Expand Down Expand Up @@ -234,6 +234,10 @@
"file": "Registry/sceneassetimporter.setreg",
"isTemplated": false
},
{
"file": "Registry/ros2.setreg",
"isTemplated": false
},
{
"file": "Resources/GameSDK.ico",
"isTemplated": false
Expand Down Expand Up @@ -557,5 +561,5 @@
}
],
"repo_uri": "https://raw.githubusercontent.com/o3de/o3de-extras/development",
"download_source_uri": "https://github.com/o3de/o3de-extras/releases/download/2.0/ros2projecttemplate-2.0.0-template.zip"
"download_source_uri": "https://github.com/o3de/o3de-extras/releases/download/2.0/ros2projecttemplate-2.0.1-template.zip"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"O3DE":
{
"InputSystem":
{
"Mouse":
{
"CaptureMouseCursor": false
}
},
"ROS2":
{
"SteadyClock" : true,
"Camera":
{
"AllowPipelineModification": true
}
}
}
}
Loading