VR-Forces Developer's Guide
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
humanMoveToController.h
Go to the documentation of this file.
1 /****************************************************************************
2  * Copyright (c) 2021 MAK Technologies, Inc.
3  * All rights reserved.
4  ****************************************************************************/
5 
9 
10 #pragma once
11 
15 
16 class DtCgf;
18 class DtSimMessage;
19 class DtHumanMoveToPSR;
21 class DtInputPortGroup;
23 class DtVectorOutputPort;
27 class DtGenericPsr;
28 class DtAnalogInputPort;
29 class DtAnalogOutputPort;
30 class DtVectorInputPort;
31 
43 {
44 private:
51 public:
53  DtHumanMoveToController(const DtString& name, DtLocalObject* owner, DtSimulationServices* simManager, DtComponentDescriptor* desc=nullptr, DtReaderWriterRegistry *parentRegistry=nullptr);
54 
56  virtual ~DtHumanMoveToController();
57 
59  virtual bool init() override;
60 
62  virtual const char* type() const override;
63 
65  virtual void tick() override;
66 
71  static void moveToCallback(DtSimMessage * msg, void * usr);
72 
77  static void setLocationCallback(DtSimMessage* msg, void* usr);
78 
83  static void moveToLocationCallback(DtSimMessage * msg, void * usr);
84 
85  static void moveToDestinationCallback(DtSimMessage* msg, void* usr);
86 
88  static DtSimComponent* creator(const DtString& name, DtLocalObject* owner, DtSimulationServices* simManager, DtComponentDescriptor* desc=nullptr, DtReaderWriterRegistry* parentRegistry=nullptr);
89 
91  static void modifyVrfObjectCallback(DtSimMessage* msg, void* usr);
92 
93 protected:
94 
97  virtual void processMoveToTask(DtSimMessage * msg);
98 
99 
100  virtual void processMoveToLocationTask(DtSimMessage * msg);
101 
102  virtual void processMoveToDestinationTask(DtSimMessage* msg);
103 
108  virtual void processDestinationChanged();
109 
113  virtual bool setupDestination();
114 
123  virtual void setupDestinationVector() const;
124 
126  virtual void invalidateDestinationVector() const;
127 
136  virtual bool atDestination();
137 
139  virtual void doMoving();
140 
142  virtual double findDesiredHeading();
143 
145  virtual double findDesiredSpeed();
146 
148  virtual void moveToDestination();
149 
152  virtual void stop(bool success);
153 
155  virtual void registerTaskMsgCallbacks() override;
156 
160  virtual void processModifyVrfObject(DtSimMessage* msg);
161 
164  virtual void processSetLocation(DtSimMessage* msg);
165 
167  virtual bool createPortGroups() override;
168 
170  virtual bool createPorts() override;
171 
177  virtual bool createPSR();
178 
179  virtual double distanceToDestination() const;
180 
182  virtual void clearTask() override;
183 
185  virtual bool destinationIsInsideObstruction(
186  const DtVector& localDestination) const;
187 
190  virtual bool decideToGiveUpTask() const override;
191 
196  virtual double atDistance() const;
197 
199  virtual bool usingNavBot() const;
200 
202  virtual void useNavBotData();
203 
206  virtual unsigned maxNumFailedPathAttempts() const;
207 
210  virtual bool findAlternateDestination();
211 
213  virtual void setStuck(bool yesNo);
215  virtual double stuckTime();
216 
217  static void navAreaChangedCallback(void* usr);
218  virtual void processNavAreaChanged();
219 
223  DtVector localDestination() const;
224 
225  virtual void updateTaskVisualizations() override;
226 
229  virtual void suspendTask() override;
230 
232  virtual void preFirstTickInit() override;
233 
234  static void setAiEnabledCallback(DtSimMessage* msg, void* usrData);
235  virtual void processSetAiEnabled(DtSimMessage* msg);
236 
237  virtual void processNavigationInterfaceChanged();
238 
240  virtual void processEstimatedTotCalculation();
241 
243  template<typename T_Task>
244  void setCommonTaskParams(const T_Task& task)
245  {
246  myOverrideAtDistance = task.isAtDistanceSpecified();
247  if (myOverrideAtDistance)
248  {
249  myOverrideAtDistanceValue = task.atDistance();
250  }
251  myOverrideSpeed = task.isSpeedSpecified();
252  if (myOverrideSpeed)
253  {
254  myOverrideSpeedValue = task.speed();
255  }
256  }
257 
258  virtual bool currentPathEdge(DtVector& pathEdgeStart, DtVector& pathEdgeEnd) const;
259 
260 protected:
261 
264 
272 
276 
279 
286 
293 
300 
308 
314 
320 
322 
326 
329 
333 
336 
339 
344 
345  //Used to force the navigation interface to be ignored.
346  //This is useful when the nav interface has given us a partial
347  //path to the destination (for example, if we're in a nav area
348  //but our destination is outside the nav area).
349  //Once set, gets reset when any of the following happen:
350  //1) A new task is issued
351  //2) The destination location changes
352  //3) A set location occurs
353  //4) The entity moves to a new navArea.
355 
357 
359 
363  //DtGenericPsr* myHumanMovePsr;
364 
367 
369 
371  const double DtEstimatedTotCalcInterval = 5.0;
372 
381 
383 };
384 
class DtHumanMoveToPSR:
Definition: humanMoveToPSR.h:29
#define DT_DLL_vrfmodel
This file is used to determine how to build.
Definition: vrfmodelDefines.h:24
DtAnalogInputPort * myEtaForLastVertexInputPort
Input Port Name: eta-for-last-vertex Input Port Description: Specifies the eta for the last vertex of...
Definition: humanMoveToController.h:313
bool myIgnoreNavData
Definition: humanMoveToController.h:354
virtual void suspendTask()
This method is called when the currently running task is being suspended. The default implementation ...
DtHumanMovementControlOutputPortGroup * myHumanMovementControlOutputPortGroup
Output Group Name: movement-control .
Definition: humanMoveToController.h:278
DtHumanStateRepository * myHumanStateRepository
Definition: humanMoveToController.h:358
Description: This repository holds all information that is common to all the forms of humans within t...
Definition: humanStateRepository.h:33
virtual const char * type() const override=0
Returns a string identifies the class type of component. Type values are defined in compTypes...
This is the DtVrfObjectNavInterface subclass for objects which are actively querying the navigation s...
Definition: activeBotNavInterface.h:27
Instances of DtBooleanOutputPort are output ports through which data producers can send boolean data...
Definition: boolIOPort.h:45
virtual void registerTaskMsgCallbacks()
virtual void preFirstTickInit()
This function can be overridden to initialize a component before it is ticked for the first time...
double myEstimatedTotLastCalcTime
used for tot calculation intervals
Definition: humanMoveToController.h:378
This class provides a base class for all controllers that are capable of executing a DtSimTask...
Definition: singleTaskControllerComponent.h:22
DtVector myIntermediateLocalDestination
Definition: humanMoveToController.h:332
The DtSimObjectReference is a shared pointer that can be used amongst many object for access to the u...
Definition: simObjectReference.h:26
A readable, writable type whose name is the name of a component and that has a list of component name...
Definition: componentDescriptor.h:49
Definition: readerWriterRegistry.h:39
DtVector myLocalDestination
Definition: humanMoveToController.h:327
DtHumanLocalObjectFacade myHumanLocalObjectFacade
Definition: humanMoveToController.h:382
bool myDestinationVectorIsValid
Definition: humanMoveToController.h:335
Contains class declarations for DtVectorInputPort, DtVectorOutputPort, and DtVectorPortData.
Definition: vectorIOPort.h:27
virtual void updateTaskVisualizations()
Called to update task visualizations after every tick. Implemented by subclasses. ...
Definition: simComponent.h:437
DtBooleanOutputPort * myUseCollisionAvoidancePort
Output Port Name: use-collision-avoidance Output Port Description: Indicates whether or not this cont...
Definition: humanMoveToController.h:299
virtual bool init() override
Calls setRadio()
DtHumanMoveToPSR * myProcessState
Container for state data associated with this component. This state is saved and restored as part of ...
Definition: humanMoveToController.h:362
DtVectorInputPort * myLastVertexLocationInputPort
Input Port Name: last-vertex-location Input Port Description: Specifies the last vertex location of t...
Definition: humanMoveToController.h:307
void registerDtHumanMoveToController(DtCgf *cgf)
Registers component and associated classes with the factories. Call after DtVrfApp::init() ...
bool myEstimatedTotCalcEnabled
enabled flag for the tot calculations
Definition: humanMoveToController.h:374
DtInputPortGroup * myCollisionAvoidancePortGroup
Input Port Group Name: collision-avoidance-control Input Port Group Description:
Definition: humanMoveToController.h:275
DtVector myIntermediateWorldDestination
Definition: humanMoveToController.h:331
Instances of DtAnalogOutputPort are input ports through which data producers can send real numbers...
Definition: analogIOPort.h:45
Instances of DtVectorOutputPort are output ports through which data producers can send a DtVector...
Definition: vectorIOPort.h:52
File: simMsg.h.
Definition: simMessage.h:35
DtAnalogOutputPort * myEtaToLastVertexOutputPort
Output Port Name: eta-to-last-vertex Output Port Description: Specifies the eta to reach the last ver...
Definition: humanMoveToController.h:319
virtual void tick()
This gives the thread of control to the component. The component is ticked once each simulation from ...
DtActiveBotNavInterface * myNavInterface
Definition: humanMoveToController.h:366
DtVectorOutputPort * myDestinationOutputPort
Output Port Name: destination Output Port Description: Specifies the current destination of the entit...
Definition: humanMoveToController.h:285
DtCollisionInputPort * myCollisionAvoidancePort
Input Port Name: potential-collision-info Input Port Description: information about an impending pote...
Definition: humanMoveToController.h:271
double myDistanceSquared
Definition: humanMoveToController.h:338
DtVector myWorldDestination
Definition: humanMoveToController.h:328
DtHumanMoveToControllerDescriptor; descriptor for the DtHumanMoveToControllerDescriptor component...
Definition: humanMoveToControllerDescriptor.h:23
virtual bool createPorts()
Called by init. Derived classes should override this method to create all their input/output ports an...
bool myOverrideAtDistance
Definition: humanMoveToController.h:340
virtual bool decideToGiveUpTask() const
This function is used to determine if the controller should give up trying to execute the current tas...
double myEstimatedTotValue
the tot value
Definition: humanMoveToController.h:376
virtual bool createPortGroups()
Called by init. Derived classes should override this method to create all their input/output port gro...
DtSimObjectReference myControlPoint
This is looked up once per tick - assumed unchanging while we have control.
Definition: humanMoveToController.h:325
Central access point of all non-object-specific the services and managers that are available for use ...
Definition: simulationServices.h:95
The DtSimComponent class is the base class for the entire simulation model component hierarchy...
Definition: simComponent.h:91
const DtTaskControllerComponent & operator=(const DtTaskControllerComponent &orig)
assignment operator
DtBooleanOutputPort * myIsMovingPort
Output Port Name: is-moving Output Port Description: Indicates the entity is being actively moved by ...
Definition: humanMoveToController.h:292
DtHumanMoveToControllerDescriptor * myHumanMoveToControllerDescriptor
Definition: humanMoveToController.h:365
bool myAtDestination
Definition: humanMoveToController.h:337
virtual void clearTask() override
If component is currently tasked, calls clearPendingSubtasks(), sets the tasked flag to false...
DtInputPortGroup is a data port group of a data consumer. It may contain any number of DtInputPorts a...
Definition: inputPortGroup.h:35
Instances of DtCollisionInputPort are input ports through which data consumers can receive informatio...
Definition: collisionIOPort.h:29
DtHumanMoveToController is a controller that models movement to a &lt;location&gt; or &lt;waypoint&gt; for indivi...
Definition: humanMoveToController.h:42
Contains class declarations for DtAnalogInputPort, DtAnalogOutputPort, and DtAnalogPortData.
Definition: analogIOPort.h:25
A DtVrfProcessStateRepository subclass that keeps an arbitrary key/value pair set of data...
Definition: genericPsr.h:17
unsigned myNumFailedPathAttempts
Definition: humanMoveToController.h:356
void processSetLocation(DtSetDataRequest *set, const DtVertexList &vertices, double position, DtMoveAlongRouteTimeEstimator *est)
An output port group that contains the ports necessary to control the movement of a human using the D...
Definition: humanMovementControlOutputPortGroup.h:22
bool myHasIntermediateDestination
Definition: humanMoveToController.h:330
bool myAIEnabled
Definition: humanMoveToController.h:368
The top level class of a VR-Forces Simulation Engine, representing a Computer Generated Forces instan...
Definition: cgf.h:147
DtVector myEstimatedTotTextPos
tot text position
Definition: humanMoveToController.h:380
void setCommonTaskParams(const T_Task &task)
Template function to handle a number of tasks that all have a common set of parameters.
Definition: humanMoveToController.h:244
DtVector myDestinationVector
Definition: humanMoveToController.h:334
double myOverrideAtDistanceValue
Definition: humanMoveToController.h:341
bool myOverrideSpeed
Definition: humanMoveToController.h:342
double myOverrideSpeedValue
Definition: humanMoveToController.h:343
A locally simulated VRF object. Holds all internal and external data for the object, and provides access to both the current frame and next frame state data for the object. All current frame data is read-only, and next-frame data can be written to. No thread safety guarantees are made on this object during the simulation frame and it should only be accessed by the thread that is simulating the object.
Definition: localObject.h:86

Document ID: Generated on Tue Sep 24 19:28:17 EDT 2024 from SVN revision 269799
Copyright © 2005-2024 MAK Technologies. All Rights Reserved (www.mak.com)