-
Notifications
You must be signed in to change notification settings - Fork 72
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
base: feature/rfc_96_split_ros2
Are you sure you want to change the base?
EBus and ROS2 support for sensor configurations #894
Conversation
There was a problem hiding this 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. |
Gems/ROS2Sensors/Code/Include/ROS2Sensors/Lidar/LidarSensorConfiguration.h
Show resolved
Hide resolved
Gems/ROS2Sensors/Code/Include/ROS2Sensors/Configuration/ConfigurationBus.h
Outdated
Show resolved
Hide resolved
Gems/ROS2Sensors/Code/Include/ROS2Sensors/Configuration/ConfigurationBus.h
Outdated
Show resolved
Hide resolved
Gems/ROS2Sensors/Code/Include/ROS2Sensors/Configuration/ConfigurationBus.h
Outdated
Show resolved
Hide resolved
6bf2af4
to
3144a50
Compare
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]>
Signed-off-by: Artur Kamieniecki <[email protected]>
Signed-off-by: Artur Kamieniecki <[email protected]>
918d155
to
0b6463e
Compare
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]>
document.Parse(msg.c_str()); | ||
if (document.HasParseError()) | ||
{ | ||
AZ_Error("ROS2Sensors", false, "Failed to parse configuration message"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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()); |
auto configInstance = reinterpret_cast<ROS2WheelOdometryComponent*>(outputValue); | ||
AZ_Assert(configInstance, "Output value for JsonROS2WheelOdometryComponentConfigSerializer can't be null."); |
There was a problem hiding this comment.
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
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); |
serialize->Class<ROS2WheelOdometryComponent, SensorBaseType>()->Version(2)->Field( | ||
"Odometry configuration", &ROS2WheelOdometryComponent::m_odometryConfiguration); |
There was a problem hiding this comment.
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>>; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
} | |
} // namespace ROS2 |
namespace ROS2 { | ||
template<typename Configuration> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
namespace ROS2 { | |
template<typename Configuration> | |
namespace ROS2 | |
{ | |
template<typename Configuration> |
ROS2OdometryCovariance m_poseCovariance; | ||
ROS2OdometryCovariance m_twistCovariance; | ||
}; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
} | |
} // namespace ROS2 |
//! A structure capturing configuration of a wheel odometry sensor. | ||
struct ROS2WheelOdometryConfiguration | ||
{ | ||
AZ_RTTI(ROS2WheelOdometryConfiguration, "{9dc58d89-e674-4d7f-9ea9-afe3ae7fd2eb}"); |
There was a problem hiding this comment.
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}"); |
There was a problem hiding this comment.
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}"); |
There was a problem hiding this comment.
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}"); |
There was a problem hiding this comment.
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); |
There was a problem hiding this comment.
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> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consider:
template<typename Configuration> | |
template<typename ConfigurationT> |
There was a problem hiding this 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)); |
There was a problem hiding this comment.
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; |
There was a problem hiding this comment.
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?
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.