WheelControllerComponent.h 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  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/Component/EntityId.h>
  11. #include <AzCore/Math/Vector3.h>
  12. #include <AzFramework/Physics/SimulatedBodies/RigidBody.h>
  13. namespace ROS2Controllers::VehicleDynamics
  14. {
  15. //! A component responsible for control (steering, forward motion) of a single wheel
  16. class WheelControllerComponent : public AZ::Component
  17. {
  18. public:
  19. AZ_COMPONENT(WheelControllerComponent, "{AC594E08-DA5C-4B8D-9388-84D0840C177A}", AZ::Component);
  20. WheelControllerComponent() = default;
  21. WheelControllerComponent(const AZ::EntityId& steeringEntity, const float steeringScale);
  22. ~WheelControllerComponent() = default;
  23. //////////////////////////////////////////////////////////////////////////
  24. // Component overrides
  25. void Activate() override;
  26. void Deactivate() override;
  27. //////////////////////////////////////////////////////////////////////////
  28. static void GetRequiredServices(AZ::ComponentDescriptor::DependencyArrayType& required);
  29. static void GetProvidedServices(AZ::ComponentDescriptor::DependencyArrayType& provided);
  30. static void GetIncompatibleServices(AZ::ComponentDescriptor::DependencyArrayType& incompatible);
  31. static void Reflect(AZ::ReflectContext* context);
  32. AZ::Vector3 GetRotationVelocity();
  33. AZ::EntityId m_steeringEntity; //!< Rigid body to apply velocity to.
  34. float m_steeringScale{ 1.0f }; //!< The direction of torque applied to steering entity when steering is applied
  35. private:
  36. AzPhysics::RigidBody* m_rigidBodyPtr{ nullptr };
  37. };
  38. } // namespace ROS2Controllers::VehicleDynamics