GripperActionServerComponent.h 2.3 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
  4. * of this distribution.
  5. *
  6. * SPDX-License-Identifier: Apache-2.0 OR MIT
  7. *
  8. */
  9. #pragma once
  10. #include "GripperActionServer.h"
  11. #include <AzCore/Component/Component.h>
  12. #include <AzCore/Component/TickBus.h>
  13. #include <ROS2Controllers/Gripper/GripperRequestBus.h>
  14. #include <ROS2Controllers/ROS2ControllersTypeIds.h>
  15. #include <control_msgs/action/gripper_command.hpp>
  16. #include <rclcpp/rclcpp.hpp>
  17. namespace ROS2
  18. {
  19. //! GripperActionServerComponent is a component that encapsulates gripper action server.
  20. //! It is responsible for creating and managing the action server, producing feedback and result.
  21. class GripperActionServerComponent
  22. : public AZ::Component
  23. , private AZ::TickBus::Handler
  24. {
  25. public:
  26. using GripperCommand = control_msgs::action::GripperCommand;
  27. using GoalHandleGripperCommand = rclcpp_action::ServerGoalHandle<control_msgs::action::GripperCommand>;
  28. AZ_COMPONENT(GripperActionServerComponent, ROS2Controllers::GripperActionServerComponentTypeId, AZ::Component);
  29. GripperActionServerComponent() = default;
  30. ~GripperActionServerComponent() = default;
  31. static void GetRequiredServices(AZ::ComponentDescriptor::DependencyArrayType& required);
  32. static void GetProvidedServices(AZ::ComponentDescriptor::DependencyArrayType& provided);
  33. static void GetIncompatibleServices(AZ::ComponentDescriptor::DependencyArrayType& incompatible);
  34. static void Reflect(AZ::ReflectContext* context);
  35. private:
  36. // AZ::Component overrides...
  37. void Activate() override;
  38. void Deactivate() override;
  39. // AZ::TickBus::Handler overrides
  40. void OnTick(float deltaTime, AZ::ScriptTimePoint time) override;
  41. std::shared_ptr<GripperActionServer::GripperCommand::Feedback> ProduceFeedback() const;
  42. std::shared_ptr<GripperActionServer::GripperCommand::Result> ProduceResult() const;
  43. AZStd::string m_gripperActionServerName{ "gripper_server" }; //! name of the GripperCommand action server
  44. AZStd::unique_ptr<GripperActionServer> m_gripperActionServer; //! action server for GripperCommand
  45. };
  46. } // namespace ROS2