ClassSegmentationConfigurationComponent.h 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  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/Component.h>
  10. #include <AzCore/Math/Color.h>
  11. #include <ROS2Sensors/Lidar/ClassSegmentationBus.h>
  12. #include <ROS2Sensors/Lidar/SegmentationClassConfiguration.h>
  13. #include <ROS2Sensors/ROS2SensorsTypeIds.h>
  14. namespace ROS2Sensors
  15. {
  16. class ClassSegmentationConfigurationComponent
  17. : public AZ::Component
  18. , ClassSegmentationRequestBus::Handler
  19. {
  20. public:
  21. AZ_COMPONENT(ClassSegmentationConfigurationComponent, ROS2Sensors::ClassSegmentationConfigurationComponentTypeId, AZ::Component);
  22. ClassSegmentationConfigurationComponent() = default;
  23. ~ClassSegmentationConfigurationComponent() override = default;
  24. static void Reflect(AZ::ReflectContext* context);
  25. static void GetProvidedServices(AZ::ComponentDescriptor::DependencyArrayType& provided);
  26. static void GetIncompatibleServices(AZ::ComponentDescriptor::DependencyArrayType& incompatible);
  27. // ClassSegmentationRequestBus overrides
  28. AZ::Color GetClassColor(uint8_t classId) const;
  29. AZStd::optional<uint8_t> GetClassIdForTag(LmbrCentral::Tag tag) const;
  30. const SegmentationClassConfigList& GetClassConfigList() const;
  31. // AZ::Component overrides
  32. void Activate() override;
  33. void Deactivate() override;
  34. private:
  35. AZ::Outcome<void, AZStd::string> ValidateSegmentationClasses(void* newValue, const AZ::TypeId& valueType) const;
  36. void ConstructSegmentationClassMaps();
  37. AZ::Crc32 OnSegmentationClassesChanged();
  38. SegmentationClassConfigList m_segmentationClasses;
  39. AZStd::unordered_map<LmbrCentral::Tag, uint8_t> m_tagToClassId;
  40. AZStd::unordered_map<uint8_t, AZ::Color> m_classIdToColor;
  41. };
  42. } // namespace ROS2Sensors