VR-Engage  2.2
Loading...
Searching...
No Matches
vreRlJoyController.h
Go to the documentation of this file.
1/*******************************************************************************
2** Copyright (c) 2025 MAK Technologies
3** All rights reserved.
4*******************************************************************************/
5
6//! \file vreRlJoyController.h
7//! \ingroup vreVrfRtd
8//! \brief Rotary-wing joystick controller for VREngage
9//!
10//! This file defines the DtVreRlJoyController class, which manages joystick
11//! input for rotary-wing aircraft in VREngage and converts it into appropriate
12//! control surface movements.
13
14#pragma once
15
17
20
21class DtBooleanOutputPort;
22class DtAnalogOutputPort;
23
24
25namespace RlCgfVrf
26{
28
29//! \brief Type string for VREngage rotary-wing joystick controller component
30//!
31//! Constant used to identify this component type in the simulation system.
32const char TS_JoyController[] = "rotorlib-cgf-vr-engage-joy-controller";
33//! \brief Rotary-wing joystick controller for VREngage
34//!
35//! This class manages joystick input for rotary-wing aircraft and converts
36//! it into appropriate control surface movements. It handles various input
37//! devices and maps their values to helicopter control outputs, providing a bridge
38//! between the physical joystick and the helicopter flight model.
39class RTD_VRF_BACKEND_PLUGIN_EXPORT DtVreRlJoyController : public makVre::DtRotaryWingJoyFlightController,
41{
42public:
43 //! \brief Constructor
44 //! \param name The name of the component
45 //! \param owner The local object this component belongs to
46 //! \param simManager The simulation services manager
47 //! \param desc Component descriptor containing configuration
48 //! \param parentRegistry Parent registry for reader/writer functionality
49 //!
50 //! Initializes a new rotary-wing joystick controller component for VREngage control.
51 DtVreRlJoyController(const DtString& name, DtLocalObject* owner, DtSimulationServices* simManager,
52 DtComponentDescriptor* desc = 0, DtReaderWriterRegistry* parentRegistry = 0);
53
54 //! \brief Virtual destructor
55 //!
56 //! Cleans up resources used by the joystick controller component.
57 virtual ~DtVreRlJoyController() override;
58
59 //! \brief Initializes the joystick controller
60 //! \return True if initialization was successful
61 //!
62 //! Performs initial setup of the joystick controller, including configuration
63 //! loading and port initialization.
64 virtual bool init() override;
65
66 //! \brief Performs per-frame processing
67 //!
68 //! Called once per simulation frame to calculate new control values
69 //! based on current joystick input and update the output ports.
70 virtual void tick() override;
71
72 //! \brief Creates component ports
73 //! \return True if port creation was successful
74 //!
75 //! Creates output ports for cyclic, collective, pedals, and other helicopter controls.
76 virtual bool createPorts() override;
77
78 //! \brief Calculates and sets port values for a specific joystick function
79 //! \param functionGroup The function group of the joystick input
80 //! \param function The specific function within the group
81 //! \param value The input value from the joystick
82 //! \param repeat Whether this is a repeated input
83 //!
84 //! Maps joystick inputs to the appropriate helicopter control outputs.
86 const DtString& functionGroup, const DtString& function, double value, bool repeat) override;
87
88 //! \brief Gets the component type
89 //! \return The type string for this component
90 //!
91 //! Returns TS_JoyController as the component type identifier.
92 virtual const char* type() const override;
93
94 //! \brief Gets the joystick enabled output port
95 //! \return Pointer to the joystick enabled output port
96 //!
97 //! Returns the output port that indicates whether joystick control is enabled.
98 virtual DtBooleanOutputPort* joystickEnabledPort();
99
100 //! \brief Disables the joystick controller
101 //!
102 //! Disables joystick input processing, usually when player
103 //! control is deactivated.
104 virtual void disable() override;
105
106 //! \brief Enables the joystick controller
107 //!
108 //! Enables joystick input processing, usually when player
109 //! control is activated.
110 virtual void enable() override;
111
112 //! \brief Sets the enabled state of the joystick controller
113 //! \param yes True to enable the controller, false to disable
114 //!
115 //! Directly sets the enabled state of the joystick controller.
116 virtual void setIsEnabled(bool yes) override;
117
118 //! \brief Component factory function
119 //! \param name The name for the new component
120 //! \param owner The local object the component will belong to
121 //! \param simManager The simulation services manager
122 //! \param desc Component descriptor containing configuration
123 //! \param parentRegistry Parent registry for reader/writer functionality
124 //! \return Pointer to the newly created component
125 //!
126 //! Static factory function used for component creation through the component registry.
127 static DtSimComponent* creator(const DtString& name, DtLocalObject* owner, DtSimulationServices* simManager,
128 DtComponentDescriptor* desc = 0, DtReaderWriterRegistry* parentRegistry = 0);
129
130private:
131 //! \brief Copy constructor (not implemented)
132 //! \param orig The source object
134
135 //! \brief Assignment operator (not implemented)
136 //! \param orig The source object
137 //! \return Reference to this object
139
140 //! \brief Component descriptor containing configuration parameters
142
143 //! \brief Output port for wheel brake control
144 DtAnalogOutputPort* myWheelBrakeOutputPort;
145
146 //! \brief Output port for pedal control (yaw)
147 //!
148 //! Pedal port of VRF rotWingActuator doesn't get any values. Seems to be a bug.
149 //! Use this port to apply values.
150 DtAnalogOutputPort* myPedalOutputPort;
151
152 //! \brief Output port for collective control (lift)
153 DtConstrainedAnalogOutputPort* myCollectiveOutputPort;
154
155 //! \brief Output port for cyclic control (pitch/roll)
156 DtConstrainedDualAxisAnalogOutputPort* myCyclicOutputPort;
157};
158
159} // namespace RlCgfVrf
Rotary-wing joystick controller descriptor for VREngage.
Definition vreRlJoyControllerDescriptor.h:33
virtual void disable() override
Disables the joystick controller.
DtConstrainedDualAxisAnalogOutputPort * myCyclicOutputPort
Output port for cyclic control (pitch/roll)
Definition vreRlJoyController.h:156
DtVreRlJoyController(const DtVreRlJoyController &orig)
Copy constructor (not implemented)
DtAnalogOutputPort * myWheelBrakeOutputPort
Output port for wheel brake control.
Definition vreRlJoyController.h:144
virtual void setIsEnabled(bool yes) override
Sets the enabled state of the joystick controller.
virtual void calcAndSetPortValues(const DtString &functionGroup, const DtString &function, double value, bool repeat) override
Calculates and sets port values for a specific joystick function.
DtConstrainedAnalogOutputPort * myCollectiveOutputPort
Output port for collective control (lift)
Definition vreRlJoyController.h:153
virtual void tick() override
Performs per-frame processing.
virtual bool createPorts() override
Creates component ports.
virtual ~DtVreRlJoyController() override
Virtual destructor.
virtual DtBooleanOutputPort * joystickEnabledPort()
Gets the joystick enabled output port.
DtAnalogOutputPort * myPedalOutputPort
Output port for pedal control (yaw)
Definition vreRlJoyController.h:150
const DtVreRlJoyControllerDescriptor * myDesc
Component descriptor containing configuration parameters.
Definition vreRlJoyController.h:141
virtual const char * type() const override
Gets the component type.
virtual bool init() override
Initializes the joystick controller.
DtVreRlJoyController(const DtString &name, DtLocalObject *owner, DtSimulationServices *simManager, DtComponentDescriptor *desc=0, DtReaderWriterRegistry *parentRegistry=0)
Constructor.
virtual void enable() override
Enables the joystick controller.
static DtSimComponent * creator(const DtString &name, DtLocalObject *owner, DtSimulationServices *simManager, DtComponentDescriptor *desc=0, DtReaderWriterRegistry *parentRegistry=0)
Component factory function.
DtVreRlJoyController & operator=(const DtVreRlJoyController &orig)
Assignment operator (not implemented)
Controller for joystick-based rotary-wing aircraft flight control.
Definition rotaryWingJoyFlightController.h:45
Extension trait for joystick controllers in VREngage.
Definition vreRtdTraitJoyControllerExtension.h:28
Definition vreRlActuator.h:40
const char TS_JoyController[]
Type string for VREngage rotary-wing joystick controller component.
Definition vreRlJoyController.h:32
Controller for joystick-based rotary-wing aircraft flight control.
Common definitions for the RTD backend library.
Extension trait for joystick controllers in VREngage.