ROS2GNSSSensorComponent.h 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  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 <AzCore/Math/Transform.h>
  10. #include <AzCore/Serialization/SerializeContext.h>
  11. #include <ROS2/Sensor/Events/TickBasedSource.h>
  12. #include <ROS2/Sensor/ROS2SensorComponentBase.h>
  13. #include <ROS2Sensors/ROS2SensorsTypeIds.h>
  14. #include <rclcpp/publisher.hpp>
  15. #include <sensor_msgs/msg/nav_sat_fix.hpp>
  16. namespace ROS2Sensors
  17. {
  18. //! Global Navigation Satellite Systems (GNSS) sensor component class
  19. //! It provides NavSatFix data of sensor's position in GNSS frame which is defined by GNSS origin offset
  20. //! Offset is provided as latitude [deg], longitude [deg], altitude [m] of o3de global frame
  21. //! It is assumed that o3de global frame overlaps with ENU coordinate system
  22. class ROS2GNSSSensorComponent : public ROS2::ROS2SensorComponentBase<ROS2::TickBasedSource>
  23. {
  24. public:
  25. using SensorBaseType = ROS2::ROS2SensorComponentBase<ROS2::TickBasedSource>;
  26. AZ_COMPONENT(ROS2GNSSSensorComponent, ROS2GNSSSensorComponentTypeId, SensorBaseType);
  27. ROS2GNSSSensorComponent();
  28. ROS2GNSSSensorComponent(const ROS2::SensorConfiguration& sensorConfiguration);
  29. ~ROS2GNSSSensorComponent() = default;
  30. static void Reflect(AZ::ReflectContext* context);
  31. static void GetProvidedServices(AZ::ComponentDescriptor::DependencyArrayType& provided);
  32. //////////////////////////////////////////////////////////////////////////
  33. // Component overrides
  34. void Activate() override;
  35. void Deactivate() override;
  36. //////////////////////////////////////////////////////////////////////////
  37. private:
  38. ///! Requests gnss message publication.
  39. void FrequencyTick();
  40. //! Returns current entity position.
  41. //! @return Current entity position.
  42. [[nodiscard]] AZ::Transform GetCurrentPose() const;
  43. std::shared_ptr<rclcpp::Publisher<sensor_msgs::msg::NavSatFix>> m_gnssPublisher;
  44. sensor_msgs::msg::NavSatFix m_gnssMsg;
  45. };
  46. } // namespace ROS2Sensors