VR-Engage  2.2
Loading...
Searching...
No Matches
vreLadderClimbingActuator.h
Go to the documentation of this file.
1/*******************************************************************************
2** Copyright (c) 2025 MAK Technologies
3** All rights reserved.
4*******************************************************************************/
5
6//! \file vreLadderClimbingActuator.h
7//! \ingroup vreVrfmodel
8//! \brief Actuator for human ladder climbing
9//!
10//! This file defines the DtVreLadderClimbingActuator class which handles movement
11//! of human entities up and down ladders. It manages position, velocity, and orientation
12//! updates when a human entity is in the ladder-climbing state.
13
14#pragma once
15
16#include "vreVrfmodel/export.h"
18
19#include <vrfobjcore/actuatorComponent.h>
20
21class DtAnalogInputPort;
22class DtInputPortGroup;
23class DtUpdateRepositoryOutputPortGroup;
24
25namespace makVre
26{
28class DtLadder;
29
30//! \brief Type identifier for the VRE ladder climbing actuator component
31const char DtVreLadderClimbingActuatorType[] = "vre-ladder-climbing-actuator";
32
33//! \brief Actuator responsible for moving human entities up and down ladders
34//!
35//! DtVreLadderClimbingActuator handles the movement of human entities when they
36//! are climbing ladders. It manages the entity's position, velocity, and orientation
37//! during ladder climbing, ensuring smooth transitions between regular movement and
38//! ladder climbing states. The actuator receives movement direction input from
39//! control components and updates the entity's state accordingly.
41{
42public:
43 //! \brief Constructor
44 //! \param name The name of this component
45 //! \param owner The local object that owns this component
46 //! \param simManager The simulation services manager
47 //! \param desc Component descriptor with configuration parameters
48 //! \param parentRegistry Optional parent registry for reader/writer functionality
49 //!
50 //! Creates a new ladder climbing actuator component with the specified parameters.
51 DtVreLadderClimbingActuator(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 ladder climbing actuator component,
57 //! including process state and port groups.
58 virtual ~DtVreLadderClimbingActuator() override;
59
60 //! \brief Gets the type identifier for this component
61 //! \return String identifying the component type (DtVreLadderClimbingActuatorType)
62 //!
63 //! Implements the DtSimComponent::type() method to return the
64 //! type identifier for this component.
65 virtual const char* type() const override;
66
67 //! \brief Initializes the ladder climbing actuator
68 //! \return True if initialization is successful, false otherwise
69 //!
70 //! Performs initial setup of the ladder climbing actuator, including creating
71 //! the process state repository (PSR) for maintaining climb state. This method
72 //! is called during component initialization.
73 virtual bool init() override;
74
75 //! \brief Updates the actuator state each simulation frame
76 //!
77 //! If the entity is in a ladder-climbing state (according to the PSR),
78 //! computes the movement of the entity on the ladder for this tick and
79 //! updates the state in myUpdateRepositoryOutputPortGroup. This includes
80 //! calculating new position, velocity, and orientation values based on
81 //! the input control direction and ladder geometry.
82 virtual void tick() override;
83
84 //! \brief Creates input and output ports for the actuator
85 //! \return True if ports are successfully created, false otherwise
86 //!
87 //! Creates the movement control input ports needed for ladder climbing,
88 //! as well as the update repository output port group for updating the
89 //! entity's state. These ports allow the actuator to receive movement
90 //! direction and output position updates.
91 virtual bool createPorts() override;
92
93 //! \brief Creates input and output port groups for the actuator
94 //! \return True if port groups are successfully created, false otherwise
95 //!
96 //! Creates the movement control input port group and the update repository
97 //! output port group. These port groups organize the input and output ports
98 //! for proper routing between components.
99 virtual bool createPortGroups() override;
100
101 //! \brief Factory method to create a new instance of this component
102 //! \param name The name for the new component
103 //! \param owner The local object that will own this component
104 //! \param simManager The simulation services manager
105 //! \param desc Optional component descriptor
106 //! \param parentRegistry Optional parent registry for reader/writer functionality
107 //! \return Pointer to the newly created component
108 //!
109 //! Static factory method used by the component creation system to instantiate
110 //! new instances of this component type.
111 static DtSimComponent* creator(const DtString& name, DtLocalObject* owner, DtSimulationServices* simManager,
112 DtComponentDescriptor* desc = 0, DtReaderWriterRegistry* parentRegistry = 0);
113
114protected:
115 //! \brief Creates the process state repository for the actuator
116 //! \return Pointer to the created process state repository
117 //!
118 //! Creates the myProcessState data member and adds it to the process state
119 //! repository manager. Uses the name and type specified in the component
120 //! descriptor (if they exist) or appropriate defaults if not specified.
121 //! This PSR stores the ladder climbing state including which ladder the
122 //! entity is on and position information.
124
125 //! \brief Gets the default process state repository type
126 //! \return String identifying the default PSR type
127 //!
128 //! Returns the default process state repository type for ladder climbing,
129 //! which is used when no type is specified in the component descriptor.
130 const char* defaultPSRType() const;
131
132 //! \brief Gets the ladder climbing speed for this entity
133 //! \return Climbing speed in meters per second
134 //!
135 //! Returns the ladder climbing speed for this entity in meters per second.
136 //! The speed is based on the value from the descriptor if one exists
137 //! (i.e., if a descriptor of type DtClimbingLadderActuatorDescriptor has been
138 //! configured). If no descriptor is available or the speed is not specified,
139 //! a default value of 0.4 m/s is returned.
140 virtual double ladderClimbingSpeed();
141
142 //! \brief Calculates and updates entity state during ladder climbing
143 //!
144 //! If the entity is on a ladder, calculates the new position, velocity,
145 //! orientation, and other state values for the current simulation frame,
146 //! then sets these values on the output ports. This method handles the
147 //! actual movement calculations based on input direction and ladder geometry.
149
150 //! \brief Constrains entity position to the ladder extent
151 //! \param ladder Reference to the ladder object
152 //! \param bodyLadderBaseToEntity Vector from ladder base to entity in body coordinates
153 //!
154 //! Given a vector in body coordinates, clamps it to fall somewhere along the length
155 //! of the ladder. This ensures that the entity's x component (in body coordinates)
156 //! remains between the base and top of the ladder, preventing the entity from
157 //! climbing beyond the ladder's endpoints.
158 virtual void clampToLadderExtent(const DtLadder& ladder, DtVector& bodyLadderBaseToEntity);
159
160protected:
161 //! \brief Process state repository for ladder climbing state
162 //!
163 //! Holds state information associated with ladder climbing, including which
164 //! ladder the entity is currently on, position relative to the ladder, and
165 //! climbing state. This state persists across simulation ticks and can be
166 //! saved and restored with scenarios.
168
169 //! \name Ports and Port Groups
170 //! \{
171
172 //! \brief Input port for ladder climbing movement direction
173 //!
174 //! Receives the desired climbing direction in radians (range: 0 - 2*pi).
175 //! This direction controls whether the entity climbs up, down, or
176 //! remains stationary on the ladder. Parent group: movement-control
178
179 //! \brief Output port group for updating entity state
180 //!
181 //! Port group used to set values into the VRF state repository during ladder climbing.
182 //! This includes position, velocity, orientation, and other state values in local
183 //! coordinates, which are applied to the entity during simulation.
184 DtUpdateRepositoryOutputPortGroup* myUpdateRepositoryOutputPortGroup;
185};
186
187} // namespace makVre
Helper class that represents a climbable ladder in simulations.
Definition ladder.h:35
const char * defaultPSRType() const
Gets the default process state repository type.
virtual bool init() override
Initializes the ladder climbing actuator.
virtual ~DtVreLadderClimbingActuator() override
Virtual destructor.
DtUpdateRepositoryOutputPortGroup * myUpdateRepositoryOutputPortGroup
Output port group for updating entity state.
Definition vreLadderClimbingActuator.h:184
virtual bool createPorts() override
Creates input and output ports for the actuator.
DtVreLadderClimbingPSR * myProcessState
Process state repository for ladder climbing state.
Definition vreLadderClimbingActuator.h:167
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 calculateAndUpdateNewState()
Calculates and updates entity state during ladder climbing.
virtual void clampToLadderExtent(const DtLadder &ladder, DtVector &bodyLadderBaseToEntity)
Constrains entity position to the ladder extent.
DtAnalogInputPort * myLadderClimbingMovementDirectionInputPort
Input port for ladder climbing movement direction.
Definition vreLadderClimbingActuator.h:177
virtual double ladderClimbingSpeed()
Gets the ladder climbing speed for this entity.
virtual const char * type() const override
Gets the type identifier for this component.
DtVreLadderClimbingActuator(const DtString &name, DtLocalObject *owner, DtSimulationServices *simManager, DtComponentDescriptor *desc=0, DtReaderWriterRegistry *parentRegistry=0)
Constructor.
virtual bool createPortGroups() override
Creates input and output port groups for the actuator.
virtual DtVreLadderClimbingPSR * createPSR()
Creates the process state repository for the actuator.
virtual void tick() override
Updates the actuator state each simulation frame.
Process state repository for ladder climbing components.
Definition vreLadderClimbingPSR.h:61
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 DtVreLadderClimbingActuatorType[]
Type identifier for the VRE ladder climbing actuator component.
Definition vreLadderClimbingActuator.h:31
Base template class for VR-Engage simulation components.