![]() |
VR-Forces 4.8 Class Documentation
|
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 *¤tSeg, 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 | |
| DtRoadMovementController * | myController |
| DtVrfMovingObjectStateRepository * | myMovingStateRep |
| DtRailMovementControllerPSR * | myRailMovementPSR |
| const DtAttachedTerrain * | myAttachedTerrain |
| 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 |
| DtUpdateRepositoryOutputPortGroup * | myUpdateRepositoryOutputPortGroup |
| 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 DtRoadMovementUpdater & | operator= (const DtRoadMovementUpdater &orig) |
| assignment operator; not implemented More... | |
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
| 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 |
destructor
|
private |
Default constructor; not implemented.
|
private |
Copy constructor; not implemented.
|
virtual |
|
virtual |
|
virtual |
|
virtual |
|
virtual |
Called when movement is complete.
|
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.
| simTime | is not used except for debugging. |
|
virtual |
Sets the movement state of the entity to stopped.
Call in place of updateRailAndWorldPosition.
|
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.
|
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.
|
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.
|
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.
|
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.
| currentOffset | is the current lateral offset from the old lane, with positive being to the right and negative being to the left. |
| distanceBetweenLanes | is the (perpendicular) distance between the centerlines of the lanes. This is always positive. |
| speed | is the new speed of the vehicle; |
| xMove | is the distance along the lane that the vehicle moved |
| newLateralOffset | is the output lateral offset |
| newHeadingOffset | is an output; the offset heading of the new location due to lane changing. |
| newRotationRate | is the heading change rate caused by the lane change maneuver. |
|
protectedvirtual |
Given the road position, update fields in the PSR: destinationLaneNumber, currentMovementState, currentLaneNumber, positionAlongLane, segmentIndex, offsetFromLaneCenterline, speedAlongLane.
Also controller->currentRoadSegment. Called in updateRailAndWorldPosition.
|
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.
|
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.
|
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).
| fuelUsed | Amount of fuel to deplete. |
|
protectedvirtual |
|
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.
|
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().
| localPosition | Position in local (database) coordinates in meters. |
| localVelocity | Velocity in local (database) coordinates in meters/second. |
| localVelocity | Velocity in local (database) coordinates in meters/second/second. |
| localOrientation | Local orientation of entity in radians. |
| rotationalVelocity | In radians/second. |
| newHeading | In radians. |
|
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.
| newLocalProjectedLocation | is the location of the origin (center of rear axle) of the entity (input). |
| newHeading | is the heading of the entity (input). |
| newLocalOrientation | is the orientation of the entity after being placed on the ground in the given location (output). |
| newLocalPosition | is the position of the origin of the entity. It may be adjusted a little from the input position in altitude. |
|
protectedvirtual |
Computes the origin location from the turn center location.
Uses myController->turnCenterOffset. Ignores roll and pitch.
|
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.
The type of ground clamping also depends on the entity's configuration. Either high or low fidelity ground clamping is performed as specified.
|
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.
|
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.
|
private |
assignment operator; not implemented
|
protected |
|
protected |
|
protected |
|
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.
|
protected |
|
protected |
|
protected |
Port group used to set what values should be set into the VRF state repository.
All values are in local coordinates
|
protected |
To warn user about new immobilization just once.