VR-Forces 4.8 Class Documentation
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
List of all members | Public Member Functions | Protected Member Functions | Protected Attributes | Private Member Functions
DtRoadMovementUpdater Class Reference

Models an entity moving along a generated road path. More...

Public Member Functions

 DtRoadMovementUpdater (DtRoadMovementController *parentController, bool useHighGroundClamp, const DtAttachedTerrain *attachedTerrain)
 Pass in the parent controller so we have access to our path and where we are in our path. More...
 
virtual ~DtRoadMovementUpdater ()
 destructor More...
 
virtual void updateRailAndWorldPosition (DtRoadSegment *currentSeg, double newAccel, double dT, double simTime=0.0)
 Updates the vehicle position this tick given the past speed and acceleration along the lane. More...
 
virtual void updateNoMovement ()
 Sets the movement state of the entity to stopped. More...
 
virtual void updateFromPSR (const DtVector localPos, DtRailSegment *currentSeg)
 If loading in from a scenario saved out during a rail task, chances are the entity is not at the start of rail so update from its saved location on the current segment. More...
 
Class Admin Functions
virtual bool init ()
 
virtual void clear ()
 
virtual void setEntityState (DtVrfMovingObjectStateRepository *state)
 
virtual void setPSR (DtRailMovementControllerPSR *psr)
 
virtual void movementComplete ()
 Called when movement is complete. More...
 

Protected Member Functions

virtual void kinematicUpdate (const double oldSpeed, const double accel, const double dt, double &deltaPosition, double &newSpeed, double &actualAccel)
 Takes a scalar acceleration and speed and computes a new speed and a delta position. More...
 
virtual void doKinematicUpdateAlongRail (const double dt, DtRoadSegment *currentSeg, const int roadLaneNum, const double oldPositionInLane, const double oldSpeed, double &accel, double &newPositionInLane, double &newLateralOffset, double &laneChangeHeadingOffset, double &newSpeed, double &newRotationRate)
 Does a kinematic update to compute the new position along the "rail" defined by the given segment and lane number. More...
 
virtual void computePositionInDownstreamSegment (DtRoadSegment *&currentSeg, int &roadLaneNum, double &newPositionInLane, const double newLateralOffset, double &segmentCurveHeadingOffset, DtVector &localPosition, int &segmentIndex)
 This function takes the given road segment, lane number, and position in the lane, and determines if the position is beyond the end of the lane. More...
 
virtual void updateLateralOffset (const double currentOffset, const double distanceBetweenLanes, const double speed, const double xMove, double &newLateralOffset, double &newHeadingOffset, double &headingChangeRate)
 Updates the lateral offset during a lane change maneuver. More...
 
virtual void updatePsrWithNewState (const int roadLaneNum, const bool isSwitchingLanes, const int roadSegmentIndex, const double positionInLane, double lateralOffset, const double newSpeed, const double newAccel, DtRoadSegment *currentSegment)
 Given the road position, update fields in the PSR: destinationLaneNumber, currentMovementState, currentLaneNumber, positionAlongLane, segmentIndex, offsetFromLaneCenterline, speedAlongLane. More...
 
virtual void computeBodyMotionVectors (const double speed, const double accel, const double turnRate, const double dt, DtVector &bodyVelocity, DtVector &bodyAcceleration)
 Sets the body velocity vectors from the speed, acceleration, and turn rate. More...
 
virtual void computeRepositoryUpdateVariables (const DtVector &newLocalPosition, const DtVector &newBodyVelocity, const DtVector &newBodyAcceleration, const DtDcm &newLocalOrientation, const double newRotationRate, DtVector &newRelativeVelocity, DtVector &newRelativeAcceleration, DtTaitBryan &newLocalOrientationTb, DtVector &newBodyRotationalVelocity)
 Computes the relative velocity and acceleration vectors, and the Tait Bryan orientation and the body rotational velocity vector from body state provided as input. More...
 
virtual void useFuel (double fuelUsed)
 Looks up the resource named “fuel” in the entity’s Resource Manager. More...
 
virtual bool isEntityImmobilized ()
 
virtual double fuelLeft () const
 Looks up the resource named “fuel” in the entity’s Resource Manager. More...
 
