JointsPositionsComponent.h 2.1 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
  4. * of this distribution.
  5. *
  6. * SPDX-License-Identifier: Apache-2.0 OR MIT
  7. *
  8. */
  9. #pragma once
  10. #include <AzCore/Component/Component.h>
  11. #include <AzCore/Component/EntityBus.h>
  12. #include <AzCore/Component/TickBus.h>
  13. #include <AzCore/std/containers/vector.h>
  14. #include <AzCore/std/string/string.h>
  15. #include <ROS2/Communication/TopicConfiguration.h>
  16. #include <ROS2Controllers/Manipulation/JointsManipulationRequests.h>
  17. #include <ROS2Controllers/ROS2ControllersTypeIds.h>
  18. #include <ROS2Controllers/RobotControl/ControlSubscriptionHandler.h>
  19. #include <std_msgs/msg/float64_multi_array.hpp>
  20. namespace ROS2Controllers
  21. {
  22. //! This component implements finger gripper functionality.
  23. class JointsPositionsComponent
  24. : public AZ::Component
  25. , public AZ::TickBus::Handler
  26. {
  27. public:
  28. JointsPositionsComponent() = default;
  29. JointsPositionsComponent(const ROS2::TopicConfiguration& topicConfiguration, const AZStd::vector<AZStd::string>& jointNames);
  30. ~JointsPositionsComponent() = default;
  31. AZ_COMPONENT(JointsPositionsComponent, JointsPositionsComponentTypeId, AZ::Component);
  32. // AZ::Component overrides...
  33. void Activate() override;
  34. void Deactivate() override;
  35. static void GetRequiredServices(AZ::ComponentDescriptor::DependencyArrayType& required);
  36. static void Reflect(AZ::ReflectContext* context);
  37. private:
  38. // AZ::TickBus::Handler overrides...
  39. void OnTick(float delta, AZ::ScriptTimePoint timePoint) override;
  40. void ProcessPositionControlMessage(const std_msgs::msg::Float64MultiArray& message);
  41. AZStd::unique_ptr<IControlSubscriptionHandler> m_jointPositionsSubscriptionHandler;
  42. ROS2::TopicConfiguration m_topicConfiguration; //!< Configuration of the subscribed topic.
  43. AZStd::vector<AZStd::string> m_jointNames; //!< Ordered list of joint names that can be modified via subscriber
  44. AZ::EntityId m_rootOfArticulation; //!< The root of the articulation chain
  45. };
  46. } // namespace ROS2Controllers