VR-Engage  2.2
Loading...
Searching...
No Matches
artPartActuator.h
Go to the documentation of this file.
1/*******************************************************************************
2** Copyright (c) 2025 MAK Technologies
3** All rights reserved.
4*******************************************************************************/
5
6//! \file artPartActuator.h
7//! \ingroup vreVrfmodel
8//! \brief Stabilized articulated part actuator component for VR Engage
9//!
10//! This file defines the DtVreStabilizedArtPartActuator class which provides control
11//! for rotating articulated parts with stabilization capabilities.
12
13#pragma once
14
15#include "vreVrfmodel/export.h"
17
18#include <vrfobjcore/actuatorComponent.h>
19
21
22class DtString;
23class DtSimulationServices;
24
26class DtConstrainedAnalogInputPort;
27class DtBooleanInputPort;
28
29//! \brief DtTurretActuatorComponent provides a simple model of a
30//! rotating turret that knows how to drive the articulating parts objects of
31//! the local state repository.
32//!
33//! End User Description: The turret actuator updates the articulated part
34//! specified in its component descriptor, based on slew data it receives. It
35//! expects an input (via a mySlewPort) of a slew amount between -1. and +1.
36//!
37//! Developer Description: The tick() function first checks to see if dT is
38//! 0.0. If it is, it just returns. Otherwise, it looks up the
39//! DtArticulatedPartStateRepository object kept by the entity to maintain state for
40//! the turret using DtAttachmentManager::findPartByType with the turret art
41//! part type from the process state repository as the argument.
42//! The current angle of the turret (with respect to whatever is it attached
43//! to) is retrieved from the DtArticulatedPartStateRepository which represents the
44//! turret by going through the kinematic state to get the "psi" component of
45//! the parent orientation.
46//! The slewRate to use is calculated using:
47//! the value on the slew port * myMaxSlewRate
48//! The new turret angle is calculated as:
49//! the current angle + (slew rate * dT)
50//! The angle is then constrained to be between 0.0 and 2 * PI using the
51//! VR-Link utility function DtModPerLo(). The new angle is then stored in the
52//! kinematic state of the rotating body.
53//!
54//! Uses Descriptor Type: DtTurretComponentDescriptor
55
56namespace makVre
57{
58const char DtVreStabilizedArtPartActuatorType[] = "vre-stabilized-art-part-actuator";
59
61{
62public:
63 //! \copydoc DtSimComponent(const DtString&,DtLocalObject*,DtSimulationServices*,
64 //! DtComponentDescriptor*,DtReaderWriterRegistry* parentRegistry)
65 DtVreStabilizedArtPartActuator(const DtString& name, DtLocalObject* owner, DtSimulationServices* simManager,
66 DtComponentDescriptor* desc = 0, DtReaderWriterRegistry* parentRegistry = 0);
67
68 //! destructor
70
71 //! \copydoc DtSimComponent::type()
72 //! \return DtTurretActuatorType
73 virtual const char* type() const override;
74
75 virtual bool init() override;
76
77 //! Calls lookupAndCacheProcessSR() and initProcessSR()
78 virtual bool postAddComponentsInit() override;
79
80 //! Calculate new kinematic state.
81 virtual void tick() override;
82
83 //! \copydoc DtSimComponent(const DtString&,DtLocalObject*,DtSimulationServices*,
84 //! DtComponentDescriptor*,DtReaderWriterRegistry* parentRegistry)
85 //! \return New instance of this class.
86 static DtSimComponent* creator(const DtString& name, DtLocalObject* owner, DtSimulationServices* simManager,
87 DtComponentDescriptor* desc = 0, DtReaderWriterRegistry* parentRegistry = 0);
88
89protected:
90 //! default constructor; not implemented
92
93 //! copy constructor; not implemented
95
96 //! assignment operator; not implemented
98
99 //! Creates the slew port.
100 virtual bool createPorts() override;
101
102 DtVector getLocalRotationAxis(const DtDcm& orientation);
103 double calculateSlewToTarget(const DtVector& target);
107 double realizeSlew(double& slewRate);
108 DtDcm axisOrientation() const;
109
110 // Handler for SlewToCue message.
112
113 //! \name Ports and Port Groups
114 //! @{
115
116 //! Input Port Name: slew\n
117 //! Input Port Description: -1.0 indicates maximum left slew, 1.0 indicates
118 //! maximum right slew\n
119 //! Input Port Range: -1. to 1.\n
120 //! Input Port Default Value: \n
121 //! Input Group Parent:
122 DtConstrainedAnalogInputPort* mySlewPort;
123
124 //! Input Port Name: stabilize\n
125 //! Input Port Description: Set stabilization on or off for this actuator.\n
126 //! Input Port Range: \n
127 //! Input Group Parent: \n
128 DtBooleanInputPort* myStabilizePort;
129
130 //! @}
131
133
134 DtArtPartType myPartType;
135
136 makVrf::DtArticulatedPartStateRepository* myPart;
137
138 //! Cache for the condition for 360 rotation, which is
139 //! hasFixedAzimuth = false and leftLimit = rightLimit
140 //! (all info from turretComponentDescriptor)
142
143 //! Local copies of the parameters in the turret descriptor,
144 //! conditioned to be between 0 and 2pi.
147
150
151 DtVector myCueVector;
153
154 //! When switching weapon systems, we can't rely on the port to determine if there's been
155 //! new data sent. Therefore, if we switched away from this weapon while giving turret
156 //! input, we need to cache that last input value so we can test it against new inputs when
157 //! we switch back.
160};
161
162} // namespace makVre
Stabilized articulated part actuator descriptor for VREngage.
Definition artPartActuatorDescriptor.h:39
Abstract base class for all VREngage messages.
Definition vreMessage.h:50
DtVreSimComponent(const DtString &name, DtLocalObject *owner, DtSimulationServices *simManager, DtComponentDescriptor *desc=0, DtReaderWriterRegistry *parentRegistry=0)
Definition vreSimComponent.h:54
DtVreStabilizedArtPartActuator(const DtVreStabilizedArtPartActuator &orig)
copy constructor; not implemented
const DtVreStabilizedArtPartActuatorDescriptor * myArtPartActuatorDescriptor
Definition artPartActuator.h:132
DtVreStabilizedArtPartActuator(const DtString &name, DtLocalObject *owner, DtSimulationServices *simManager, DtComponentDescriptor *desc=0, DtReaderWriterRegistry *parentRegistry=0)
DtVector myCueVector
Definition artPartActuator.h:151
const DtVreStabilizedArtPartActuator & operator=(const DtVreStabilizedArtPartActuator &orig)
assignment operator; not implemented
bool myStabilizationOn
Definition artPartActuator.h:149
static DtSimComponent * creator(const DtString &name, DtLocalObject *owner, DtSimulationServices *simManager, DtComponentDescriptor *desc=0, DtReaderWriterRegistry *parentRegistry=0)
DtVreStabilizedArtPartActuator()
default constructor; not implemented
DtReal myUpperLimit
Definition artPartActuator.h:146
DtReal myLowerLimit
Local copies of the parameters in the turret descriptor, conditioned to be between 0 and 2pi.
Definition artPartActuator.h:145
makVrf::DtArticulatedPartStateRepository * myPart
Definition artPartActuator.h:136
virtual ~DtVreStabilizedArtPartActuator() override
destructor
bool mySlewToCueOverrideActive
Definition artPartActuator.h:152
virtual void tick() override
Calculate new kinematic state.
virtual bool postAddComponentsInit() override
Calls lookupAndCacheProcessSR() and initProcessSR()
double myLastInput
Definition artPartActuator.h:159
virtual bool createPorts() override
Creates the slew port.
double realizeSlew(double &slewRate)
DtArtPartType myPartType
Definition artPartActuator.h:134
bool myRotation360
Cache for the condition for 360 rotation, which is hasFixedAzimuth = false and leftLimit = rightLimit...
Definition artPartActuator.h:141
double calculateSlewToTarget(const DtVector &target)
bool myStabilizeButtonDown
Definition artPartActuator.h:148
DtVector getLocalRotationAxis(const DtDcm &orientation)
DtConstrainedAnalogInputPort * mySlewPort
Input Port Name: slew Input Port Description: -1.0 indicates maximum left slew, 1....
Definition artPartActuator.h:122
DtBooleanInputPort * myStabilizePort
Input Port Name: stabilize Input Port Description: Set stabilization on or off for this actuator....
Definition artPartActuator.h:128
bool myRequireNewData
When switching weapon systems, we can't rely on the port to determine if there's been new data sent....
Definition artPartActuator.h:158
virtual const char * type() const override
virtual DtVreMessageResult handleSlewToCue(DtVreMessage *msg)
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 DtVreStabilizedArtPartActuatorType[]
Definition artPartActuator.h:58
DtVreMessageResult
Enumeration of possible message handling results.
Definition vreMessage.h:33
Defines the base class for all VREngage messages.
Base template class for VR-Engage simulation components.