virtual void updateRepository (const DtVector &localPosition, const DtVector &localVelocity, const DtVector &localAcceleration, const DtTaitBryan &localOrientation, const DtVector &rotationalVelocity, double newHeading)
 Updates the local state repository: It places the position, velocity, acceleration, and orientation arguments into the local repository. More...
 
virtual void calculateOrientationAndPosition (const DtVector &newLocalProjectedLocation, const double newHeading, DtDcm &newLocalOrientation, DtVector &newLocalPosition)
 Calculates the orientation and position of the entity, given a new location and heading. More...
 
virtual void calculateOriginLocation (const DtVector &turnCenterLocation, const double heading, DtVector &originLocation)
 Computes the origin location from the turn center location. More...
 
bool groundClamp (const double heading, const DtVector &location, DtAttachedTerrain &terrain, DtVector &newNormal)
 Clamps the entity to the ground at the specified location, and determines the normal of the plane the entity is on at that location. More...
 
void groundClampHighFidelity (const double heading, const DtVector &location, DtAttachedTerrain &terrain, DtVector &newNormal)
 Uses all four ground interaction points to determine the plane of the entity and the soil type. More...
 
void groundClampLowFidelity (const double heading, const DtVector &location, DtAttachedTerrain &terrain, DtVector &newNormal)
 Uses only the center ground interaction point. More...
 

Protected Attributes

DtRoadMovementControllermyController
 
DtVrfMovingObjectStateRepositorymyMovingStateRep
 
DtRailMovementControllerPSRmyRailMovementPSR
 
const DtAttachedTerrainmyAttachedTerrain
 Used to ground clamp the entity– TODO how we ground clamp, ie get access to terrain may change, we might want to instead just point to the physical world. More...
 
bool myUseHighFidelityGroundClamping
 
bool myDrivingOnLeft
 
DtUpdateRepositoryOutputPortGroupmyUpdateRepositoryOutputPortGroup
 Port group used to set what values should be set into the VRF state repository. More...
 
bool myWarnedAboutImmobilizedOnce
 To warn user about new immobilization just once. More...
 

Private Member Functions

 DtRoadMovementUpdater ()
 Default constructor; not implemented. More...
 
 DtRoadMovementUpdater (const DtRoadMovementUpdater &orig)
 Copy constructor; not implemented. More...
 
const DtRoadMovementUpdateroperator= (const DtRoadMovementUpdater &orig)
 assignment operator; not implemented More...
 

Detailed Description

Models an entity moving along a generated road path.

Provides a kinematics-based model of an entity moving along a generated path or route in a fashion where it is locked onto the the path. DtRoadSegment is the class that represents the segment of the path which has various attributes which will help the entity determine how it will follow along the segment such as the speed and heading the entity will follow along the segment.

Uses Descriptor Type: DtComponentDescriptor

Constructor & Destructor Documentation

DtRoadMovementUpdater::DtRoadMovementUpdater ( DtRoadMovementController parentController,
bool  useHighGroundClamp,
const DtAttachedTerrain attachedTerrain 
)

Pass in the parent controller so we have access to our path and where we are in our path.

virtual DtRoadMovementUpdater::~DtRoadMovementUpdater ( )
virtual

destructor

DtRoadMovementUpdater::DtRoadMovementUpdater ( )
private

Default constructor; not implemented.

DtRoadMovementUpdater::DtRoadMovementUpdater ( const DtRoadMovementUpdater orig)
private

Copy constructor; not implemented.

Member Function Documentation

virtual bool DtRoadMovementUpdater::init ( )
virtual
virtual void DtRoadMovementUpdater::clear ( )
virtual
virtual void DtRoadMovementUpdater::setEntityState ( DtVrfMovingObjectStateRepository state)
virtual
virtual void DtRoadMovementUpdater::setPSR ( DtRailMovementControllerPSR psr)
virtual
virtual void DtRoadMovementUpdater::movementComplete ( )
virtual

Called when movement is complete.

virtual void DtRoadMovementUpdater::updateRailAndWorldPosition ( DtRoadSegment currentSeg,
double  newAccel,
double  dT,
double  simTime = 0.0 
)
virtual

