GNSSPostProcessingRequestBus.h 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  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/Component/EntityId.h>
  10. #include <AzCore/EBus/EBusSharedDispatchTraits.h>
  11. #include <AzCore/Interface/Interface.h>
  12. #include <AzCore/std/string/string.h>
  13. #include <sensor_msgs/msg/nav_sat_fix.hpp>
  14. namespace ROS2
  15. {
  16. //! Interface class that allows to add post-processing to the pipeline
  17. //!
  18. //! Each function call can be processed without blocking Bus for other dispatches.
  19. //! Do not use connects / disconnects to this bus during event dispatch, as they are not allowed for this concurrency model.
  20. //! Those constraints allow for processing multiple GNSS frames at the same time.
  21. //! Bus implementations should allow for asynchronous execution of provided functions.
  22. class GNSSPostProcessingRequests : public AZ::EBusSharedDispatchTraits<GNSSPostProcessingRequests>
  23. {
  24. public:
  25. using BusIdType = AZ::EntityId;
  26. static constexpr AZ::EBusAddressPolicy AddressPolicy = AZ::EBusAddressPolicy::ById;
  27. //! Multiple post-processing functions can be registered to the bus.
  28. //! They will be executed in the order
  29. static constexpr AZ::EBusHandlerPolicy HandlerPolicy = AZ::EBusHandlerPolicy::MultipleAndOrdered;
  30. //! Priority of the post-processing bus.
  31. //! @note higher priority buses will be processed first.
  32. static constexpr AZ::u8 MIN_PRIORITY = 0;
  33. static constexpr AZ::u8 MAX_PRIORITY = 255;
  34. static constexpr AZ::u8 DEFAULT_PRIORITY = 127;
  35. //! Apply post-processing function to GNSS data.
  36. //! @param gnss standard GNSS message passed as a reference. It will be changed through post-processing.
  37. virtual void ApplyPostProcessing(sensor_msgs::msg::NavSatFix& gnss) = 0;
  38. //! Get priority of the post-processing bus.
  39. //! @return priority of the bus.
  40. //! @note higher priority buses will be processed first.
  41. virtual AZ::u8 GetPriority() const = 0;
  42. //! Compare two post-processing buses.
  43. //! @param other bus to compare to.
  44. //! @return true if this bus should be processed before the other.
  45. inline bool Compare(const GNSSPostProcessingRequests* other) const
  46. {
  47. return GetPriority() > other->GetPriority();
  48. }
  49. protected:
  50. ~GNSSPostProcessingRequests() = default;
  51. };
  52. using GNSSPostProcessingRequestBus = AZ::EBus<GNSSPostProcessingRequests>;
  53. } // namespace ROS2