ROS2CameraSensorEditorComponent.h 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  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 <ROS2/Frame/NamespaceConfiguration.h>
  14. #include <ROS2/Frame/ROS2Transform.h>
  15. #include <ROS2/Sensor/SensorConfiguration.h>
  16. #include <ROS2Sensors/Camera/CameraConfigurationRequestBus.h>
  17. #include <ROS2Sensors/Camera/CameraSensorConfiguration.h>
  18. #include <ROS2Sensors/ROS2SensorsTypeIds.h>
  19. namespace ROS2Sensors
  20. {
  21. //! ROS2 Camera Editor sensor component class
  22. //! Allows turning an entity into a camera sensor in Editor
  23. //! Component draws camera frustum in the Editor
  24. class ROS2CameraSensorEditorComponent
  25. : public AzToolsFramework::Components::EditorComponentBase
  26. , public CameraConfigurationRequestBus::Handler
  27. , protected AzFramework::EntityDebugDisplayEventBus::Handler
  28. {
  29. public:
  30. ROS2CameraSensorEditorComponent();
  31. ROS2CameraSensorEditorComponent(
  32. const ROS2::SensorConfiguration& sensorConfiguration, const CameraSensorConfiguration& cameraConfiguration);
  33. ~ROS2CameraSensorEditorComponent() override = default;
  34. AZ_EDITOR_COMPONENT(ROS2CameraSensorEditorComponent, ROS2CameraSensorEditorComponentTypeId);
  35. static void Reflect(AZ::ReflectContext* context);
  36. static void GetRequiredServices(AZ::ComponentDescriptor::DependencyArrayType& required);
  37. static void GetIncompatibleServices(AZ::ComponentDescriptor::DependencyArrayType& incompatible);
  38. static void GetProvidedServices(AZ::ComponentDescriptor::DependencyArrayType& provided);
  39. void Activate() override;
  40. void Deactivate() override;
  41. // AzToolsFramework::Components::EditorComponentBase overrides
  42. void BuildGameEntity(AZ::Entity* gameEntity) override;
  43. private:
  44. // CameraConfigurationRequestBus::Handler overrides ..
  45. void SetConfiguration(const CameraSensorConfiguration& configuration) override;
  46. const CameraSensorConfiguration GetConfiguration() override;
  47. AZ::Matrix3x3 GetCameraMatrix() override;
  48. float GetVerticalFOV() override;
  49. void SetVerticalFOV(float value) override;
  50. int GetWidth() override;
  51. void SetWidth(int value) override;
  52. int GetHeight() override;
  53. void SetHeight(int value) override;
  54. bool IsColorCamera() override;
  55. void SetColorCamera(bool value) override;
  56. bool IsDepthCamera() override;
  57. void SetDepthCamera(bool value) override;
  58. float GetNearClipDistance() override;
  59. void SetNearClipDistance(float value) override;
  60. float GetFarClipDistance() override;
  61. void SetFarClipDistance(float value) override;
  62. // EntityDebugDisplayEventBus::Handler overrides
  63. void DisplayEntityViewport(const AzFramework::ViewportInfo& viewportInfo, AzFramework::DebugDisplayRequests& debugDisplay) override;
  64. AZStd::pair<AZStd::string, ROS2::TopicConfiguration> MakeTopicConfigurationPair(
  65. const AZStd::string& topic, const AZStd::string& messageType, const AZStd::string& configName) const;
  66. ROS2::SensorConfiguration m_sensorConfiguration;
  67. CameraSensorConfiguration m_cameraConfiguration;
  68. };
  69. } // namespace ROS2Sensors