Updates the vehicle position this tick given the past speed and acceleration along the lane.

Calls kinematicUpdate() and updateLateralOffset(). Implicitly uses the PSR, which has state for position along lane centerline, lateral offset, current lane N, is-passing, and destination lane N. Uses design driver lateral acceleration limit defined in DtRoadConstants.

Parameters
simTimeis not used except for debugging.
virtual void DtRoadMovementUpdater::updateNoMovement ( )
virtual

Sets the movement state of the entity to stopped.

Call in place of updateRailAndWorldPosition.

virtual void DtRoadMovementUpdater::updateFromPSR ( const DtVector  localPos,
DtRailSegment currentSeg 
)
virtual

If loading in from a scenario saved out during a rail task, chances are the entity is not at the start of rail so update from its saved location on the current segment.

virtual void DtRoadMovementUpdater::kinematicUpdate ( const double  oldSpeed,
const double  accel,
const double  dt,
double deltaPosition,
double newSpeed,
double actualAccel 
)
protectedvirtual

Takes a scalar acceleration and speed and computes a new speed and a delta position.

Limits the speed to be between 0 and the entity max speed, and adjusts the acceleration to match. Outputs the position, limited speed, and adjusted acceleration.

virtual void DtRoadMovementUpdater::doKinematicUpdateAlongRail ( const double  dt,
DtRoadSegment currentSeg,
const int  roadLaneNum,
const double  oldPositionInLane,
const double  oldSpeed,
double accel,
double newPositionInLane,
double newLateralOffset,
double laneChangeHeadingOffset,
double newSpeed,
double newRotationRate 
)
protectedvirtual

Does a kinematic update to compute the new position along the "rail" defined by the given segment and lane number.

(Lane number is 0-based). Also uses PSR members offsetFromLaneCenter() and laneChangeWidth(). Updates the following state:
longitudinal position along lane,
lateral offset from centerline (from lane change maneuver),
orientation offset from the centerline (from lane change maneuver),
rotation rate (from lane change maneuver and lane curvature).
Acceleration is an input, but may be updated if the speed exceeds either 0 or entity max speed in this tick, and so is clamped.
Note that if myDrivingOnLeft is true, the newRotationRate and laneChangeHeadingOffset will be mirror images, relative to the line between the start and end of the segment, of the normal values.
Called in updateRailAndWorldPosition.

virtual void DtRoadMovementUpdater::computePositionInDownstreamSegment ( DtRoadSegment *&  currentSeg,
int roadLaneNum,
double newPositionInLane,
const double  newLateralOffset,
double segmentCurveHeadingOffset,
DtVector localPosition,
int segmentIndex 
)
protectedvirtual

This function takes the given road segment, lane number, and position in the lane, and determines if the position is beyond the end of the lane.

If it is, then it finds the road segment and lane number that this one connects to and computes the position in that lane (and if the position is beyond that segment, it keeps going forward until it finds the correct segment). Once the correct segment is found, the function computes the position (database coordinates) corresponding to the segment/lane/lane-position and the heading offset from segment heading (i.e. if on a curve). The segment, segment index, lane number, and position in lane are also updated if the position is on a new segment.
Note that if myDrivingOnLeft is true, the localPosition and segmentCurveHeadingOffset will be mirror images, relative to the line between the start and end of the segment, of the normal values.
Called in updateRailAndWorldPosition.

virtual void DtRoadMovementUpdater::updateLateralOffset ( const double  currentOffset,
const double  distanceBetweenLanes,
const double  speed,
const double  xMove,
double newLateralOffset,
double newHeadingOffset,
double headingChangeRate 
)
protectedvirtual

Updates the lateral offset during a lane change maneuver.

The maneuver is assumed to be a double circular arc maneuver at a radius corresponding to the design driver lateral acceleration limit, or the vehicle turn radius at minimum. When a lane change is started, the current lane is immediately changed to the target lane, and a lane offset is computed that corresponds to the lateral distance to the old lane. In future ticks, the function slowly decreases the offset distance to zero.

