Skip to content

Commit 15f1bd5

Browse files
committed
Modified editor items behavior. Fixed invalid GUID
Signed-off-by: Adam Dąbrowski <[email protected]>
1 parent 4a42901 commit 15f1bd5

File tree

5 files changed

+20
-51
lines changed

5 files changed

+20
-51
lines changed

Gems/ROS2/Code/Source/Lidar/ROS2LidarSensorComponent.cpp

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ namespace ROS2
2525
serialize->Class<ROS2LidarSensorComponent, ROS2SensorComponent>()
2626
->Version(1)
2727
->Field("lidarModel", &ROS2LidarSensorComponent::m_lidarModel)
28+
->Field("SensorConfiguration", &ROS2LidarSensorComponent::m_sensorConfiguration)
2829
;
2930

3031
if (AZ::EditContext* ec = serialize->GetEditContext())
@@ -33,20 +34,29 @@ namespace ROS2
3334
->ClassElement(AZ::Edit::ClassElements::EditorData, "")
3435
->Attribute(AZ::Edit::Attributes::AppearsInAddComponentMenu, AZ_CRC("Game"))
3536
->DataElement(AZ::Edit::UIHandlers::Default, &ROS2LidarSensorComponent::m_lidarModel, "Lidar Model", "Lidar model")
37+
->DataElement(AZ::Edit::UIHandlers::Default, &ROS2LidarSensorComponent::m_sensorConfiguration, "Sensor configuration", "Sensor configuration")
3638
;
3739
}
3840
}
3941
}
4042

43+
ROS2LidarSensorComponent::ROS2LidarSensorComponent()
44+
{ // TODO - replace with EditorComponent behavior
45+
SensorConfiguration sc;
46+
PublisherConfiguration pc;
47+
pc.m_type = "sensor_msgs::msg::PointCloud2";
48+
pc.m_topic = "pc";
49+
m_sensorConfiguration.m_frequency = 10; // TODO - dependent on lidar type
50+
m_sensorConfiguration.m_publishersConfigurations = { pc };
51+
}
52+
4153
void ROS2LidarSensorComponent::Activate()
4254
{
4355
ROS2SensorComponent::Activate();
4456
auto ros2Node = ROS2Interface::Get()->GetNode();
45-
auto config = GetConfiguration();
46-
47-
AZ_Assert(config.m_publishersConfigurations.size() == 1, "Invalid configuration of publishers for lidar sensor");
57+
AZ_Assert(m_sensorConfiguration.m_publishersConfigurations.size() == 1, "Invalid configuration of publishers for lidar sensor");
4858

49-
const auto& publisherConfig = config.m_publishersConfigurations.front();
59+
const auto& publisherConfig = m_sensorConfiguration.m_publishersConfigurations.front();
5060
AZStd::string fullTopic = ROS2Names::GetNamespacedName(GetNamespace(), publisherConfig.m_topic);
5161
m_pointCloudPublisher = ros2Node->create_publisher<sensor_msgs::msg::PointCloud2>(fullTopic.data(), publisherConfig.m_qos);
5262
}
@@ -99,15 +109,4 @@ namespace ROS2
99109

100110
m_pointCloudPublisher->publish(message);
101111
}
102-
103-
SensorConfiguration ROS2LidarSensorComponent::DefaultConfiguration() const
104-
{
105-
SensorConfiguration sc;
106-
PublisherConfiguration pc;
107-
pc.m_type = "sensor_msgs::msg::PointCloud2";
108-
pc.m_topic = "pc";
109-
sc.m_frequency = 10; // TODO - dependent on lidar type
110-
sc.m_publishersConfigurations = { pc };
111-
return sc;
112-
}
113112
} // namespace ROS2

