2
0

ROS2CameraSensorEditorComponent.h 3.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  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/ROS2Transform.h>
  14. #include <ROS2/Sensor/SensorConfiguration.h>
  15. #include <ROS2Sensors/Camera/CameraConfigurationRequestBus.h>
  16. #include <ROS2Sensors/Camera/CameraSensorConfiguration.h>
  17. #include <ROS2Sensors/ROS2SensorsTypeIds.h>
  18. namespace ROS2Sensors
  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 CameraConfigurationRequestBus::Handler
  26. , protected AzFramework::EntityDebugDisplayEventBus::Handler
  27. {
  28. public:
  29. ROS2CameraSensorEditorComponent();
  30. ROS2CameraSensorEditorComponent(
  31. const ROS2::SensorConfiguration& sensorConfiguration, const CameraSensorConfiguration& cameraConfiguration);
  32. ~ROS2CameraSensorEditorComponent() override = default;
  33. AZ_EDITOR_COMPONENT(ROS2CameraSensorEditorComponent, ROS2CameraSensorEditorComponentTypeId);
  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. private:
  43. // CameraConfigurationRequestBus::Handler overrides ..
  44. void SetConfiguration(const CameraSensorConfiguration& configuration) override;
  45. const CameraSensorConfiguration GetConfiguration() override;
  46. AZ::Matrix3x3 GetCameraMatrix() override;
  47. float GetVerticalFOV() override;
  48. void SetVerticalFOV(float value) override;
  49. int GetWidth() override;
  50. void SetWidth(int value) override;
  51. int GetHeight() override;
  52. void SetHeight(int value) override;
  53. bool IsColorCamera() override;
  54. void SetColorCamera(bool value) override;
  55. bool IsDepthCamera() override;
  56. void SetDepthCamera(bool value) override;
  57. float GetNearClipDistance() override;
  58. void SetNearClipDistance(float value) override;
  59. float GetFarClipDistance() override;
  60. void SetFarClipDistance(float value) override;
  61. // EntityDebugDisplayEventBus::Handler overrides
  62. void DisplayEntityViewport(const AzFramework::ViewportInfo& viewportInfo, AzFramework::DebugDisplayRequests& debugDisplay) override;
  63. AZStd::pair<AZStd::string, ROS2::TopicConfiguration> MakeTopicConfigurationPair(
  64. const AZStd::string& topic, const AZStd::string& messageType, const AZStd::string& configName) const;
  65. ROS2::SensorConfiguration m_sensorConfiguration;
  66. CameraSensorConfiguration m_cameraConfiguration;
  67. };
  68. } // namespace ROS2Sensors