Skip to content

Commit 1516a27

Browse files
committed
neat collection
Signed-off-by: Adam Dąbrowski <[email protected]>
1 parent 15f1bd5 commit 1516a27

File tree

4 files changed

+26
-5
lines changed

4 files changed

+26
-5
lines changed

Gems/ROS2/Code/Source/Sensor/PublisherConfiguration.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ namespace ROS2
1919
{
2020
if (auto serializeContext = azrtti_cast<AZ::SerializeContext*>(context))
2121
{
22+
serializeContext->RegisterGenericType<AZStd::vector<PublisherConfiguration>>();
2223
serializeContext->Class<PublisherConfiguration>()
2324
->Version(1)
2425
->Field("Type", &PublisherConfiguration::m_type)
@@ -29,10 +30,9 @@ namespace ROS2
2930
if (AZ::EditContext* ec = serializeContext->GetEditContext())
3031
{
3132
ec->Class<PublisherConfiguration>("ROS2 Publisher configuration", "Publisher configuration")
32-
->DataElement(AZ::Edit::UIHandlers::Default, &PublisherConfiguration::m_type, "Type", "Type of topic")
33-
->Attribute(AZ::Edit::Attributes::ReadOnly, true)
34-
->DataElement(AZ::Edit::UIHandlers::Default, &PublisherConfiguration::m_topic, "Topic", "Topic with no namespace")
35-
;
33+
->ClassElement(AZ::Edit::ClassElements::EditorData, "")
34+
->DataElement(AZ::Edit::UIHandlers::Default, &PublisherConfiguration::m_topic, "Topic", "Topic with no namespace")
35+
;
3636
}
3737
}
3838
};

Gems/ROS2/Code/Source/Sensor/PublisherConfiguration.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,16 @@ namespace ROS2
2424
virtual ~PublisherConfiguration() = default;
2525
static void Reflect(AZ::ReflectContext* context);
2626

27+
bool operator==(const PublisherConfiguration& other) const
28+
{
29+
if (m_type != other.m_type)
30+
{
31+
return false;
32+
}
33+
34+
return m_topic == other.m_topic;
35+
}
36+
2737
AZStd::string m_type = "std_msgs::msg::Empty";
2838
AZStd::string m_topic = "default_topic";
2939
rclcpp::QoS m_qos = 10;

Gems/ROS2/Code/Source/Sensor/SensorConfiguration.cpp

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ namespace ROS2
1919
PublisherConfiguration::Reflect(context);
2020
if (auto serializeContext = azrtti_cast<AZ::SerializeContext*>(context))
2121
{
22-
serializeContext->RegisterGenericType<AZStd::vector<PublisherConfiguration>>();
2322
serializeContext->Class<SensorConfiguration>()
2423
->Version(1)
2524
->Field("Visualise", &SensorConfiguration::m_visualise)
@@ -31,15 +30,24 @@ namespace ROS2
3130
if (AZ::EditContext* ec = serializeContext->GetEditContext())
3231
{
3332
ec->Class<SensorConfiguration>("ROS2 Sensor Component", "[Base component for sensors]")
33+
->ClassElement(AZ::Edit::ClassElements::EditorData, "")
3434
->DataElement(AZ::Edit::UIHandlers::Default, &SensorConfiguration::m_visualise, "Visualise", "Visualise")
3535
->DataElement(AZ::Edit::UIHandlers::Default, &SensorConfiguration::m_publishingEnabled, "Publishing Enabled", "Toggle publishing for topic")
3636
->DataElement(AZ::Edit::UIHandlers::Default, &SensorConfiguration::m_frequency, "Frequency", "Frequency of publishing")
3737
->Attribute(AZ::Edit::Attributes::Min, 1)
3838
->Attribute(AZ::Edit::Attributes::Max, 100)
39+
->Attribute(AZ::Edit::Attributes::Step, 1)
3940
->DataElement(AZ::Edit::UIHandlers::Default, &SensorConfiguration::m_publishersConfigurations, "Publishers", "Publishers")
4041
->Attribute(AZ::Edit::Attributes::ContainerCanBeModified, false)
42+
->Attribute(AZ::Edit::Attributes::AutoExpand, true)
43+
->Attribute(AZ::Edit::Attributes::IndexedChildNameLabelOverride, &SensorConfiguration::GetPublisherLabel)
4144
;
4245
}
4346
}
4447
}
48+
49+
AZStd::string SensorConfiguration::GetPublisherLabel(int index) const
50+
{
51+
return m_publishersConfigurations[index].m_type;
52+
}
4553
} // namespace ROS2

Gems/ROS2/Code/Source/Sensor/SensorConfiguration.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,9 @@ namespace ROS2
3333
float m_frequency = 10;
3434
bool m_publishingEnabled = true;
3535
bool m_visualise = true;
36+
37+
private:
38+
AZStd::string GetPublisherLabel(int index) const;
3639
};
3740
} // namespace ROS2
3841

0 commit comments

Comments
 (0)