VR-Forces Developer's Guide
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
derivedMoveAlongController.h
Go to the documentation of this file.
1 /*******************************************************************************
2 ** Copyright (c) 2025 MAK Technologies, Inc.
3 ** All rights reserved.
4 *******************************************************************************/
5 
6 //
7 //File: DerivedMoveAlongController.h
8 //
9 //Class: DerivedMoveAlongController
10 //
11 #pragma once
12 
14 
15 //
16 //Class Description: DerivedMoveAlongController
17 //
18 //The purpose of this class is to demonstrate how to check for and handle
19 //a situation in which an entity is unable to carry out a given task behavior.
20 //In this particular example, it extends the DtGroundMoveAlongControllerComponent
21 //with the ability to determine when it should 'give up' trying to reach its
22 //waypoint. The criteria for determining it should give up trying to complete
23 //its task is that it should stop trying after 10 seconds. At that point, it
24 //sends a task complete report, indicating it has finished (although it may be
25 //no where near its destination).
26 //
27 //There are 2 required member functions that this class overrides to implement
28 //the 'give up' behavior:
29 //
30 //decideToGiveUpTask() : This is the function that looks at the current
31 //situation and decides if it should give up. It will be automatically called
32 //immediately following the entity's tick().
33 //
34 //giveUpTask() : This gets called when the decideToGiveUpTask() returns true.
35 //In this example, it calls taskComplete(), which results in a task complete
36 //report being sent and the controller put into a non-tasked state.
37 
39 {
40 public:
41 
42  //constructor
44  DtLocalObject* owner,
46  DtComponentDescriptor* desc = NULL,
47  DtReaderWriterRegistry* parentRegistry = NULL);
48 
49  //destructor
50  virtual ~DerivedMoveAlongController() override;
51 
52  //Override to initialize myTimeToGiveUp member to current time plus 10 seconds.
53  //We'll check this in decideToGiveUp(). Note that this function is only
54  //overridden for this particular time-based criteria for giving up. You would
55  //not in general have to override this to add a 'decide to give up' capability
56  //to a controller.
57  virtual void processMoveAlong(const DtTaskMessage& msg, DtSimTaskStatePtr taskStatePtr) override;
58 
59  //Creates and returns a new DerivedMoveAlongController
60  static DtSimComponent* creator(const DtString& name,
61  DtLocalObject* owner,
62  DtSimulationServices* simManager,
63  DtComponentDescriptor* desc = NULL,
64  DtReaderWriterRegistry* parentRegistry = NULL);
65 
66 protected:
67 
68  //Override to see if we should give up after 10 seconds (checks current
69  //simulation time against myTimeToGiveUp).
70  virtual bool decideToGiveUpTask() const override;
71 
72  //Calls taskComplete(). This will result in a DtTaskComplete report being
73  //sent to whomever issued the task.
74  virtual void giveUpTask() override;
75 
76 private:
77  //Default constructor; should not be called. Here because the compiler
78  //will generate an unprotected one otherwise.
80 
81  //copy constructor; shallow; does not copy the ports.
83  orig);
84 
85  //assignment operator; see comments on copy constructor!
88 
89 protected:
90 
91  //This is the time we decide we want to give up when the entity
92  //is executing a task.
94 };
DtTime myTimeToGiveUp
Definition: derivedMoveAlongController.h:93
DtGroundMoveAlongControllerComponent is a controller that models movement of a ground entity along a ...
Definition: groundMoveAlongControllerComponent.h:25
virtual void giveUpTask() override
Called when controller is tasked and decideToGiveUp() returns true. Base class implementation calls c...
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
std::shared_ptr< DtSimTaskState > DtSimTaskStatePtr
Definition: taskAndTaskStateDefines.h:18
virtual ~DerivedMoveAlongController() override
const DerivedMoveAlongController & operator=(const DerivedMoveAlongController &orig)
virtual void processMoveAlong(const DtTaskMessage &msg, DtSimTaskStatePtr taskStatePtr) override
Central access point of all non-object-specific the services and managers that are available for use ...
Definition: simulationServices.h:96
The DtSimComponent class is the base class for the entire simulation model component hierarchy...
Definition: simComponent.h:89
VRF4API_METHOD const DtSimulationServices * simManager() const
This is the deprecated API that can be used as a reference to migrate 4.X code to 5...
Definition: simComponent.h:583
Definition: derivedMoveAlongController.h:38
virtual DtSymbolString name() const
Accessor for name of this readable/writable object.
A DtTaskMsg is a DtRadioMsg with a pointer to a task. The type of the taskMsg is just the type of the...
Definition: taskMessage.h:21
static DtSimComponent * creator(const DtString &name, DtLocalObject *owner, DtSimulationServices *simManager, DtComponentDescriptor *desc=NULL, DtReaderWriterRegistry *parentRegistry=NULL)
virtual bool decideToGiveUpTask() const override
Checks to see if destination is inside an obstruction. If it is, returns true. Otherwise it returns t...
A locally simulated VRF object.
Definition: localObject.h:98

Document ID: Generated on Thu Oct 23 22:29:17 EDT 2025 from SVN revision 280951
Copyright © 2005-2024 MAK Technologies. All Rights Reserved (www.mak.com)