Parameters
currentOffsetis the current lateral offset from the old lane, with positive being to the right and negative being to the left.
distanceBetweenLanesis the (perpendicular) distance between the centerlines of the lanes. This is always positive.
speedis the new speed of the vehicle;
xMoveis the distance along the lane that the vehicle moved
newLateralOffsetis the output lateral offset
newHeadingOffsetis an output; the offset heading of the new location due to lane changing.
newRotationRateis the heading change rate caused by the lane change maneuver.
virtual void DtRoadMovementUpdater::updatePsrWithNewState ( const int  roadLaneNum,
const bool  isSwitchingLanes,
const int  roadSegmentIndex,
const double  positionInLane,
double  lateralOffset,
const double  newSpeed,
const double  newAccel,
DtRoadSegment currentSegment 
)
protectedvirtual

Given the road position, update fields in the PSR: destinationLaneNumber, currentMovementState, currentLaneNumber, positionAlongLane, segmentIndex, offsetFromLaneCenterline, speedAlongLane.

Also controller->currentRoadSegment. Called in updateRailAndWorldPosition.

virtual void DtRoadMovementUpdater::computeBodyMotionVectors ( const double  speed,
const double  accel,
const double  turnRate,
const double  dt,
DtVector bodyVelocity,
DtVector bodyAcceleration 
)
protectedvirtual

Sets the body velocity vectors from the speed, acceleration, and turn rate.

The output vectors describe the motion of the entity origin. If there is an offset from the origin to the vehicle turn center (rear axle), the (tangent) velocity on a curve is not just in the x direction; it gets a y component to make it tangent to the turn curve. Acceleration is linear acceleration plus centripetal, where centripetal is perpendicular to the tangent velocity. Uses myController->turnCenterOffset.

virtual void DtRoadMovementUpdater::computeRepositoryUpdateVariables ( const DtVector newLocalPosition,
const DtVector newBodyVelocity,
const DtVector newBodyAcceleration,
const DtDcm &  newLocalOrientation,
const double  newRotationRate,
DtVector newRelativeVelocity,
DtVector newRelativeAcceleration,
DtTaitBryan &  newLocalOrientationTb,
DtVector newBodyRotationalVelocity 
)
protectedvirtual

Computes the relative velocity and acceleration vectors, and the Tait Bryan orientation and the body rotational velocity vector from body state provided as input.

Local position is not used in this base implementation. Called in updateRailAndWorldPosition.

virtual void DtRoadMovementUpdater::useFuel ( double  fuelUsed)
protectedvirtual

Looks up the resource named “fuel” in the entity’s Resource Manager.

If the resource is not found, useFuel() just returns. If the resource is found, the amount of fuel passed as the argument to useFuel() is deducted from the resource. When the resource reaches 0, a warning is printed (using DtWarn).

Parameters
fuelUsedAmount of fuel to deplete.
virtual bool DtRoadMovementUpdater::isEntityImmobilized ( )
protectedvirtual
virtual double DtRoadMovementUpdater::fuelLeft ( ) const
protectedvirtual

Looks up the resource named “fuel” in the entity’s Resource Manager.

If the resource is not found, it returns an appropriately large constant to implement unlimited fuel. Otherwise, the value of the resource is returned.

Returns
Amount of fuel resource still available.
virtual void DtRoadMovementUpdater::updateRepository ( const DtVector localPosition,
const DtVector localVelocity,
const DtVector localAcceleration,
const DtTaitBryan &  localOrientation,
const DtVector rotationalVelocity,
double  newHeading 
)
protectedvirtual

Updates the local state repository: It places the position, velocity, acceleration, and orientation arguments into the local repository.

It puts the heading into the repository. It calculates the current speed from the velocity vector passed and sets that value in the local repository. It calculates the distance traveled this frame (speed * dT) and uses that and the fuel consumption ground vehicle parameter to determine the fuel used, and then calls useFuel().

Parameters
localPositionPosition in local (database) coordinates in meters.
localVelocityVelocity in local (database) coordinates in meters/second.
localVelocityVelocity in local (database) coordinates in meters/second/second.
localOrientationLocal orientation of entity in radians.
rotationalVelocityIn radians/second.
newHeadingIn radians.
virtual void DtRoadMovementUpdater::calculateOrientationAndPosition ( const DtVector newLocalProjectedLocation,
const double  newHeading,
DtDcm &  newLocalOrientation,
DtVector newLocalPosition 
)
protectedvirtual

