JointsPIDControllerComponent.h 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  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 <ROS2/Manipulation/Controllers/JointsPositionControllerRequests.h>
  11. #include <ROS2/Utilities/Controllers/PidConfiguration.h>
  12. namespace ROS2
  13. {
  14. //! Handles position control commands for joints.
  15. class JointsPIDControllerComponent
  16. : public AZ::Component
  17. , public JointsPositionControllerRequestBus::Handler
  18. {
  19. public:
  20. JointsPIDControllerComponent() = default;
  21. ~JointsPIDControllerComponent() = default;
  22. AZ_COMPONENT(JointsPIDControllerComponent, "{41A31EDB-90B0-412E-BBFA-D35D45546A8E}", AZ::Component);
  23. static void GetProvidedServices(AZ::ComponentDescriptor::DependencyArrayType& provided);
  24. static void GetIncompatibleServices(AZ::ComponentDescriptor::DependencyArrayType& incompatible);
  25. static void Reflect(AZ::ReflectContext* context);
  26. // JointsPositionControllerRequestBus::Handler overrides ...
  27. //! @see ROS2::JointsPositionControllerRequestBus::SupportsArticulation
  28. bool SupportsArticulation() override
  29. {
  30. return false;
  31. }
  32. //! @see ROS2::JointsPositionControllerRequestBus::SupportsClassicJoints
  33. bool SupportsClassicJoints() override
  34. {
  35. return true;
  36. }
  37. //! @see ROS2::JointsPositionControllerRequestBus::PositionControl
  38. AZ::Outcome<void, AZStd::string> PositionControl(
  39. const AZStd::string& jointName,
  40. JointInfo joint,
  41. JointPosition currentPosition,
  42. JointPosition targetPosition,
  43. float deltaTime) override;
  44. private:
  45. // Component overrides ...
  46. void Activate() override;
  47. void Deactivate() override;
  48. void InitializePIDs();
  49. AZStd::unordered_map<AZStd::string, Controllers::PidConfiguration> m_pidConfiguration;
  50. };
  51. } // namespace ROS2