ROS2CameraSensorEditorComponent.h 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  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 <AzFramework/Entity/EntityDebugDisplayBus.h>
  11. #include <AzToolsFramework/API/ComponentEntitySelectionBus.h>
  12. #include <AzToolsFramework/ToolsComponents/EditorComponentBase.h>
  13. #include "CameraSensorConfiguration.h"
  14. #include <ROS2/Frame/NamespaceConfiguration.h>
  15. #include <ROS2/Frame/ROS2Transform.h>
  16. #include <ROS2Sensors/Camera/CameraCalibrationRequestBus.h>
  17. #include <ROS2Sensors/Sensor/SensorConfiguration.h>
  18. namespace ROS2
  19. {
  20. //! ROS2 Camera Editor sensor component class
  21. //! Allows turning an entity into a camera sensor in Editor
  22. //! Component draws camera frustum in the Editor
  23. class ROS2CameraSensorEditorComponent
  24. : public AzToolsFramework::Components::EditorComponentBase
  25. , public CameraCalibrationRequestBus::Handler
  26. , protected AzFramework::EntityDebugDisplayEventBus::Handler
  27. {
  28. public:
  29. ROS2CameraSensorEditorComponent();
  30. ROS2CameraSensorEditorComponent(
  31. const SensorConfiguration& sensorConfiguration, const CameraSensorConfiguration& cameraConfiguration);
  32. ~ROS2CameraSensorEditorComponent() override = default;
  33. AZ_EDITOR_COMPONENT(ROS2CameraSensorEditorComponent, "{3C2A86B2-AD58-4BF1-A5EF-71E0F94A2B42}");
  34. static void Reflect(AZ::ReflectContext* context);
  35. static void GetRequiredServices(AZ::ComponentDescriptor::DependencyArrayType& required);
  36. static void GetIncompatibleServices(AZ::ComponentDescriptor::DependencyArrayType& incompatible);
  37. static void GetProvidedServices(AZ::ComponentDescriptor::DependencyArrayType& provided);
  38. void Activate() override;
  39. void Deactivate() override;
  40. // AzToolsFramework::Components::EditorComponentBase overrides
  41. void BuildGameEntity(AZ::Entity* gameEntity) override;
  42. // CameraCalibrationRequestBus::Handler overrides
  43. AZ::Matrix3x3 GetCameraMatrix() const override;
  44. int GetWidth() const override;
  45. int GetHeight() const override;
  46. float GetVerticalFOV() const override;
  47. private:
  48. // EntityDebugDisplayEventBus::Handler overrides
  49. void DisplayEntityViewport(const AzFramework::ViewportInfo& viewportInfo, AzFramework::DebugDisplayRequests& debugDisplay) override;
  50. AZStd::pair<AZStd::string, TopicConfiguration> MakeTopicConfigurationPair(
  51. const AZStd::string& topic, const AZStd::string& messageType, const AZStd::string& configName) const;
  52. SensorConfiguration m_sensorConfiguration;
  53. CameraSensorConfiguration m_cameraSensorConfiguration;
  54. };
  55. } // namespace ROS2