VR-Engage  2.3
Loading...
Searching...
No Matches
rotaryWingJoyFlightController.h
Go to the documentation of this file.
1/*******************************************************************************
2** Copyright (c) 2025 MAK Technologies
3** All rights reserved.
4*******************************************************************************/
5
6//! \file rotaryWingJoyFlightController.h
7//! \ingroup vreVrfmodel
8//! \brief Controller for joystick-based rotary-wing aircraft flight control
9//!
10//! This file defines the DtRotaryWingJoyFlightController class which provides
11//! joystick control functionality for rotary-wing aircraft. It extends the base
12//! rotary wing pilot controller to map joystick inputs to helicopter flight controls.
13
14#pragma once
15
16#include "vreVrfmodel/export.h"
17#include <vrfmodel/rotaryWingPilotController.h>
19
20class DtString;
21class DtSimulationServices;
22class DtJoyDeviceControllerDescriptor;
23class DtJoyDevice;
24
25namespace makVre
26{
27//! \brief Type identifier for the rotary wing joystick flight controller component
28const char DtRotaryWingJoyFlightControllerType[] = "rotary-wing-joy-flight-controller";
29
30//! \brief Controller for joystick-based rotary-wing aircraft flight control
31//!
32//! DtRotaryWingJoyFlightController extends the base rotary wing pilot controller
33//! to provide joystick control functionality for helicopters and other rotary-wing
34//! aircraft. It translates joystick inputs into appropriate control commands for
35//! cyclic, collective, and anti-torque controls, managing the complex flight
36//! dynamics of rotary-wing vehicles.
37//!
38//! The controller includes stabilization functionality with configurable gains
39//! to assist pilot control while still allowing for realistic helicopter flight
40//! characteristics.
41//!
42//! Uses Descriptor Type: DtRotaryWingPilotDescriptor
43class VREVRFMODEL_DLL DtRotaryWingJoyFlightController : public DtRotaryWingPilotController,
45{
46public:
47 //! \brief Constructor
48 //! \param name The name of this component
49 //! \param owner The local object that owns this component
50 //! \param simManager The simulation services manager
51 //! \param desc Component descriptor with configuration parameters
52 //! \param parentRegistry Optional parent registry for reader/writer functionality
53 //!
54 //! Creates a new rotary wing joystick flight controller component with the specified parameters.
55 //! Initializes control gains and joystick input mappings for helicopter flight control.
56 DtRotaryWingJoyFlightController(const DtString& name, DtLocalObject* owner, DtSimulationServices* simManager,
57 DtComponentDescriptor* desc = 0, DtReaderWriterRegistry* parentRegistry = 0);
58
59 //! \brief Virtual destructor
60 //!
61 //! Cleans up resources used by the rotary wing joystick flight controller component.
63
64 //! \brief Initializes the controller
65 //! \return True if initialization was successful, false otherwise
66 //!
67 //! Initializes the rotary wing joystick flight controller, setting up control
68 //! gains and registering with the joystick system. Called during component creation.
69 virtual bool init() override;
70
71 //! \brief Gets the type identifier for this component
72 //! \return String identifying the component type (DtRotaryWingJoyFlightControllerType)
73 //!
74 //! Implements the DtSimComponent::type() method to return the
75 //! type identifier for this component.
76 virtual const char* type() const override;
77
78 //! \brief Calls base first-tick initialization and restores incoming joystick state.
79 virtual void preFirstTickInit() override;
80
81 //! \brief Factory method to create a new instance of this component
82 //! \param name The name for the new component
83 //! \param owner The local object that will own this component
84 //! \param simManager The simulation services manager
85 //! \param desc Optional component descriptor
86 //! \param parentRegistry Optional parent registry for reader/writer functionality
87 //! \return Pointer to the newly created component
88 //!
89 //! Static factory method used by the component creation system to instantiate
90 //! new instances of this component type.
91 static DtSimComponent* creator(const DtString& name, DtLocalObject* owner, DtSimulationServices* simManager,
92 DtComponentDescriptor* desc = 0, DtReaderWriterRegistry* parentRegistry = 0);
93
94protected:
95 //! \brief Calculates stabilizing control gains for rotary wing flight
96 //! \param manuverConst Maneuverability constant affecting control responsiveness
97 //! \param riseTime Time to desired rise in response to control inputs
98 //! \param velGain Output parameter for calculated velocity gain
99 //! \param oriGain Output parameter for calculated orientation gain
100 //!
101 //! Calculates stabilizing gains using the input parameters and internal
102 //! configuration. These gains are used to establish the proper balance between
103 //! control responsiveness and stability for the rotary wing aircraft.
104 virtual void calculateGains(const DtReal manuverConst, const DtReal riseTime, DtReal& velGain, DtReal& oriGain);
105
106 //! \brief Processes joystick input and sets corresponding port values
107 //! \param functionGroup The function group identifier for the input
108 //! \param function The specific function name for the input
109 //! \param value The input value (typically in range [-1.0, 1.0])
110 //! \param repeat Flag indicating whether the function should repeat
111 //!
112 //! Handles joystick input by translating joystick function calls into
113 //! appropriate helicopter control values. Maps joystick axes and buttons
114 //! to cyclic, collective, and anti-torque controls for rotary wing flight.
116 const DtString& functionGroup, const DtString& function, double value, bool repeat) override;
117 //! \brief Handles joystick connection events
118 //!
119 //! Required by the DtJoystickControllerInterface. Called when a joystick
120 //! is connected to the system. Sets up initial joystick mappings and
121 //! prepares the controller to receive joystick inputs.
122 virtual void joystickConnected() override;
123 //! \brief Handles joystick disconnection events
124 //!
125 //! Required by the DtJoystickControllerInterface. Called when a joystick
126 //! is disconnected from the system. Ensures the controller gracefully
127 //! handles the loss of joystick input.
128 virtual void joystickDisconnected() override;
129
130protected:
131 //! \brief Default constructor (not implemented)
132 //!
133 //! Default constructor is protected and not implemented to prevent
134 //! creation of instances without proper initialization.
136
137 //! \brief Copy constructor (not implemented)
138 //!
139 //! Copy constructor is protected and not implemented to prevent
140 //! copy construction.
142
143 //! \brief Assignment operator (not implemented)
144 //! \return Reference to this object
145 //!
146 //! Assignment operator is protected and not implemented to prevent assignment.
148
149protected:
150 //! \brief Feedback gain for the pitch angular velocity control
151 //!
152 //! Controls the responsiveness of the pitch rate to joystick inputs.
153 //! Higher values result in faster pitch rate changes.
155
156 //! \brief Feedback gain for the pitch orientation control
157 //!
158 //! Controls the responsiveness of the pitch angle to joystick inputs.
159 //! Higher values result in more direct pitch angle control.
161
162 //! \brief Feedback gain for the roll angular velocity control
163 //!
164 //! Controls the responsiveness of the roll rate to joystick inputs.
165 //! Higher values result in faster roll rate changes.
167
168 //! \brief Feedback gain for the roll orientation control
169 //!
170 //! Controls the responsiveness of the roll angle to joystick inputs.
171 //! Higher values result in more direct roll angle control.
173
174 //! \brief Feedback gain for the yaw angular velocity control
175 //!
176 //! Controls the responsiveness of the yaw rate to joystick inputs.
177 //! Higher values result in faster yaw rate changes.
179
180 //! \brief Feedback gain for the yaw orientation control
181 //!
182 //! Controls the responsiveness of the yaw angle to joystick inputs.
183 //! Higher values result in more direct yaw angle control.
185};
186} // namespace makVre
virtual const char * type() const override
Gets the type identifier for this component.
virtual bool init() override
Initializes the controller.
static DtSimComponent * creator(const DtString &name, DtLocalObject *owner, DtSimulationServices *simManager, DtComponentDescriptor *desc=0, DtReaderWriterRegistry *parentRegistry=0)
Factory method to create a new instance of this component.
DtReal myRollOriGain
Feedback gain for the roll orientation control.
Definition rotaryWingJoyFlightController.h:172
virtual void joystickDisconnected() override
Handles joystick disconnection events.
DtReal myRollVelGain
Feedback gain for the roll angular velocity control.
Definition rotaryWingJoyFlightController.h:166
DtReal myYawOriGain
Feedback gain for the yaw orientation control.
Definition rotaryWingJoyFlightController.h:184
DtRotaryWingJoyFlightController()
Default constructor (not implemented)
virtual ~DtRotaryWingJoyFlightController() override
Virtual destructor.
DtRotaryWingJoyFlightController & operator=(const DtRotaryWingJoyFlightController &orig)
Assignment operator (not implemented)
DtReal myYawVelGain
Feedback gain for the yaw angular velocity control.
Definition rotaryWingJoyFlightController.h:178
DtRotaryWingJoyFlightController(const DtString &name, DtLocalObject *owner, DtSimulationServices *simManager, DtComponentDescriptor *desc=0, DtReaderWriterRegistry *parentRegistry=0)
Constructor.
DtRotaryWingJoyFlightController(const DtRotaryWingJoyFlightController &orig)
Copy constructor (not implemented)
virtual void preFirstTickInit() override
Calls base first-tick initialization and restores incoming joystick state.
DtReal myPitchVelGain
Feedback gain for the pitch angular velocity control.
Definition rotaryWingJoyFlightController.h:154
virtual void calculateGains(const DtReal manuverConst, const DtReal riseTime, DtReal &velGain, DtReal &oriGain)
Calculates stabilizing control gains for rotary wing flight.
DtReal myPitchOriGain
Feedback gain for the pitch orientation control.
Definition rotaryWingJoyFlightController.h:160
virtual void joystickConnected() override
Handles joystick connection events.
virtual void calcAndSetPortValues(const DtString &functionGroup, const DtString &function, double value, bool repeat) override
Processes joystick input and sets corresponding port values.
DtVreJoystickControllerInterface(DtSimComponent *component, DtLocalObject *owner, DtSimulationServices *simManager, DtComponentDescriptor *desc)
Constructs an interface alongside an existing component base.
Defines export macros for the vreVrfmodel library.
#define VREVRFMODEL_DLL
Definition export.h:22
!
Definition glsVreMessageUtil.h:50
const char DtRotaryWingJoyFlightControllerType[]
Type identifier for the rotary wing joystick flight controller component.
Definition rotaryWingJoyFlightController.h:28
Internal-state persistence for VRE joystick controllers.