VR-Engage  2.2
Loading...
Searching...
No Matches
controlSurfacesActuator.h
Go to the documentation of this file.
1/*******************************************************************************
2** Copyright (c) 2025 MAK Technologies
3** All rights reserved.
4*******************************************************************************/
5
6//! \file controlSurfacesActuator.h
7//! \ingroup vreVrfmodel
8//! \brief Actuator for aircraft control surfaces
9//!
10//! This file defines the DtControlSurfacesActuator class which manages the articulated
11//! parts for fixed wing control surfaces (rudder, ailerons, elevators) and flaps based on
12//! incoming port data. It translates control inputs into appropriate control surface
13//! deflections.
14
15#pragma once
16
17#include <vreVrfmodel/export.h>
19
21
22#include <vrfobjcore/actuatorComponent.h>
23
24class DtString;
25class DtSimulationServices;
26
27class DtControlSurfacesActuatorDescriptor;
28class DtAnalogInputPort;
29class DtBooleanInputPort;
30
31namespace makVre
32{
33//! \brief Type identifier for the control surfaces actuator component
34const char DtControlSurfacesActuatorType[] = "control-surfaces-actuator";
35
36//! \brief Actuator component for aircraft flight control surfaces
37//!
38//! DtControlSurfacesActuator manages the articulated parts for fixed wing
39//! flight control surfaces such as rudder, ailerons, elevators, and flaps.
40//! It receives control inputs through input ports and applies the appropriate
41//! deflection values to the corresponding articulated parts.
42//!
43//! Uses Descriptor Type: DtActuatorComponentDescriptor
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 Optional component descriptor
52 //! \param parentRegistry Optional parent registry for reader/writer functionality
53 //!
54 //! Creates a new control surfaces actuator component with the specified parameters.
55 DtControlSurfacesActuator(const DtString& name, DtLocalObject* owner, DtSimulationServices* simManager,
56 DtComponentDescriptor* desc = 0, DtReaderWriterRegistry* parentRegistry = 0);
57
58 //! \brief Virtual destructor
59 //!
60 //! Cleans up resources used by the control surfaces actuator component.
61 virtual ~DtControlSurfacesActuator() override;
62
63 //! \brief Gets the type identifier for this component
64 //! \return String identifying the component type (DtControlSurfacesActuatorType)
65 //!
66 //! Implements the DtSimComponent::type() method to return the
67 //! type identifier for this component.
68 virtual const char* type() const override;
69
70 // virtual bool init() override;
71
72 //! \brief Performs post-component-addition initialization
73 //! \return True if initialization is successful, false otherwise
74 //!
75 //! Gets and caches references to the articulated part repositories for
76 //! each control surface after all components have been added.
77 virtual bool postAddComponentsInit() override;
78
79 //! \brief Updates control surface positions each simulation frame
80 //!
81 //! Reads current input port values and applies the appropriate deflection
82 //! to each control surface articulated part. When player control is lost,
83 //! it will run one additional tick to reset surfaces to neutral positions.
84 virtual void tick() override;
85
86 //! \brief Factory method to create a new instance of this component
87 //! \param name The name for the new component
88 //! \param owner The local object that will own this component
89 //! \param simManager The simulation services manager
90 //! \param desc Optional component descriptor
91 //! \param parentRegistry Optional parent registry for reader/writer functionality
92 //! \return Pointer to the newly created component
93 //!
94 //! Static factory method used by the component creation system to instantiate
95 //! new instances of this component type.
96 static DtSimComponent* creator(const DtString& name, DtLocalObject* owner, DtSimulationServices* simManager,
97 DtComponentDescriptor* desc = 0, DtReaderWriterRegistry* parentRegistry = 0);
98
99private:
100 //! \brief Default constructor (not implemented)
101 //!
102 //! Default constructor is private and not implemented to prevent
103 //! creation of instances without proper initialization.
105
106 //! \brief Copy constructor (not implemented)
107 //!
108 //! Copy constructor is private and not implemented to prevent
109 //! copy construction.
111
112 //! \brief Assignment operator (not implemented)
113 //! \return Reference to this object
114 //!
115 //! Assignment operator is private and not implemented to prevent assignment.
117
118protected:
119 //! \brief Creates input ports for control surfaces
120 //! \return True if ports were created successfully, false otherwise
121 //!
122 //! Creates the input ports for each defined control surface and
123 //! adds them to the control surfaces port group.
124 virtual bool createPorts() override;
125
126 //! \brief Creates port groups for organizing input ports
127 //! \return True if port groups were created successfully, false otherwise
128 //!
129 //! Creates a port group called "control-surfaces" to organize
130 //! all control surface input ports.
131 virtual bool createPortGroups() override;
132
133 //! \brief Associates an input port with the corresponding art part repository
134 //!
135 //! This structure maintains the relationship between an input port that
136 //! receives control commands and the articulated part that should be
137 //! manipulated based on those commands.
138 struct PortData
139 {
140 //! \brief Default constructor
141 //!
142 //! Initializes pointers to null
144 : myInput(0)
145 , myPartRep(0)
146 {
147 }
148
149 //! \brief Pointer to the analog input port for this control surface
150 DtAnalogInputPort* myInput;
151
152 //! \brief Pointer to the articulated part state repository for this control surface
153 makVrf::DtArticulatedPartStateRepository* myPartRep;
154 };
155
156 //! \brief Map of control surface names to their port and articulated part data
157 //!
158 //! Maps each control surface name (e.g., "rudder", "aileron") to its
159 //! corresponding PortData structure containing input port and art part references.
160 std::map<std::string, PortData> myPorts;
161
162 //! \brief Port group for control surface inputs
163 //!
164 //! Groups all control surface input ports under the "control-surfaces" group
165 //! for easier organization and access.
167
168 //! \brief Flag indicating if this entity is currently player-controlled
169 //!
170 //! Tracks whether the entity is currently under player control. When control is lost,
171 //! this allows the actuator to tick one more time to reset control surfaces to
172 //! neutral positions.
174};
175
176} // namespace makVre
virtual bool createPorts() override
Creates input ports for control surfaces.
virtual const char * type() const override
Gets the type identifier for this component.
std::map< std::string, PortData > myPorts
Map of control surface names to their port and articulated part data.
Definition controlSurfacesActuator.h:160
virtual bool postAddComponentsInit() override
Performs post-component-addition initialization.
bool myPlayerControlled
Flag indicating if this entity is currently player-controlled.
Definition controlSurfacesActuator.h:173
virtual ~DtControlSurfacesActuator() override
Virtual destructor.
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.
virtual void tick() override
Updates control surface positions each simulation frame.
DtControlSurfacesActuator()
Default constructor (not implemented)
DtControlSurfacesActuator(const DtString &name, DtLocalObject *owner, DtSimulationServices *simManager, DtComponentDescriptor *desc=0, DtReaderWriterRegistry *parentRegistry=0)
Constructor.
virtual bool createPortGroups() override
Creates port groups for organizing input ports.
const DtControlSurfacesActuator & operator=(const DtControlSurfacesActuator &orig)
Assignment operator (not implemented)
DtInputPortGroup * myControlSurfacesInputGroup
Port group for control surface inputs.
Definition controlSurfacesActuator.h:166
DtControlSurfacesActuator(const DtControlSurfacesActuator &orig)
Copy constructor (not implemented)
DtVreSimComponent(const DtString &name, DtLocalObject *owner, DtSimulationServices *simManager, DtComponentDescriptor *desc=0, DtReaderWriterRegistry *parentRegistry=0)
Definition vreSimComponent.h:54
Defines export macros for the vreVrfmodel library.
#define VREVRFMODEL_DLL
Definition export.h:22
Include export definitions for this library.
Definition glsVreMessageUtil.h:49
const char DtControlSurfacesActuatorType[]
Type identifier for the control surfaces actuator component.
Definition controlSurfacesActuator.h:34
makVrf::DtArticulatedPartStateRepository * myPartRep
Pointer to the articulated part state repository for this control surface.
Definition controlSurfacesActuator.h:153
DtAnalogInputPort * myInput
Pointer to the analog input port for this control surface.
Definition controlSurfacesActuator.h:150
PortData()
Default constructor.
Definition controlSurfacesActuator.h:143
Defines the base class for all VREngage messages.
Base template class for VR-Engage simulation components.