forked from o3de/o3de-extras
-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathRigidBodyTwistControlComponent.h
More file actions
60 lines (52 loc) · 2.76 KB
/
Copy pathRigidBodyTwistControlComponent.h
File metadata and controls
60 lines (52 loc) · 2.76 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
/*
* 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/TickBus.h>
#include <AzFramework/Physics/PhysicsSystem.h>
#include <ROS2/RobotControl/Twist/TwistBus.h>
namespace ROS2
{
//! A component with a simple handler for Twist type of control (linear and angular velocities).
//! Velocities are directly applied to a selected body.
class RigidBodyTwistControlComponent
: public AZ::Component
, private TwistNotificationBus::Handler
, private AZ::TickBus::Handler
{
public:
AZ_COMPONENT(RigidBodyTwistControlComponent, "{D994FE1A-AA6A-42B9-8B8E-B3B375891F5B}", AZ::Component);
RigidBodyTwistControlComponent() = default;
//////////////////////////////////////////////////////////////////////////
// Component overrides
void Activate() override;
void Deactivate() override;
//////////////////////////////////////////////////////////////////////////
static void GetRequiredServices(AZ::ComponentDescriptor::DependencyArrayType& required);
static void Reflect(AZ::ReflectContext* context);
private:
//////////////////////////////////////////////////////////////////////////
// TwistNotificationBus::Handler overrides
void TwistReceived(const AZ::Vector3& linear, const AZ::Vector3& angular) override;
//////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////
// AZ::TickBus::Handler overrides
void OnTick(float deltaTime, AZ::ScriptTimePoint time) override;
//////////////////////////////////////////////////////////////////////////
AZ::Vector3 m_linearVelocityLocal{ AZ::Vector3::CreateZero() }; //!< Linear velocity in local frame
AZ::Vector3 m_angularVelocityLocal{ AZ::Vector3::CreateZero() }; //!< Angular velocity in local frame
AzPhysics::SceneEvents::OnSceneSimulationFinishHandler m_sceneFinishSimHandler; //!< Handler called after every physics sub-step
AzPhysics::SimulatedBodyHandle m_bodyHandle = AzPhysics::InvalidSimulatedBodyHandle; //!< Handle to the body to apply velocities to
bool m_disableLinearVelocityXOverriding = false;
bool m_disableLinearVelocityYOverriding = false;
bool m_disableLinearVelocityZOverriding = false;
bool m_disableAngularVelocityXOverriding = false;
bool m_disableAngularVelocityYOverriding = false;
bool m_disableAngularVelocityZOverriding = false;
};
} // namespace ROS2