![]() |
VR-Forces 4.3 Class Documentation
|
End User Description: DtRailMovementUpdater 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. More...
Public Member Functions | |
| DtRailMovementUpdater (DtRailMovementController *parentController, bool useTurnSmoothing, bool useAcceleration, 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 | ~DtRailMovementUpdater () |
| destructor | |
| virtual bool | init () |
| virtual void | clear () |
| virtual void | setEntityState (DtVrfMovingObjectStateRepository *state) |
| virtual double | setUpTurn (DtRailSegment *currentSeg, DtRailSegment *nextSeg, const int currentLane, const int drivingLane, double headingDiff, bool useLocalPos=false, DtVector currentLocalPos=DtVector::zero()) |
| Sets up the next turn. | |
| virtual bool | turnValid (int currentLane) |
| We need to check if the turn we calculated is still valid. | |
| virtual bool | recalculateTurnSpline (DtRailSegment *currentSeg, DtRailSegment *nextSeg, const int currentLane, const int passingLane) |
| virtual bool | modifyTurnSpline (const DtVector ¤tLocalPos, const DtRailSegment *currentSegment, const DtRailSegment *nextSegment, const int currentLane, const int passingLane) |
| Modifies the exsiting turn spline. | |
| virtual void | setUpLaneSwitch (const DtVector &projectedLocation, DtRailSegment *currentSeg, const int currentLane, const int passingLane) |
| Sets up a switch splice for switching lanes form currentLane to desiredLane. | |
| virtual void | update (DtRailSegment *currentSeg, DtRailSegment *nextSeg, double drivingSpeed, int passingLane, DtTime simTime=0.0) |
| Calculate new kinematic state and update our state repository. | |
| virtual void | updateNoMovement () |
| Sets the movement state of the entity to stopped. Call in place of update(). | |
| virtual void | movementComplete () |
| Called when movement is complete. | |
| 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 it's saved location on the current segment. | |
| virtual const DtCoordTransform & | localToBodyTransform () const |
| set/get the turn entry and exit points. | |
| virtual void | determinePositionAndSetFromEnd (const DtRailSegment *currentSeg, const int currentLane) |
| Set position to end of the segment. | |
Protected Member Functions | |
| virtual void | useFuel (double fuelUsed) |
| Upone reaching a new segment our coordinate transform matrices will be recomputed. | |
| virtual bool | checkEntityImmobilized () |
| virtual double | fuelLeft () const |
| Looks up the resource named “fuel” in the entity’s Resource Manager. | |
| 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. | |
| virtual double | calculateAcceleration (double desiredSpeed) |
| virtual void | calculateOrientationAndPosition (const DtVector &newLocalProjectedLocation, double newHeading, DtDcm &newLocalOrientation, DtVector &newLocalPosition) |
| Calculates the orientation and position of the entity, given a new location and heading. | |
| bool | groundClamp (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. | |
| void | groundClampHighFidelity (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. | |
| void | groundClampLowFidelity (double heading, const DtVector &location, DtAttachedTerrain &terrain, DtVector &newNormal) |
| Uses only the center ground interaction point. | |
| virtual DtVector | calculateRotationalVelocity (const DtTaitBryan &newTopoOrientation, const DtTaitBryan &oldTopoOrientation, double dT) |
| Calculates rotational velocity from new and old topocentric orientation. | |
| virtual void | calculateDirectionOfLinearMotion (const DtDcm &newLocalOrientation, const DtVector &newLocalPosition, DtDcm &newLocalDirectionOfLinearMotion) |
| Computes direction of linear motion. | |
| virtual DtVector | calculateBodyAcceleration (double desiredSpeed, const DtVector &oldBodyVelocity, double dT) |
| Calculates the linear acceleration in body coordinates of the entity in meters/second/second. | |
| virtual DtVector | calculateBodyVelocity (const DtVector &oldBodyVelocity, const DtVector &newBodyAcceleration, double dT) |
| virtual DtVector | calculateProjectedLocation (const DtVector &oldLocalPosition, const DtVector &newBodyAcceleration, const DtVector &oldBodyVelocity, const DtVector &newBodyVelocity, double newHeading) |
| virtual bool | rotationalVelocityShouldBeClamped (const DtVector &bodyRotationalVelocity) |
| Returns true if given magnitude of body rotational velocity is < 0.0001 radians/sec, false otherwise. | |
| virtual bool | passedTurnPoint (double distSq, double &differance) |
| Determines if the entity has gone passed the point at which it should start to turn. | |
| virtual DtVector | determinePositionAlongNextSegment (DtRailSegment *nextSegment, double distance, double &newHeading, int lanePos, DtVector projectedPos) |
| When the entity moves past the end point of it's current segment, the remaining distance traveled is then applied along the next segment to determine where the entity is on the segment. | |
| virtual void | determinePosition (const DtRailSegment *currentSeg, const int currentLane, DtVector &newLocalProjectedLocation) |
| Get position relative to lane along segment. | |
Protected Attributes | |
| DtRailMovementController * | myController |
| DtVrfMovingObjectStateRepository * | myMovingStateRep |
| 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. | |
| DtCoordTransform | myCoordTransform |
| bool | myUseHighFidelityGroundClamping |
| Only calculate these when switching rails, expensive. | |
| bool | myUseAcceleration |
| bool | myUseTurnSmoothing |
| double | myDistanceSqToTurn |
| This is the distance from the current segment's startpoint to the turn point on the segment. | |
| double | myHeadingDiff |
| Difference between our current segment's heading and our next segment. | |
| DtRailSplineCalculator | myTurnSpline |
| Handles turning from one rail to another using a quadratic spline curve. | |
| DtRailSplineCalculator | myLaneSwitchSpline |
| Handles switching lanes on the same rail using a quadratic spline curve. | |
| double | myTurnDistTraveled |
| This is the distance the entity has traveled so far. | |
| double | myDistAlongSeg |
| DtUpdateRepositoryOutputPortGroup * | myUpdateRepositoryOutputPortGroup |
| Port group used to set what values should be set into the VRF state repository. | |
Private Member Functions | |
| DtRailMovementUpdater () | |
| Default constructor; not implemented. | |
| DtRailMovementUpdater (const DtRailMovementUpdater &orig) | |
| Copy constructor; not implemented. | |
| const DtRailMovementUpdater & | operator= (const DtRailMovementUpdater &orig) |
| assignment operator; not implemented | |
End User Description: DtRailMovementUpdater 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.
DtRailSegment is the class that represents the segmentof 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. It converts throttle and brake into orientation, acceleration, velocity, and position.
Uses Descriptor Type: DtComponentDescriptor
| DtRailMovementUpdater::DtRailMovementUpdater | ( | DtRailMovementController * | parentController, |
| bool | useTurnSmoothing, | ||
| bool | useAcceleration, | ||
| 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 |
Sets up the next turn.
If using turn smoothing will call calculateTurnPath. If not, just sets the entry and exit turn points to the end of the current segment providing for the lane offsets of the 2 lanes. Returns the distance squared from the start of the segment to the turn point.
We need to check if the turn we calculated is still valid.
If our current lane is the same as the entry lane no need to recalculate the turn.
|
virtual |
|
virtual |
Modifies the exsiting turn spline.
Returns true if possible to modify the spline, false if the entity is too far along the spline to modify it reliably
|
virtual |
Sets up a switch splice for switching lanes form currentLane to desiredLane.
|
virtual |
Calculate new kinematic state and update our state repository.
|
virtual |
Sets the movement state of the entity to stopped. Call in place of update().
|
virtual |
Called when movement is complete.
|
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 it's saved location on the current segment.
|
virtual |
set/get the turn entry and exit points.
These will be computed initially when an entity moves on to a new segment, however cases could arise where the user may want to manipulate these Used to tranform local to body reference coordinate system based on the current segment's heading and using the end point as the offset. Makes computations much easier. Recomputed when switching to next segment in the setUpTurn function.
|
virtual |
Set position to end of the segment.
|
protectedvirtual |
Upone reaching a new segment our coordinate transform matrices will be recomputed.
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 |
|
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 wheel's or tread (or knees).
|
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.
|
protectedvirtual |
Calculates rotational velocity from new and old topocentric orientation.
|
protectedvirtual |
Computes direction of linear motion.
In base class, this is equivalent to newLocalOrientation, so it sets newLocalDirectionOfLinearMotion = newLocalOrientation.
|
protectedvirtual |
Calculates the linear acceleration in body coordinates of the entity in meters/second/second.
|
protectedvirtual |
|
protectedvirtual |
|
protectedvirtual |
Returns true if given magnitude of body rotational velocity is < 0.0001 radians/sec, false otherwise.
Called in tick() to determine whether or not to clamp small values for velocity to zero.
|
protectedvirtual |
Determines if the entity has gone passed the point at which it should start to turn.
If not using turn smoothing this is simply the end point of the current segment the entity is on.
|
protectedvirtual |
When the entity moves past the end point of it's current segment, the remaining distance traveled is then applied along the next segment to determine where the entity is on the segment.
The heading of the new segment is returned since this will then be the heading of the the entity. This is used when the entity is not using turn smoothing or the distance traveled takes the entity beyond the turn in this tick.
| distance | is the distance beyond the current segment that the vehicle has traveled. |
| projectedPos | is the current local position updated for this tick with a dT's worth of velocity and acceleration. |
|
protectedvirtual |
Get position relative to lane along segment.
|
private |
assignment operator; not implemented
|
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 |
Only calculate these when switching rails, expensive.
|
protected |
|
protected |
|
protected |
This is the distance from the current segment's startpoint to the turn point on the segment.
|
protected |
Difference between our current segment's heading and our next segment.
Used for turn smoothing.
|
protected |
Handles turning from one rail to another using a quadratic spline curve.
|
protected |
Handles switching lanes on the same rail using a quadratic spline curve.
|
protected |
This is the distance the entity has traveled so far.
|
protected |
|
protected |
Port group used to set what values should be set into the VRF state repository.
All values are in local coordinates