VR-Engage  2.2
Loading...
Searching...
No Matches
makVre::DtDriverControlLogic Class Reference

Detailed Description

The DtDriverControlLogic provides functionality for controlling various aspects of ground vehicles. This includes basic driving controls (steering, throttle, braking), transmission controls (gear shifting), and auxiliary systems (engine, differential lock, parking brake, headlights, pivot steering, and towing hook).

It also maintains vehicle state information through attributes and handles resource updates for systems like fuel levels and towing targets.

#include <driverControlLogic.h>

Inheritance diagram for makVre::DtDriverControlLogic:
[legend]

Public Member Functions

 DtDriverControlLogic ()
 
virtual ~DtDriverControlLogic () override
 
virtual bool initialize (makVre::DtPlayerStation *player, makVre::DtInitTable &config) override
 
virtual void tick (double dt) override
 
virtual void shutdown () override
 
virtual const char * type () const override
 
virtual void sendJoystickMessage (const std::string &function, double val, double delay=0)
 
virtual void steerLeft (float val)
 
virtual void steerRight (float val)
 
virtual void setSteering (double val)
 
virtual void setThrottle (double val)
 
virtual void setBrake (double val)
 
virtual void setGearUp (double val)
 
virtual void setGearDown (double val)
 
virtual void setEngineEnable (double val)
 
virtual void setDifferentialLock (double val)
 
virtual void setParkingBrake (double val)
 
virtual void setHeadlights (double val)
 
virtual void setPivot (double val)
 
virtual void setHook (double val)
 
- Public Member Functions inherited from makVre::DtEntityControlLogic
 DtEntityControlLogic ()
 
virtual ~DtEntityControlLogic () override
 
virtual bool postInitialize () override
 
virtual void setExtendedData (const std::string &key, const std::string &value, DtEntityIdentifier entity=DtEntityIdentifier::nullId())
 
virtual void setMouseControlEnabled (bool enabled)
 
virtual bool isMouseControlEnabled ()
 
virtual bool isMouseControlSupportAllowed () const
 
virtual void setMouseControlSupportAllowed (bool enable)
 
virtual const std::vector< std::string > & joystickGroups () const
 
virtual makVre::DtVreMessageResult handleSimState (makVre::DtVreMessage *msg)
 
virtual makVre::DtVreMessageResult handleStateMessages (makVre::DtVreMessage *message)
 
virtual makVre::DtVreMessageResult handleReset (makVre::DtVreMessage *message)
 
virtual void reset (float val)
 
virtual void resetInPlace (float val)
 
virtual void toggleMouseControl (float val)
 
virtual void enableMouseControl (float val)
 
virtual makVre::DtVreMessageResult handleFocusMessage (makVre::DtVreMessage *message)
 
- Public Member Functions inherited from makVre::DtPlayerComponent
 DtPlayerComponent ()
 
virtual ~DtPlayerComponent ()
 
virtual void setName (const std::string &name)
 
virtual const std::string & name ()
 
virtual DtPlayerStationplayer ()
 
virtual DtAttributeHandleplayerAttributeStore ()
 
virtual const DtAttributeHandleplayerAttributeStore () const
 

Protected Member Functions

virtual makVre::DtVreMessageResult handleResourceUpdate (makVre::DtVreMessage *msg)
 
virtual void onHookTargetUuidChanged (const std::string &hookTargetUuid)
 
- Protected Member Functions inherited from makVre::DtEntityControlLogic
virtual void takeControlOfPlayerEntity ()
 
virtual void releaseControlOfPlayerEntity ()
 
- Protected Member Functions inherited from makVre::DtPlayerComponent
virtual void initializeStateAttributes ()
 

Protected Attributes

std::string myMarkingText
 
DtInputLogic myDriverInputLogic
 
std::string myMainJoystickGroup
 
bool myCanPivot
 
bool myHasDifferentialLock
 
bool myHasTowHook
 
bool myShowInclinometer
 
- Protected Attributes inherited from makVre::DtEntityControlLogic
std::vector< std::string > myJoystickFunctionGroups
 
DtInputLogic myCommonInputLogic
 
std::string myInputConfigFile
 
bool myMouseControlEnabled
 
bool myMouseControlSupportAllowed
 
