Skip to content

EBus and ROS2 support for sensor configurations #894

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

Open
wants to merge 16 commits into
base: feature/rfc_96_split_ros2
Choose a base branch
from

Conversation

arturkamieniecki
Copy link
Contributor

@arturkamieniecki arturkamieniecki commented Apr 22, 2025

What does this PR do?

This PR enables runtime modification of sensor configuration using EBuses and ROS2 messages.
It add a new toggle to all sensors. If it is enabled, the sensor will create two topics. Get configuration and set configuration. Each of these components will use JSON to communicate.

How was this PR tested?

By modifying the configuration of the components.

@arturkamieniecki arturkamieniecki changed the title Ak/sensor configurations EBus support for sensor configurations Apr 22, 2025
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR adds runtime sensor configuration support via EBuses and introduces new configuration structures across multiple sensor components. Key changes include:

  • Introduction of configuration structs and Bus overrides for GNSS, Contact, and Camera sensor components.
  • Refactoring of ROS2SensorComponentBase to support a configuration template parameter.
  • Updates to include paths and adjustments to Lidar sensor configuration with mutable model lists.

Reviewed Changes

Copilot reviewed 43 out of 43 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
Gems/ROS2Sensors/Code/Source/Imu/ImuSensorConfiguration.cpp Updated include path to use ROS2Sensors module.
Gems/ROS2Sensors/Code/Source/GNSS/ROS2GNSSSensorComponent.{h,cpp} Added configuration struct and overrides for GNSS sensor.
Gems/ROS2Sensors/Code/Source/ContactSensor/ROS2ContactSensorComponent.{h,cpp} Introduced configuration struct and interface for the Contact sensor.
Gems/ROS2Sensors/Code/Source/Camera/ROS2CameraSensorComponent{.h,.cpp} Refactored sensor activation and configuration handling; added dedicated configuration method.
Gems/ROS2Sensors/Code/Include/ROS2Sensors/Sensor/ROS2SensorComponentBase.h Updated base component to be templated with a configuration type and integrated ConfigurationBus support.
Gems/ROS2Sensors/Code/Include/ROS2Sensors/Lidar/LidarSensorConfiguration.h Modified include paths and changed m_availableModels from const to mutable.
Gems/ROS2Sensors/Code/Include/ROS2Sensors/Configuration/ConfigurationBus.h Added a new configuration Bus interface.

@byrcolin byrcolin added the sig/simulation Categorizes an issue or PR as relevant to SIG Simulation label Apr 22, 2025
@jhanca-robotecai jhanca-robotecai force-pushed the feature/rfc_96_split_ros2 branch from 6bf2af4 to 3144a50 Compare April 24, 2025 06:47
Signed-off-by: Artur Kamieniecki <[email protected]>
Signed-off-by: Artur Kamieniecki <[email protected]>
Signed-off-by: Artur Kamieniecki <[email protected]>
Signed-off-by: Artur Kamieniecki <[email protected]>
Signed-off-by: Artur Kamieniecki <[email protected]>
Signed-off-by: Artur Kamieniecki <[email protected]>
Signed-off-by: Artur Kamieniecki <[email protected]>
Signed-off-by: Artur Kamieniecki <[email protected]>
Signed-off-by: Artur Kamieniecki <[email protected]>
@arturkamieniecki arturkamieniecki force-pushed the ak/SensorConfigurations branch from 918d155 to 0b6463e Compare April 24, 2025 07:49
Signed-off-by: Artur Kamieniecki <[email protected]>
Signed-off-by: Artur Kamieniecki <[email protected]>
@arturkamieniecki arturkamieniecki marked this pull request as ready for review April 24, 2025 07:57
@arturkamieniecki arturkamieniecki requested review from a team as code owners April 24, 2025 07:57
Signed-off-by: Artur Kamieniecki <[email protected]>
Signed-off-by: Artur Kamieniecki <[email protected]>
@arturkamieniecki arturkamieniecki changed the title EBus support for sensor configurations EBus and ROS2 support for sensor configurations Apr 24, 2025
Signed-off-by: Artur Kamieniecki <[email protected]>
document.Parse(msg.c_str());
if (document.HasParseError())
{
AZ_Error("ROS2Sensors", false, "Failed to parse configuration message");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
AZ_Error("ROS2Sensors", false, "Failed to parse configuration message");
AZ_Error("ROS2Sensors", false, "Failed to parse configuration message: %s (Offset %u)", rapidjson::GetParseError_En(document.GetParseError()), document.GetErrorOffset());

Comment on lines +38 to +39
auto configInstance = reinterpret_cast<ROS2WheelOdometryComponent*>(outputValue);
AZ_Assert(configInstance, "Output value for JsonROS2WheelOdometryComponentConfigSerializer can't be null.");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

reinterpret_cast is not the same as dynamic_cast, so if the expectation here is to validate the pointer type with the assert, all this assert will do is check if configInstance is null or not. To be clearer, the assert should be done up front

Suggested change
auto configInstance = reinterpret_cast<ROS2WheelOdometryComponent*>(outputValue);
AZ_Assert(configInstance, "Output value for JsonROS2WheelOdometryComponentConfigSerializer can't be null.");
AZ_Assert(outputValue, "Output value for JsonROS2WheelOdometryComponentConfigSerializer can't be null.");
auto configInstance = reinterpret_cast<ROS2WheelOdometryComponent*>(outputValue);

Comment on lines +112 to +113
serialize->Class<ROS2WheelOdometryComponent, SensorBaseType>()->Version(2)->Field(
"Odometry configuration", &ROS2WheelOdometryComponent::m_odometryConfiguration);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The formatting got collapsed here?


template<typename Configuration>
using ConfigurationBus = AZ::EBus<ConfigurationRequests<Configuration>>;
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
}
} // namespace ROS2

Comment on lines +14 to +15
namespace ROS2 {
template<typename Configuration>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
namespace ROS2 {
template<typename Configuration>
namespace ROS2
{
template<typename Configuration>

ROS2OdometryCovariance m_poseCovariance;
ROS2OdometryCovariance m_twistCovariance;
};
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
}
} // namespace ROS2

//! A structure capturing configuration of a wheel odometry sensor.
struct ROS2WheelOdometryConfiguration
{
AZ_RTTI(ROS2WheelOdometryConfiguration, "{9dc58d89-e674-4d7f-9ea9-afe3ae7fd2eb}");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Move the UUID to the ROS2SensorsTypeIds.h.

//! This structure is required to be able to use the SensorConfigurationRequestBus.
struct ROS2ContactSensorConfiguration
{
AZ_RTTI(ROS2ContactSensorConfiguration, "{f7ebfb9d-2d49-4059-a88f-f577a52cd68c}");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Move the UUID to the ROS2SensorsTypeIds.h file.

//! This structure is required to be able to use the SensorConfigurationRequestBus.
struct ROS2GNSSSensorConfiguration
{
AZ_RTTI(ROS2GNSSSensorConfiguration, "{e85947cc-2821-4fa7-93d0-b3150999a588}");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Move the UUID to the ROS2SensorsTypeIds.h file.

//! This structure is required to be able to use the SensorConfigurationRequestBus.
struct ROS2OdometrySensorConfiguration
{
AZ_RTTI(ROS2OdometrySensorConfiguration, "{04c5d154-6fa7-4c12-a4e3-025ac853198a}");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Move the UUID to the ROS2SensorsTypeIds.h file.

class JsonROS2WheelOdometryComponentConfigSerializer : public AZ::BaseJsonSerializer
{
public:
AZ_RTTI(JsonROS2WheelOdometryComponentConfigSerializer, "{3f7f9be6-d964-4a55-b856-c03cc5754df0}", AZ::BaseJsonSerializer);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Move the UUID to the ROS2SensorsTypeIds.h file.

#include <AzCore/Component/EntityId.h>

namespace ROS2 {
template<typename Configuration>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider:

Suggested change
template<typename Configuration>
template<typename ConfigurationT>

Copy link
Contributor

@michalpelka michalpelka left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think reusing std_msgs/string is not acceptable approach.
I support some internal API for adjusting sensors but ROS 2 messages should be used for sensors' data.

@@ -76,7 +76,6 @@ namespace ROS2
void ROS2SystemComponent::GetRequiredServices([[maybe_unused]] AZ::ComponentDescriptor::DependencyArrayType& required)
{
required.push_back(AZ_CRC("AssetDatabaseService", 0x3abf5601));
required.push_back(AZ_CRC("RPISystem", 0xf2add773));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FYI : this change is in the development.

{
AZStd::string ns = GetNamespace();
AZStd::string configurationName = ComponentConfigurationT::TYPEINFO_Name();
AZStd::string getTopic = ns + "/" + "Get" + configurationName;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be done with services.
The question is should be done?
I think at least RFC should be written on this feature. The review is not good place to discuss the shape of this feature.
It can modify configuration re-using string message. But how to modify extrinsic calibration of camera or lidar with this change?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
sig/simulation Categorizes an issue or PR as relevant to SIG Simulation
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants