ROS2LidarSensorComponent.h 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. /*
  2. * Copyright (c) Contributors to the Open 3D Engine Project.
  3. * For complete copyright and license terms please see the LICENSE at the root of this distribution.
  4. *
  5. * SPDX-License-Identifier: Apache-2.0 OR MIT
  6. *
  7. */
  8. #pragma once
  9. #include <Atom/RPI.Public/AuxGeom/AuxGeomDraw.h>
  10. #include <AzCore/Serialization/SerializeContext.h>
  11. #include <ROS2/Lidar/LidarRegistrarBus.h>
  12. #include <ROS2/Lidar/LidarSystemBus.h>
  13. #include <ROS2/Sensor/Events/TickBasedSource.h>
  14. #include <ROS2/Sensor/ROS2SensorComponentBase.h>
  15. #include <rclcpp/publisher.hpp>
  16. #include <sensor_msgs/msg/point_cloud2.hpp>
  17. #include <vision_msgs/msg/label_info.hpp>
  18. #include "LidarCore.h"
  19. #include "LidarRaycaster.h"
  20. #include "LidarSensorConfiguration.h"
  21. namespace ROS2
  22. {
  23. //! Lidar sensor Component.
  24. //! Lidars (Light Detection and Ranging) emit laser light and measure it after reflection.
  25. //! Lidar Component allows customization of lidar type and behavior and encapsulates both simulation
  26. //! and data publishing. It requires ROS2FrameComponent.
  27. class ROS2LidarSensorComponent : public ROS2SensorComponentBase<TickBasedSource>
  28. {
  29. public:
  30. AZ_COMPONENT(ROS2LidarSensorComponent, ROS2LidarSensorComponentTypeId, SensorBaseType);
  31. ROS2LidarSensorComponent();
  32. ROS2LidarSensorComponent(const SensorConfiguration& sensorConfiguration, const LidarSensorConfiguration& lidarConfiguration);
  33. ~ROS2LidarSensorComponent() = default;
  34. static void Reflect(AZ::ReflectContext* context);
  35. static void GetRequiredServices(AZ::ComponentDescriptor::DependencyArrayType& required);
  36. //////////////////////////////////////////////////////////////////////////
  37. // Component overrides
  38. void Activate() override;
  39. void Deactivate() override;
  40. //////////////////////////////////////////////////////////////////////////
  41. private:
  42. //////////////////////////////////////////////////////////////////////////
  43. void FrequencyTick();
  44. void PublishRaycastResults(const RaycastResults& results);
  45. bool m_canRaycasterPublish = false;
  46. std::shared_ptr<rclcpp::Publisher<sensor_msgs::msg::PointCloud2>> m_pointCloudPublisher;
  47. std::shared_ptr<rclcpp::Publisher<vision_msgs::msg::LabelInfo>> m_segmentationClassesPublisher;
  48. LidarCore m_lidarCore;
  49. LidarId m_lidarRaycasterId;
  50. };
  51. } // namespace ROS2