ManualMotorControllerComponent.cpp 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  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. #include <AzCore/Serialization/EditContext.h>
  9. #include <ROS2Controllers/Manipulation/MotorizedJoints/ManualMotorControllerComponent.h>
  10. #include <imgui/imgui.h>
  11. namespace ROS2Controllers
  12. {
  13. ManualMotorControllerComponent::ManualMotorControllerComponent()
  14. {
  15. m_jointMotorControllerConfiguration.m_isDebugController = true;
  16. }
  17. void ManualMotorControllerComponent::Reflect(AZ::ReflectContext* context)
  18. {
  19. if (auto* serializeContext = azrtti_cast<AZ::SerializeContext*>(context))
  20. {
  21. serializeContext->Class<ManualMotorControllerComponent, JointMotorControllerComponent>()->Version(2);
  22. if (AZ::EditContext* ec = serializeContext->GetEditContext())
  23. {
  24. ec->Class<ManualMotorControllerComponent>("Manual Motor Controller", "Debug motor controller used via ImGui.")
  25. ->ClassElement(AZ::Edit::ClassElements::EditorData, "")
  26. ->Attribute(AZ::Edit::Attributes::Category, "ROS2")
  27. ->Attribute(AZ::Edit::Attributes::AppearsInAddComponentMenu, AZ_CRC_CE("Game"))
  28. ->Attribute(AZ::Edit::Attributes::Icon, "Editor/Icons/Components/ManualMotorController.svg")
  29. ->Attribute(AZ::Edit::Attributes::ViewportIcon, "Editor/Icons/Components/Viewport/ManualMotorController.svg");
  30. }
  31. }
  32. }
  33. float ManualMotorControllerComponent::CalculateMotorSpeed([[maybe_unused]] float deltaTime)
  34. {
  35. return m_setSpeed;
  36. }
  37. void ManualMotorControllerComponent::DisplayControllerParameters()
  38. {
  39. ImGui::PushItemWidth(200.0f);
  40. ImGui::SliderFloat("SetSpeed", &m_setSpeed, -5.0f, 5.0f);
  41. ImGui::PopItemWidth();
  42. if (ImGui::Button("Zero"))
  43. {
  44. m_setSpeed = 0.0f;
  45. }
  46. }
  47. } // namespace ROS2Controllers