Calculates the orientation and position of the entity, given a new location and heading.

Checks for intersections with the terrain, to determine altitude and orientation (from support points) from 1/4 of the height of the entity's bounding volume as a rough approximation of the entity's wheels or treads height.

Parameters
newLocalProjectedLocationis the location of the origin (center of rear axle) of the entity (input).
newHeadingis the heading of the entity (input).
newLocalOrientationis the orientation of the entity after being placed on the ground in the given location (output).
newLocalPositionis the position of the origin of the entity. It may be adjusted a little from the input position in altitude.
Returns
nothing, but sets the specified orientation and position appropriately.
Note
As a side effect, this also fills in the soil type, position, and altitude information of the groundCenter of the vrfObject. This is done through the placePoints() call from the state repository.
If the task parameter use-ground-clamping is set to false, then this function is not called at all, and instead the entity position is determined directly from the road segment, where each road segment is assumed to be planar and whose orientation is determined by the altitude of points on the road. This is much faster than doing the altitude lookups required by this function.
virtual void DtRoadMovementUpdater::calculateOriginLocation ( const DtVector turnCenterLocation,
const double  heading,
DtVector originLocation 
)
protectedvirtual

Computes the origin location from the turn center location.

Uses myController->turnCenterOffset. Ignores roll and pitch.

bool DtRoadMovementUpdater::groundClamp ( const double  heading,
const DtVector location,
DtAttachedTerrain terrain,
DtVector newNormal 
)
protected

Clamps the entity to the ground at the specified location, and determines the normal of the plane the entity is on at that location.

Returns
a boolean indicating success or failure in performing the ground clamping and determining the new normal.
Note
As a side effect of this function, the soil type in the center ground interaction point is set.

The type of ground clamping also depends on the entity's configuration. Either high or low fidelity ground clamping is performed as specified.

See Also
groundClampHighFidelity
groundClampLowFidelity
void DtRoadMovementUpdater::groundClampHighFidelity ( const double  heading,
const DtVector location,
DtAttachedTerrain terrain,
DtVector newNormal 
)
protected

Uses all four ground interaction points to determine the plane of the entity and the soil type.

The left, right, and other support points are used to determine the plane, and the returned normal is the normal to that plane.

void DtRoadMovementUpdater::groundClampLowFidelity ( const double  heading,
const DtVector location,
DtAttachedTerrain terrain,
DtVector newNormal 
)
protected

Uses only the center ground interaction point.

The normal is the normal of the polygon on which the center point sits. And the soil type is also the polygon's. This requires fewer intersection tests with the terrain, but also may return an incorrect normal if the entity is sitting across several polygons.

const DtRoadMovementUpdater& DtRoadMovementUpdater::operator= ( const DtRoadMovementUpdater orig)
private

assignment operator; not implemented

Member Data Documentation

DtRoadMovementController* DtRoadMovementUpdater::myController
protected
DtVrfMovingObjectStateRepository* DtRoadMovementUpdater::myMovingStateRep
protected
DtRailMovementControllerPSR* DtRoadMovementUpdater::myRailMovementPSR
protected
const DtAttachedTerrain* DtRoadMovementUpdater::myAttachedTerrain
protected

Used to ground clamp the entity– TODO how we ground clamp, ie get access to terrain may change, we might want to instead just point to the physical world.

bool DtRoadMovementUpdater::myUseHighFidelityGroundClamping
protected
bool DtRoadMovementUpdater::myDrivingOnLeft
protected
DtUpdateRepositoryOutputPortGroup* DtRoadMovementUpdater::myUpdateRepositoryOutputPortGroup
protected

Port group used to set what values should be set into the VRF state repository.

All values are in local coordinates

bool DtRoadMovementUpdater::myWarnedAboutImmobilizedOnce
protected

To warn user about new immobilization just once.


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

Document ID: Generated on Thu Aug 27 10:56:05 EDT 2020 from SVN revision 217100
Copyright © 2005-2020 MAK Technologies. All Rights Reserved (www.mak.com)