Gems/ROS2/Code/Source/Lidar/ROS2LidarSensorComponent.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,14 @@ namespace ROS2
2323
{
2424
public:
2525
AZ_COMPONENT(ROS2LidarSensorComponent, "{502A955F-7742-4E23-AD77-5E4063739DCA}", ROS2SensorComponent);
26+
ROS2LidarSensorComponent();
27+
~ROS2LidarSensorComponent() = default;
2628
static void Reflect(AZ::ReflectContext* context);
2729
void Activate() override;
2830
void Deactivate() override;
2931

3032
private:
3133
void FrequencyTick() override;
32-
SensorConfiguration DefaultConfiguration() const override;
3334

3435
LidarTemplate::LidarModel m_lidarModel = LidarTemplate::SickMRS6000;
3536
LidarRaycaster m_lidarRaycaster;

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ namespace ROS2
1919
struct PublisherConfiguration
2020
{
2121
public:
22-
AZ_RTTI(PublisherConfiguration, "{{7F875348-F2F9-404A-841E-D9A749EA4E79}}");
22+
AZ_RTTI(PublisherConfiguration, "{7F875348-F2F9-404A-841E-D9A749EA4E79}");
2323
PublisherConfiguration() = default;
2424
virtual ~PublisherConfiguration() = default;
2525
static void Reflect(AZ::ReflectContext* context);

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

Lines changed: 0 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,6 @@
1414

1515
namespace ROS2
1616
{
17-
void ROS2SensorComponent::Init()
18-
{
19-
m_sensorConfiguration = DefaultConfiguration();
20-
}
21-
2217
void ROS2SensorComponent::Activate()
2318
{
2419
AZ::TickBus::Handler::BusConnect();
@@ -36,25 +31,10 @@ namespace ROS2
3631
{
3732
serialize->Class<ROS2SensorComponent, AZ::Component>()
3833
->Version(1)
39-
->Field("SensorConfiguration", &ROS2SensorComponent::m_sensorConfiguration)
4034
;
41-
42-
if (AZ::EditContext* ec = serialize->GetEditContext())
43-
{
44-
ec->Class<ROS2SensorComponent>("ROS2 Sensor", "[Base component for sensors]")
45-
->ClassElement(AZ::Edit::ClassElements::EditorData, "")
46-
->Attribute(AZ::Edit::Attributes::AppearsInAddComponentMenu, AZ_CRC("Game"))
47-
->DataElement(AZ::Edit::UIHandlers::Default, &ROS2SensorComponent::m_sensorConfiguration, "Sensor configuration", "Sensor configuration")
48-
;
49-
}
5035
}
5136
}
5237

53-
const SensorConfiguration& ROS2SensorComponent::GetConfiguration() const
54-
{
55-
return m_sensorConfiguration;
56-
}
57-
5838
AZStd::string ROS2SensorComponent::GetNamespace() const
5939
{
6040
// TODO - hold frame?
@@ -99,12 +79,4 @@ namespace ROS2
9979
// Note that sensor frequency can be limited by simulation tick rate (if higher sensor Hz is desired).
10080
FrequencyTick();
10181
}
102-
103-
SensorConfiguration ROS2SensorComponent::DefaultConfiguration() const
104-
{
105-
SensorConfiguration sc;
106-
PublisherConfiguration pc;
107-
sc.m_publishersConfigurations = { pc };
108-
return sc;
109-
}
11082
} // namespace ROS2

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

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ namespace ROS2
2525
AZ_COMPONENT(ROS2SensorComponent, "{91BCC1E9-6D93-4466-9CDB-E73D497C6B5E}", AZ::Component);
2626

2727
// AZ::Component interface implementation.
28-
void Init() override;
2928
void Activate() override;
3029
void Deactivate() override;
3130

@@ -37,13 +36,11 @@ namespace ROS2
3736
protected:
3837
AZStd::string GetNamespace() const;
3938
AZStd::string GetFrameID() const; // includes namespace
40-
const SensorConfiguration& GetConfiguration() const;
41-
42-
private:
43-
virtual SensorConfiguration DefaultConfiguration() const; // Override to provide default sensor config
44-
virtual void FrequencyTick() { }; // Override to implement sensor behavior
4539

4640
// TODO - Editor component: validation of fields, constraints between values and so on
4741
SensorConfiguration m_sensorConfiguration;
42+
43+
private:
44+
virtual void FrequencyTick() { }; // Override to implement sensor behavior
4845
};
4946
} // namespace ROS2

0 commit comments

Comments
 (0)