ROS2Lidar2DSensorComponent.h 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  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/laser_scan.hpp>
  17. #include "LidarCore.h"
  18. #include "LidarRaycaster.h"
  19. namespace ROS2
  20. {
  21. //! Lidar 2D sensor Component.
  22. //! Lidars (Light Detection and Ranging) emit laser light and measure it after reflection.
  23. //! Lidar Component allows customization of lidar type and behavior and encapsulates both simulation
  24. //! and data publishing. It requires ROS2FrameComponent.
  25. class ROS2Lidar2DSensorComponent : public ROS2SensorComponentBase<TickBasedSource>
  26. {
  27. public:
  28. AZ_COMPONENT(ROS2Lidar2DSensorComponent, ROS2Lidar2DSensorComponentTypeId, SensorBaseType);
  29. ROS2Lidar2DSensorComponent();
  30. ROS2Lidar2DSensorComponent(const SensorConfiguration& sensorConfiguration, const LidarSensorConfiguration& lidarConfiguration);
  31. ~ROS2Lidar2DSensorComponent() = default;
  32. static void GetRequiredServices(AZ::ComponentDescriptor::DependencyArrayType& required);
  33. static void Reflect(AZ::ReflectContext* context);
  34. //////////////////////////////////////////////////////////////////////////
  35. // Component overrides
  36. void Activate() override;
  37. void Deactivate() override;
  38. //////////////////////////////////////////////////////////////////////////
  39. private:
  40. //////////////////////////////////////////////////////////////////////////
  41. void FrequencyTick();
  42. void PublishRaycastResults(const RaycastResults& results);
  43. std::shared_ptr<rclcpp::Publisher<sensor_msgs::msg::LaserScan>> m_laserScanPublisher;
  44. LidarCore m_lidarCore;
  45. };
  46. } // namespace ROS2