public abstract class BasicVehicle extends Object implements VehicleSimView
Modifier and Type | Class and Description |
---|---|
static class |
BasicVehicle.AccelScheduleMovement
The acceleration schedule movement.
|
static interface |
BasicVehicle.Movement
The movement of a vehicle.
|
static interface |
BasicVehicle.MovementFactory
The Movement Factory
|
static interface |
BasicVehicle.MovementWithAccel
The movement with acceleration interface
|
static class |
BasicVehicle.MoveToTargetVelocityMovement
A move-to-target-velocity movement.
|
static class |
BasicVehicle.NonAccelMovement
The non-acceleration movement
|
static class |
BasicVehicle.PhysicalMovement
The physical movement.
|
static class |
BasicVehicle.SteeringMovement
The steering movement.
|
static class |
BasicVehicle.TrackMovement
The track movement.
|
Modifier and Type | Field and Description |
---|---|
protected double |
currentTime
The current time
|
protected BasicVehicle.Movement |
movement
The movement mechanism
|
protected VehicleSpec |
spec
The characteristics of the vehicle
|
protected int |
vin
The vehicle's ID number (i.e., the VIN number).
|
Constructor and Description |
---|
BasicVehicle(VehicleSpec spec,
Point2D pos,
double heading,
double velocity,
double steeringAngle,
double acceleration,
double targetVelocity,
double currentTime)
Construct a vehicle
|
Modifier and Type | Method and Description |
---|---|
void |
checkCurrentTime(double currentTime)
Check whether this vehicle's time is current.
|
void |
coast()
Set the acceleration to zero.
|
protected void |
finalize() |
Point2D[] |
gaugeCornerPoints()
Get the current global coordinates of the corners of this Vehicle,
according to the Vehicle's gauges.
|
double |
gaugeHeading()
Get this Vehicle's compass gauge's reading.
|
Point2D |
gaugePointAtMiddleFront(double delta)
Get the point in front of the middle point of the vehicle that is
at the distance of delta away from the vehicle, according to the gauges.
|
Point2D |
gaugePointAtRear()
Get the point at the rear center of the vehicle, according to our gauges
|
Point2D |
gaugePointBetweenFrontWheels()
Get the point between the front wheels, according to our gauges.
|
Point2D |
gaugePosition()
Get the current position of this Vehicle, represented by the point at
the center of the front of the Vehicle, according to the Vehicle's
gauges.
|
Point2D |
gaugeRearLeftCornerPoint()
Get the current global coordinate of the rear-left corner of this
Vehicle, according to the Vehicle's gauges.
|
Point2D |
gaugeRearRightCornerPoint()
Get the current global coordinate of the rear-right corner of this
Vehicle, according to the Vehicle's gauges.
|
Shape |
gaugeShape()
Get a
Shape describing the Vehicle, according to the Vehicle's
gauges. |
double |
gaugeTime()
Read this Vehicle's clock (chronometer).
|
double |
gaugeVelocity()
Get this Vehicle's speedometer gauge's reading.
|
double |
getAcceleration()
Get the acceleration of the vehicle
|
AccelSchedule |
getAccelSchedule()
Get the acceleration profile.
|
Point2D |
getCenterPoint()
Get the location of the center of the Vehicle at this point in time.
|
Point2D[] |
getCornerPoints()
Get the current global coordinates of the corners of this Vehicle.
|
abstract Driver |
getDriver()
Getter method for the Driver controlling this Vehicle.
|
List<Line2D> |
getEdges()
Get the edges that represent the boundaries of this Vehicle.
|
double |
getHeading()
Get the heading of the vehicle
|
Point2D |
getPointAtMiddleFront(double delta)
Get the point in front of the middle point of the vehicle that is
at the distance of delta away from the vehicle.
|
Point2D |
getPointAtRear()
Get the point at the rear center of the Vehicle.
|
Point2D |
getPosition()
Get the position of the vehicle.
|
Shape |
getShape()
Get a
Shape describing the Vehicle. |
Shape |
getShape(double extra)
Get a {link Shape} describing this Vehicle, if it were larger in each
dimension.
|
VehicleSpec |
getSpec()
Get the specification of the vehicle
|
double |
getSteeringAngle()
Get the steering angle of the vehicle
|
double |
getVelocity()
Get the velocity of the vehicle
|
int |
getVIN()
Get the ID number of this vehicle.
|
Shape[] |
getWheelShapes()
Get the Shapes of each of the wheels.
|
void |
move(double timeStep)
Move a single Vehicle according to some approximation of the laws
of physics.
|
void |
printState()
print the state of the driver.
|
void |
removeAccelSchedule()
Remove the acceleration profile.
|
void |
setAccelSchedule(AccelSchedule accelSchedule)
Set the acceleration profile.
|
void |
setAccelWithMaxTargetVelocity(double acceleration)
Set the acceleration to the specified value, using maximum and minimum
velocities as targets, automatically.
|
void |
setMaxAccelWithMaxTargetVelocity()
Set the Vehicle's acceleration to its maximum value.
|
void |
setTargetVelocityWithMaxAccel(double targetVelocity)
Set the acceleration to the appropriate value to reach the target
velocity, based on the current speedometer reading.
|
void |
setVIN(int vin)
Set the VIN number of this Vehicle.
|
void |
slowToStop()
Set the Vehicle's acceleration to its minimum value without going
backward.
|
void |
turnTowardPoint(Point2D p)
Turn the wheels toward a given Point.
|
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
getV2IOutbox, setDriver
protected int vin
protected VehicleSpec spec
protected BasicVehicle.Movement movement
protected double currentTime
public BasicVehicle(VehicleSpec spec, Point2D pos, double heading, double velocity, double steeringAngle, double acceleration, double targetVelocity, double currentTime)
spec
- the vehicle's specificationpos
- the initial position of the Vehicleheading
- the initial heading of the VehiclesteeringAngle
- the initial steering angle of the Vehiclevelocity
- the initial velocity of the VehicletargetVelocity
- the initial target velocityacceleration
- the initial acceleration of the VehiclecurrentTime
- the current timeprotected void finalize() throws Throwable
public int getVIN()
getVIN
in interface VehicleDriverView
public void setVIN(int vin)
setVIN
in interface VehicleSimView
vin
- the vehicle's VIN number.public VehicleSpec getSpec()
getSpec
in interface VehicleDriverView
public double gaugeTime()
gaugeTime
in interface VehicleDriverView
public abstract Driver getDriver()
getDriver
in interface VehicleDriverView
null
if none exists.public Point2D getPosition()
getPosition
in interface VehicleSimView
public double getHeading()
getHeading
in interface VehicleSimView
public double getSteeringAngle()
public double getVelocity()
getVelocity
in interface VehicleSimView
public double getAcceleration()
getAcceleration
in interface VehicleSimView
public AccelSchedule getAccelSchedule()
getAccelSchedule
in interface VehicleDriverView
public Point2D gaugePosition()
gaugePosition
in interface VehicleDriverView
public double gaugeVelocity()
gaugeVelocity
in interface VehicleDriverView
public double gaugeHeading()
gaugeHeading
in interface VehicleDriverView
public Shape getShape()
Shape
describing the Vehicle.getShape
in interface VehicleSimView
public Shape gaugeShape()
Shape
describing the Vehicle, according to the Vehicle's
gauges.gaugeShape
in interface VehicleDriverView
public Shape getShape(double extra)
getShape
in interface VehicleSimView
extra
- the fixed extra amount by which to increase the size of the
Vehicle in each dimensionpublic List<Line2D> getEdges()
getEdges
in interface VehicleSimView
public Point2D getPointAtMiddleFront(double delta)
getPointAtMiddleFront
in interface VehicleSimView
delta
- the distance of the vehicle and the pointpublic Point2D gaugePointAtMiddleFront(double delta)
gaugePointAtMiddleFront
in interface VehicleDriverView
delta
- the distance of the vehicle and the point,
according to the gaugespublic Point2D gaugePointBetweenFrontWheels()
gaugePointBetweenFrontWheels
in interface VehicleDriverView
public Point2D getCenterPoint()
getCenterPoint
in interface VehicleSimView
public Point2D[] getCornerPoints()
getCornerPoints
in interface VehicleSimView
public Point2D[] gaugeCornerPoints()
public Point2D getPointAtRear()
getPointAtRear
in interface VehicleSimView
public Point2D gaugePointAtRear()
gaugePointAtRear
in interface VehicleDriverView
public Point2D gaugeRearLeftCornerPoint()
gaugeRearLeftCornerPoint
in interface VehicleDriverView
public Point2D gaugeRearRightCornerPoint()
gaugeRearRightCornerPoint
in interface VehicleDriverView
public Shape[] getWheelShapes()
getWheelShapes
in interface VehicleSimView
public void move(double timeStep)
move
in interface VehicleSimView
timeStep
- the size of the time step to simulate, in secondspublic void turnTowardPoint(Point2D p)
turnTowardPoint
in interface VehicleDriverView
p
- the Point toward which to turn the wheelspublic void coast()
coast
in interface VehicleDriverView
public void slowToStop()
slowToStop
in interface VehicleDriverView
public void setMaxAccelWithMaxTargetVelocity()
public void setTargetVelocityWithMaxAccel(double targetVelocity)
setTargetVelocityWithMaxAccel
in interface VehicleDriverView
targetVelocity
- the desired ultimate velocitypublic void setAccelWithMaxTargetVelocity(double acceleration)
setAccelWithMaxTargetVelocity
in interface VehicleDriverView
acceleration
- the desired acceleration.public void setAccelSchedule(AccelSchedule accelSchedule)
setAccelSchedule
in interface VehicleDriverView
accelSchedule
- the acceleration profilepublic void removeAccelSchedule()
removeAccelSchedule
in interface VehicleDriverView
public void checkCurrentTime(double currentTime)
checkCurrentTime
in interface VehicleSimView
currentTime
- the current timepublic void printState()
printState
in interface VehicleDriverView
Copyright © 2013. All rights reserved.