- Protected Attributes inherited from makVre::DtPlayerComponent
std::string myName
 
DtInitTable myConfig
 
DtPlayerStationmyPlayer
 
makVrv::DtDe * myDe
 
DtEntityResolvermyResolver
 
DtAttributeCallbackManager myAttributeCallbacks
 

Constructor & Destructor Documentation

◆ DtDriverControlLogic()

makVre::DtDriverControlLogic::DtDriverControlLogic ( )

Constructor for DtDriverControlLogic.

Initializes the component with default values and checks out the required VR Engage Ground license.

◆ ~DtDriverControlLogic()

virtual makVre::DtDriverControlLogic::~DtDriverControlLogic ( )
overridevirtual

Virtual destructor for DtDriverControlLogic.

Member Function Documentation

◆ initialize()

virtual bool makVre::DtDriverControlLogic::initialize ( makVre::DtPlayerStation * player,
makVre::DtInitTable & config )
overridevirtual

Initializes the component with configuration from Lua.

Sets up input handlers, initializes state attributes, and subscribes to resource updates. Configures vehicle capabilities based on Lua settings (differential lock, pivot steering, and tow hook availability).

Parameters
playerPointer to the player station this component belongs to
configConfiguration table containing initialization parameters
Returns
True if initialization succeeds, false otherwise

Reimplemented from makVre::DtEntityControlLogic.

References makVre::DtPlayerComponent::player().

◆ tick()

virtual void makVre::DtDriverControlLogic::tick ( double dt)
overridevirtual

Updates the component state.

Updates the headlight state attribute based on the vehicle's current appearance.

Parameters
dtDelta time in seconds since the last tick

Reimplemented from makVre::DtEntityControlLogic.

◆ shutdown()

virtual void makVre::DtDriverControlLogic::shutdown ( )
overridevirtual

Shuts down the component.

Unsubscribes from resource updates, removes callbacks, and cleans up input handlers.

Reimplemented from makVre::DtEntityControlLogic.

◆ type()

virtual const char * makVre::DtDriverControlLogic::type ( ) const
overridevirtual

Returns the component type identifier.

Returns
The component type string

Reimplemented from makVre::DtEntityControlLogic.

◆ steerLeft()

virtual void makVre::DtDriverControlLogic::steerLeft ( float val)
virtual

Input handler functions.

Handles left steering input

Inverts the value and passes it to setSteering().

Parameters
valThe input value, typically from 0.0 to 1.0

◆ steerRight()

virtual void makVre::DtDriverControlLogic::steerRight ( float val)
virtual

Handles right steering input.

Passes the value directly to setSteering().

Parameters
valThe input value, typically from 0.0 to 1.0

◆ setSteering()

virtual void makVre::DtDriverControlLogic::setSteering ( double val)
virtual

Sets the vehicle's steering value.

Sends a "Steering" joystick message with the provided value.

Parameters
valThe steering value, from -1.0 (full left) to 1.0 (full right)

◆ setThrottle()

virtual void makVre::DtDriverControlLogic::setThrottle ( double val)
virtual

Sets the vehicle's throttle value.

Sends a "Throttle" joystick message with the provided value.

Parameters
valThe throttle value, typically from 0.0 to 1.0

◆ setBrake()

virtual void makVre::DtDriverControlLogic::setBrake ( double val)
virtual

Sets the vehicle's brake value.

Sends a "Brake" joystick message with the provided value.

Parameters
valThe brake value, typically from 0.0 to 1.0

◆ setGearUp()

virtual void makVre::DtDriverControlLogic::setGearUp ( double val)
virtual

Shifts up to the next gear.

Sends a "GearUp" joystick message with the provided value.

Parameters
valThe input value, a value of 1.0 triggers the gear shift

◆ setGearDown()

virtual void makVre::DtDriverControlLogic::setGearDown ( double val)
virtual

Shifts down to the previous gear.

Sends a "GearDown" joystick message with the provided value.

Parameters
valThe input value, a value of 1.0 triggers the gear shift

◆ setEngineEnable()

virtual void makVre::DtDriverControlLogic::setEngineEnable ( double val)
virtual

Toggles the engine on/off.

Sends an "EngineEnable" joystick message with the provided value.

