Skip to content

Commit

Permalink
Merge branch 'development' of https://github.com/o3de/o3de-extras int…
Browse files Browse the repository at this point in the history
…o moudgils/gitflow_230418_o3de_extra

Signed-off-by: moudgils <[email protected]>
  • Loading branch information
moudgils committed Apr 20, 2023
2 parents 1cea3a4 + ae3cab3 commit 6cfe5d2
Show file tree
Hide file tree
Showing 25 changed files with 569 additions and 400 deletions.
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -126,3 +126,4 @@ Gems/AtomLyIntegration/CommonFeatures/Assets/Objects/Lucy/.wip/marmoset_bake.tbs
Gems/AtomLyIntegration/CommonFeatures/Assets/Objects/Lucy/.wip/Brass/brass_bake.spp filter=lfs diff=lfs merge=lfs -text
Gems/AtomLyIntegration/CommonFeatures/Assets/Objects/Lucy/.wip/stone/stone_bake.spp filter=lfs diff=lfs merge=lfs -text
Gems/WarehouseAssets/docs/images/*.png filter= diff= merge= -text
Gems/ROS2/docs/**/*.png -filter -diff -merge
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
/*
* Copyright (c) Contributors to the Open 3D Engine Project.
* For complete copyright and license terms please see the LICENSE at the root of this distribution.
*
* SPDX-License-Identifier: Apache-2.0 OR MIT
*
*/
#pragma once

#include <AzCore/Component/Component.h>
#include <AzCore/Component/EntityBus.h>
#include <AzCore/Component/TickBus.h>
#include <AzCore/Serialization/SerializeContext.h>
#include <ImGuiBus.h>
#include <ROS2/Manipulation/JointMotorControllerConfiguration.h>

namespace ROS2
{
class JointMotorControllerComponent
: public AZ::Component
, public AZ::TickBus::Handler
, public ImGui::ImGuiUpdateListenerBus::Handler
, public AZ::EntityBus::Handler
{
public:
JointMotorControllerComponent() = default;
JointMotorControllerComponent(const JointMotorControllerComponent& other) = default;
JointMotorControllerComponent(JointMotorControllerComponent&& other) = default;
~JointMotorControllerComponent() = default;
AZ_COMPONENT(JointMotorControllerComponent, "{88e725fc-29d8-45b9-b3e8-bd268ad9f413}");

// Component overrides
void Activate() override;
void Deactivate() override;

static void Reflect(AZ::ReflectContext* context);

// ImGui::ImGuiUpdateListenerBus overrides
void OnImGuiUpdate() override;

// EntityBus overrides
void OnEntityActivated(const AZ::EntityId& entityId) override;

protected:
AZ::EntityComponentIdPair m_jointComponentIdPair; //!< Joint component managed by the motorized joint.
float m_currentPosition{ 0.0f }; //!< Last measured position.
float m_currentSpeed{ 0.0f }; //!< Last measured speed.

JointMotorControllerConfiguration m_jointMotorControllerConfiguration;

private:
virtual float CalculateMotorSpeed([[maybe_unused]] float deltaTime)
{
return 0.0f;
};

virtual void DisplayControllerParameters(){};

// AZ::TickBus overrides
void OnTick(float deltaTime, AZ::ScriptTimePoint time) override;
};
} // namespace ROS2
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
/*
* Copyright (c) Contributors to the Open 3D Engine Project.
* For complete copyright and license terms please see the LICENSE at the root of this distribution.
*
* SPDX-License-Identifier: Apache-2.0 OR MIT
*
*/
#pragma once

#include <AzCore/RTTI/RTTI.h>
#include <AzCore/Serialization/SerializeContext.h>

namespace ROS2
{
struct JointMotorControllerConfiguration
{
AZ_TYPE_INFO(JointMotorControllerConfiguration, "{4358971c-36bd-4e13-8427-74ebba6c6760}");
static void Reflect(AZ::ReflectContext* context);

bool IsDebugModeVisible() const;

bool m_isDebugController{ false }; //!< Is it a debug controller.

bool m_debugMode{ false }; //!< Is debug mode activated.
};

} // namespace ROS2
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
/*
* Copyright (c) Contributors to the Open 3D Engine Project.
* For complete copyright and license terms please see the LICENSE at the root of this distribution.
*
* SPDX-License-Identifier: Apache-2.0 OR MIT
*
*/
#pragma once

#include <AzCore/Serialization/SerializeContext.h>
#include <ROS2/Manipulation/JointMotorControllerComponent.h>

namespace ROS2
{
class ManualMotorControllerComponent : public JointMotorControllerComponent
{
public:
AZ_COMPONENT(ManualMotorControllerComponent, "{0817634e-4862-4245-a66e-72d1a6939705}", JointMotorControllerComponent);

ManualMotorControllerComponent();
~ManualMotorControllerComponent() = default;
static void Reflect(AZ::ReflectContext* context);

private:
float m_setSpeed{ 0.0f };

float CalculateMotorSpeed([[maybe_unused]] float deltaTime) override;
void DisplayControllerParameters() override;
};
} // namespace ROS2
93 changes: 0 additions & 93 deletions Gems/ROS2/Code/Include/ROS2/Manipulation/MotorizedJointComponent.h

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,15 @@

namespace ROS2
{
//! Interface to communicate with motorized joints.
//! It allows to apply setpoint and tracking performance of the PID controller.
class MotorizedJointRequest : public AZ::EBusTraits
//! Interface to communicate with a PID motor controller.
//! It allows to apply a setpoint and track performance of the controller.
class PidMotorControllerRequests : public AZ::EBusTraits
{
public:
static constexpr AZ::EBusAddressPolicy AddressPolicy = AZ::EBusAddressPolicy::ById;
using BusIdType = AZ::EntityId;

virtual ~MotorizedJointRequest() = default;
virtual ~PidMotorControllerRequests() = default;

//! Set current setpoint value for position controller.
//! The setpoint is the desired position for a simulated actuator.
Expand Down Expand Up @@ -53,5 +53,5 @@ namespace ROS2
virtual float GetError() = 0;
};

using MotorizedJointRequestBus = AZ::EBus<MotorizedJointRequest>;
} // namespace ROS2
using PidMotorControllerRequestBus = AZ::EBus<PidMotorControllerRequests>;
} // namespace ROS2
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
/*
* Copyright (c) Contributors to the Open 3D Engine Project.
* For complete copyright and license terms please see the LICENSE at the root of this distribution.
*
* SPDX-License-Identifier: Apache-2.0 OR MIT
*
*/
#pragma once

#include <AzCore/Serialization/SerializeContext.h>
#include <AzFramework/Entity/EntityDebugDisplayBus.h>
#include <ROS2/Manipulation/JointMotorControllerComponent.h>
#include <ROS2/Manipulation/PidMotorControllerBus.h>
#include <ROS2/Utilities/Controllers/PidConfiguration.h>

namespace ROS2
{
class PidMotorControllerComponent
: public JointMotorControllerComponent
, public PidMotorControllerRequestBus::Handler
{
public:
AZ_COMPONENT(PidMotorControllerComponent, "{ac1d057f-a6ad-4a26-b44f-0ebda2f5f526}", JointMotorControllerComponent);

PidMotorControllerComponent() = default;
~PidMotorControllerComponent() = default;
static void Reflect(AZ::ReflectContext* context);

// Component overrides
void Activate() override;
void Deactivate() override;

// PidMotorControllerBus overrides
void SetSetpoint(float setpoint) override;
float GetSetpoint() override;
float GetCurrentMeasurement() override;
float GetError() override;

private:
Controllers::PidConfiguration m_pidPos; //!< PID controller for position.
float m_zeroOffset{ 0.0f }; //!< Offset added to setpoint.
float m_setPoint{ 0.0f }; //!< Desired local position.
float m_error{ 0.0f }; //!< Current error (difference between control value and measurement).

// JointMotorControllerComponent overrides
float CalculateMotorSpeed([[maybe_unused]] float deltaTime) override;
void DisplayControllerParameters() override;
};
} // namespace ROS2
Loading

0 comments on commit 6cfe5d2

Please sign in to comment.