Skip to content

Commit

Permalink
Adjusted to review
Browse files Browse the repository at this point in the history
Signed-off-by: Antoni Puch <antoni.puch@robotec.ai>
  • Loading branch information
Antoni-Robotec committed Aug 31, 2023
1 parent b828e44 commit a754bae
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 12 deletions.
2 changes: 0 additions & 2 deletions Gems/ROS2/Code/Source/Lidar/LidarCore.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@ namespace ROS2

void LidarCore::ConfigureLidarRaycaster()
{
m_lidarConfiguration.FetchLidarImplementationFeatures();
LidarRaycasterRequestBus::Event(m_lidarRaycasterId, &LidarRaycasterRequestBus::Events::ConfigureRayOrientations, m_lastRotations);
LidarRaycasterRequestBus::Event(
m_lidarRaycasterId,
Expand Down Expand Up @@ -142,7 +141,6 @@ namespace ROS2

m_lastRotations = LidarTemplateUtils::PopulateRayRotations(m_lidarConfiguration.m_lidarParameters);

m_lidarConfiguration.FetchLidarImplementationFeatures();
ConnectToLidarRaycaster();
ConfigureLidarRaycaster();
}
Expand Down
10 changes: 7 additions & 3 deletions Gems/ROS2/Code/Source/Lidar/LidarSensorConfiguration.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,6 @@ namespace ROS2

LidarSensorConfiguration(AZStd::vector<LidarTemplate::LidarModel> availableModels = {});

void FetchLidarImplementationFeatures();

LidarSystemFeatures m_lidarSystemFeatures;

AZStd::string m_lidarSystem;
Expand All @@ -46,11 +44,17 @@ namespace ROS2
bool IsEntityExclusionVisible() const;
bool IsMaxPointsConfigurationVisible() const;

AZStd::vector<AZStd::string> GetAvailableModels() const;
//! Update the lidar configuration based on the current lidar model selected.
void FetchLidarModelConfiguration();
//! Update the lidar system features based on the current lidar system selected.
void FetchLidarImplementationFeatures();

AZ::Crc32 OnLidarModelSelected();
AZ::Crc32 OnLidarImplementationSelected();

//! Get all models this configuration can be set to (for example all 2D lidar models).
AZStd::vector<AZStd::string> GetAvailableModels() const;
//! Get all available lidar systems.
AZStd::vector<AZStd::string> FetchLidarSystemList();

const AZStd::vector<LidarTemplate::LidarModel> m_availableModels;
Expand Down
6 changes: 3 additions & 3 deletions Gems/ROS2/Code/Source/Lidar/ROS2Lidar2DSensorComponent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ namespace ROS2
{
namespace
{
const char* kLaserScanType = "sensor_msgs::msg::LaserScan";
const char* LaserScanType = "sensor_msgs::msg::LaserScan";
}

void ROS2Lidar2DSensorComponent::Reflect(AZ::ReflectContext* context)
Expand Down Expand Up @@ -49,7 +49,7 @@ namespace ROS2
: m_lidarCore(LidarTemplateUtils::Get2DModels())
{
TopicConfiguration ls;
AZStd::string type = kLaserScanType;
AZStd::string type = LaserScanType;
ls.m_type = type;
ls.m_topic = "ls";
m_sensorConfiguration.m_frequency = 10.f;
Expand All @@ -74,7 +74,7 @@ namespace ROS2
auto ros2Node = ROS2Interface::Get()->GetNode();
AZ_Assert(m_sensorConfiguration.m_publishersConfigurations.size() == 1, "Invalid configuration of publishers for lidar sensor");

const TopicConfiguration& publisherConfig = m_sensorConfiguration.m_publishersConfigurations[kLaserScanType];
const TopicConfiguration& publisherConfig = m_sensorConfiguration.m_publishersConfigurations[LaserScanType];
AZStd::string fullTopic = ROS2Names::GetNamespacedName(GetNamespace(), publisherConfig.m_topic);
m_laserScanPublisher = ros2Node->create_publisher<sensor_msgs::msg::LaserScan>(fullTopic.data(), publisherConfig.GetQoS());

Expand Down
8 changes: 4 additions & 4 deletions Gems/ROS2/Code/Source/Lidar/ROS2LidarSensorComponent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ namespace ROS2
{
namespace
{
const char* kPointCloudType = "sensor_msgs::msg::PointCloud2";
const char* PointCloudType = "sensor_msgs::msg::PointCloud2";
}

void ROS2LidarSensorComponent::Reflect(AZ::ReflectContext* context)
Expand Down Expand Up @@ -49,7 +49,7 @@ namespace ROS2
: m_lidarCore(LidarTemplateUtils::Get3DModels())
{
TopicConfiguration pc;
AZStd::string type = kPointCloudType;
AZStd::string type = PointCloudType;
pc.m_type = type;
pc.m_topic = "pc";
m_sensorConfiguration.m_frequency = 10.f;
Expand Down Expand Up @@ -82,7 +82,7 @@ namespace ROS2

if (m_canRaycasterPublish)
{
const TopicConfiguration& publisherConfig = m_sensorConfiguration.m_publishersConfigurations[kPointCloudType];
const TopicConfiguration& publisherConfig = m_sensorConfiguration.m_publishersConfigurations[PointCloudType];
auto* ros2Frame = Utils::GetGameOrEditorComponent<ROS2FrameComponent>(GetEntity());

LidarRaycasterRequestBus::Event(
Expand All @@ -97,7 +97,7 @@ namespace ROS2
auto ros2Node = ROS2Interface::Get()->GetNode();
AZ_Assert(m_sensorConfiguration.m_publishersConfigurations.size() == 1, "Invalid configuration of publishers for lidar sensor");

const TopicConfiguration& publisherConfig = m_sensorConfiguration.m_publishersConfigurations[kPointCloudType];
const TopicConfiguration& publisherConfig = m_sensorConfiguration.m_publishersConfigurations[PointCloudType];
AZStd::string fullTopic = ROS2Names::GetNamespacedName(GetNamespace(), publisherConfig.m_topic);
m_pointCloudPublisher = ros2Node->create_publisher<sensor_msgs::msg::PointCloud2>(fullTopic.data(), publisherConfig.GetQoS());
}
Expand Down

0 comments on commit a754bae

Please sign in to comment.