ROS2RobotControlComponent.h 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  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/std/smart_ptr/unique_ptr.h>
  11. #include <ROS2/Communication/TopicConfiguration.h>
  12. #include <ROS2Controllers/RobotControl/ControlConfiguration.h>
  13. #include <ROS2Controllers/RobotControl/ControlSubscriptionHandler.h>
  14. namespace ROS2Controllers
  15. {
  16. //! A Component responsible for controlling a robot movement.
  17. //! Uses IRobotControl implementation depending on type of ROS2 control message.
  18. //! Depends on ROS2FrameComponent. Can be configured through ControlConfiguration.
  19. class ROS2RobotControlComponent : public AZ::Component
  20. {
  21. public:
  22. AZ_COMPONENT(ROS2RobotControlComponent, "{CBFB0764-99F9-40EE-9FEE-F5F5A66E59D2}", AZ::Component);
  23. ROS2RobotControlComponent() = default;
  24. ROS2RobotControlComponent(ControlConfiguration controlConfiguration)
  25. : m_controlConfiguration(AZStd::move(controlConfiguration))
  26. {
  27. }
  28. const ControlConfiguration& GetControlConfiguration() const;
  29. void SetControlConfiguration(const ControlConfiguration& controlConfiguration);
  30. const ROS2::TopicConfiguration& GetSubscriberConfiguration() const;
  31. void SetSubscriberConfiguration(const ROS2::TopicConfiguration& subscriberConfiguration);
  32. //////////////////////////////////////////////////////////////////////////
  33. // Component overrides
  34. void Activate() override;
  35. void Deactivate() override;
  36. //////////////////////////////////////////////////////////////////////////
  37. static void GetRequiredServices(AZ::ComponentDescriptor::DependencyArrayType& required);
  38. static void GetProvidedServices(AZ::ComponentDescriptor::DependencyArrayType& provided);
  39. // Required Reflect function.
  40. static void Reflect(AZ::ReflectContext* context);
  41. private:
  42. AZStd::unique_ptr<IControlSubscriptionHandler> m_subscriptionHandler;
  43. ControlConfiguration m_controlConfiguration;
  44. ROS2::TopicConfiguration m_subscriberConfiguration;
  45. };
  46. } // namespace ROS2Controllers