Parameters
valThe input value, a value of 1.0 typically toggles the engine state

◆ setDifferentialLock()

virtual void makVre::DtDriverControlLogic::setDifferentialLock ( double val)
virtual

Toggles the differential lock.

Sends a "DifferentialLock" joystick message with the provided value. Only applies to vehicles with differential lock capability.

Parameters
valThe input value, a value of 1.0 typically toggles the differential lock

◆ setParkingBrake()

virtual void makVre::DtDriverControlLogic::setParkingBrake ( double val)
virtual

Toggles the parking brake.

Sends a "ParkingBrake" joystick message with the provided value.

Parameters
valThe input value, a value of 1.0 typically toggles the parking brake

◆ setHeadlights()

virtual void makVre::DtDriverControlLogic::setHeadlights ( double val)
virtual

Toggles the headlights.

Sends a "Headlights" joystick message with the provided value.

Parameters
valThe input value, a value of 1.0 typically toggles the headlights

◆ setPivot()

virtual void makVre::DtDriverControlLogic::setPivot ( double val)
virtual

Controls pivot steering.

Sends a "Pivot" joystick message with the provided value. Only applies to vehicles with pivot steering capability.

Parameters
valThe input value

◆ setHook()

virtual void makVre::DtDriverControlLogic::setHook ( double val)
virtual

Controls the towing hook.

Sends a "Hook" joystick message with the provided value. Only applies to vehicles with towing hook capability.

Parameters
valThe input value, typically toggles hook engagement

◆ sendJoystickMessage()

virtual void makVre::DtDriverControlLogic::sendJoystickMessage ( const std::string & function,
double val,
double delay = 0 )
virtual

Sends a joystick message to the simulation.

Helper function called by the various control functions to send joystick messages with the appropriate parameters.

Parameters
functionThe function name to include in the message
valThe function value to include in the message
delayOptional delay before sending the message (defaults to 0)

◆ handleResourceUpdate()

virtual makVre::DtVreMessageResult makVre::DtDriverControlLogic::handleResourceUpdate ( makVre::DtVreMessage * msg)
protectedvirtual

Handles resource update messages.

Processes resource updates, particularly for fuel levels. Updates the "fuel" state attribute with the current amount.

Parameters
msgThe resource update message to process
Returns
HANDLED if the message was processed

◆ onHookTargetUuidChanged()

virtual void makVre::DtDriverControlLogic::onHookTargetUuidChanged ( const std::string & hookTargetUuid)
protectedvirtual

Callback for changes to the hook target UUID.

When a nearby towing target is found, its entity ID (UUID) is published. This callback updates the "hasHookTarget" and "hook-target-marking-text" state attributes accordingly.

Parameters
hookTargetUuidThe UUID of the potential hook target

Member Data Documentation

◆ myMarkingText

std::string makVre::DtDriverControlLogic::myMarkingText
protected

Marking text for the current entity used in resource subscription.

◆ myDriverInputLogic

DtInputLogic makVre::DtDriverControlLogic::myDriverInputLogic
protected

Input handler logic for processing input device events.

◆ myMainJoystickGroup

std::string makVre::DtDriverControlLogic::myMainJoystickGroup
protected

Main joystick function group name from configuration.

Used to identify the function group when sending joystick messages.

◆ myCanPivot

bool makVre::DtDriverControlLogic::myCanPivot
protected

Flag indicating if this vehicle is capable of pivot steering.

When true, enables pivot steering functionality. This value is stored in the "canPivot" state attribute. Defaults to false.

◆ myHasDifferentialLock

bool makVre::DtDriverControlLogic::myHasDifferentialLock
protected

Flag indicating if this vehicle has a differential lock.

When true, enables differential lock functionality. This value is stored in the "hasDifferentialLock" state attribute. Defaults to false.

◆ myHasTowHook

bool makVre::DtDriverControlLogic::myHasTowHook
protected

Flag indicating if this vehicle has a tow hook.

When true, enables towing hook functionality. This value is stored in the "hasTowHook" state attribute. Defaults to false.

◆ myShowInclinometer

bool makVre::DtDriverControlLogic::myShowInclinometer
protected

The documentation for this class was generated from the following file: