aim4.vehicle
Class BasicVehicle

java.lang.Object
  extended by aim4.vehicle.BasicVehicle
All Implemented Interfaces:
VehicleDriverView, VehicleSimView
Direct Known Subclasses:
BasicAutoVehicle

public abstract class BasicVehicle
extends Object
implements VehicleSimView

The most basic form of a vehicle.


Nested Class Summary
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.
 
Field Summary
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 Summary
BasicVehicle(VehicleSpec spec, Point2D pos, double heading, double velocity, double steeringAngle, double acceleration, double targetVelocity, double currentTime)
          Construct a vehicle
 
Method Summary
 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.
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface aim4.vehicle.VehicleSimView
getV2IOutbox, setDriver
 

Field Detail

vin

protected int vin
The vehicle's ID number (i.e., the VIN number). If the VIN number is less than zero, the vehicle has not been registered in the vehicle registry.


spec

protected VehicleSpec spec
The characteristics of the vehicle


movement

protected BasicVehicle.Movement movement
The movement mechanism


currentTime

protected double currentTime
The current time

Constructor Detail

BasicVehicle

public BasicVehicle(VehicleSpec spec,
                    Point2D pos,
                    double heading,
                    double velocity,
                    double steeringAngle,
                    double acceleration,
                    double targetVelocity,
                    double currentTime)
Construct a vehicle

Parameters:
spec - the vehicle's specification
pos - the initial position of the Vehicle
heading - the initial heading of the Vehicle
steeringAngle - the initial steering angle of the Vehicle
velocity - the initial velocity of the Vehicle
targetVelocity - the initial target velocity
acceleration - the initial acceleration of the Vehicle
currentTime - the current time
Method Detail

finalize

protected void finalize()
                 throws Throwable

Overrides:
finalize in class Object
Throws:
Throwable

getVIN

public int getVIN()
Get the ID number of this vehicle. If the vehicle does not have a VIN number, this function returns a negative number.

Specified by:
getVIN in interface VehicleDriverView
Returns:
the Vehicle's VIN number.

setVIN

public void setVIN(int vin)
Set the VIN number of this Vehicle.

Specified by:
setVIN in interface VehicleSimView
Parameters:
vin - the vehicle's VIN number.

getSpec

public VehicleSpec getSpec()
Get the specification of the vehicle

Specified by:
getSpec in interface VehicleDriverView
Returns:
the specification of the vehicle

gaugeTime

public double gaugeTime()
Read this Vehicle's clock (chronometer).

Specified by:
gaugeTime in interface VehicleDriverView
Returns:
the Vehicle's clock gauge.

getDriver

public abstract Driver getDriver()
Getter method for the Driver controlling this Vehicle.

Specified by:
getDriver in interface VehicleDriverView
Returns:
the Driver controlling this Vehicle, or null if none exists.

getPosition

public Point2D getPosition()
Get the position of the vehicle.

Specified by:
getPosition in interface VehicleSimView
Returns:
the position of the vehicle

getHeading

public double getHeading()
Get the heading of the vehicle

Specified by:
getHeading in interface VehicleSimView
Returns:
the heading of the vehicle

getSteeringAngle

public double getSteeringAngle()
Get the steering angle of the vehicle

Returns:
the steering angle of the vehicle

getVelocity

public double getVelocity()
Get the velocity of the vehicle

Specified by:
getVelocity in interface VehicleSimView
Returns:
the velocity of the vehicle

getAcceleration

public double getAcceleration()
Get the acceleration of the vehicle

Specified by:
getAcceleration in interface VehicleSimView
Returns:
the acceleration of the vehicle

getAccelSchedule

public AccelSchedule getAccelSchedule()
Get the acceleration profile.

Specified by:
getAccelSchedule in interface VehicleDriverView
Returns:
the acceleration profile

gaugePosition

public 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.

Specified by:
gaugePosition in interface VehicleDriverView
Returns:
the position of this Vehicle according to the Vehicle's gauges

gaugeVelocity

public double gaugeVelocity()
Get this Vehicle's speedometer gauge's reading.

Specified by:
gaugeVelocity in interface VehicleDriverView
Returns:
the Vehicle's speedometer gauge's reading

gaugeHeading

public double gaugeHeading()
Get this Vehicle's compass gauge's reading.

Specified by:
gaugeHeading in interface VehicleDriverView
Returns:
the Vehicle's compass gauge's reading

getShape

public Shape getShape()
Get a Shape describing the Vehicle.

Specified by:
getShape in interface VehicleSimView
Returns:
a Shape describing this Vehicle.

gaugeShape

public Shape gaugeShape()
Get a Shape describing the Vehicle, according to the Vehicle's gauges.

Specified by:
gaugeShape in interface VehicleDriverView
Returns:
a Shape describing this Vehicle, according to the Vehicle's gauges.

getShape

public Shape getShape(double extra)
Get a {link Shape} describing this Vehicle, if it were larger in each dimension.

Specified by:
getShape in interface VehicleSimView
Parameters:
extra - the fixed extra amount by which to increase the size of the Vehicle in each dimension
Returns:
a Shape describing a Vehicle larger in each dimension by the extra amount.

getEdges

public List<Line2D> getEdges()
Get the edges that represent the boundaries of this Vehicle.

Specified by:
getEdges in interface VehicleSimView
Returns:
an array of line segments that represent the edges of the Vehicle.

getPointAtMiddleFront

public 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.

Specified by:
getPointAtMiddleFront in interface VehicleSimView
Parameters:
delta - the distance of the vehicle and the point
Returns:
the projected point

gaugePointAtMiddleFront

public 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.

Specified by:
gaugePointAtMiddleFront in interface VehicleDriverView
Parameters:
delta - the distance of the vehicle and the point, according to the gauges
Returns:
the projected point

gaugePointBetweenFrontWheels

public Point2D gaugePointBetweenFrontWheels()
Get the point between the front wheels, according to our gauges.

Specified by:
gaugePointBetweenFrontWheels in interface VehicleDriverView
Returns:
the global coordinates of the point between the front wheels, according to the gauges

getCenterPoint

public Point2D getCenterPoint()
Get the location of the center of the Vehicle at this point in time.

Specified by:
getCenterPoint in interface VehicleSimView
Returns:
the global coordinates of the center of the Vehicle.

getCornerPoints

public Point2D[] getCornerPoints()
Get the current global coordinates of the corners of this Vehicle.

Specified by:
getCornerPoints in interface VehicleSimView
Returns:
an array of points representing the four corners.

gaugeCornerPoints

public Point2D[] gaugeCornerPoints()
Get the current global coordinates of the corners of this Vehicle, according to the Vehicle's gauges.

Returns:
an array of points representing the four corners, according to the Vehicle's gauges.

getPointAtRear

public Point2D getPointAtRear()
Get the point at the rear center of the Vehicle.

Specified by:
getPointAtRear in interface VehicleSimView
Returns:
the global coordinates of the point at the center of the Vehicle's rear

gaugePointAtRear

public Point2D gaugePointAtRear()
Get the point at the rear center of the vehicle, according to our gauges

Specified by:
gaugePointAtRear in interface VehicleDriverView
Returns:
the global coordinates of the point at the center of the vehicle's rear, according to the gauges.

gaugeRearLeftCornerPoint

public Point2D gaugeRearLeftCornerPoint()
Get the current global coordinate of the rear-left corner of this Vehicle, according to the Vehicle's gauges.

Specified by:
gaugeRearLeftCornerPoint in interface VehicleDriverView
Returns:
a point representing the rear-left corner, according to the Vehicle's gauges.

gaugeRearRightCornerPoint

public Point2D gaugeRearRightCornerPoint()
Get the current global coordinate of the rear-right corner of this Vehicle, according to the Vehicle's gauges.

Specified by:
gaugeRearRightCornerPoint in interface VehicleDriverView
Returns:
a point representing the rear-right corner, according to the Vehicle's gauges.

getWheelShapes

public Shape[] getWheelShapes()
Get the Shapes of each of the wheels.

Specified by:
getWheelShapes in interface VehicleSimView
Returns:
an array of wheel Shapes: front left, front right, rear left, rear right

move

public void move(double timeStep)
Move a single Vehicle according to some approximation of the laws of physics.

Specified by:
move in interface VehicleSimView
Parameters:
timeStep - the size of the time step to simulate, in seconds

turnTowardPoint

public void turnTowardPoint(Point2D p)
Turn the wheels toward a given Point.

Specified by:
turnTowardPoint in interface VehicleDriverView
Parameters:
p - the Point toward which to turn the wheels

coast

public void coast()
Set the acceleration to zero. Obeys limits on acceleration and disabilities.

Specified by:
coast in interface VehicleDriverView

slowToStop

public void slowToStop()
Set the Vehicle's acceleration to its minimum value without going backward. Obeys limits on acceleration as well as disabilities.

Specified by:
slowToStop in interface VehicleDriverView

setMaxAccelWithMaxTargetVelocity

public void setMaxAccelWithMaxTargetVelocity()
Set the Vehicle's acceleration to its maximum value. Obeys limits on setMaxAccelWithMaxTargetVelocity as well as disabilities.


setTargetVelocityWithMaxAccel

public void setTargetVelocityWithMaxAccel(double targetVelocity)
Set the acceleration to the appropriate value to reach the target velocity, based on the current speedometer reading. Obeys limits on acceleration and velocity as well as any disabilities.

Specified by:
setTargetVelocityWithMaxAccel in interface VehicleDriverView
Parameters:
targetVelocity - the desired ultimate velocity

setAccelWithMaxTargetVelocity

public void setAccelWithMaxTargetVelocity(double acceleration)
Set the acceleration to the specified value, using maximum and minimum velocities as targets, automatically. Obeys limits on acceleration and velocity as well as any disabilities.

Specified by:
setAccelWithMaxTargetVelocity in interface VehicleDriverView
Parameters:
acceleration - the desired acceleration.

setAccelSchedule

public void setAccelSchedule(AccelSchedule accelSchedule)
Set the acceleration profile.

Specified by:
setAccelSchedule in interface VehicleDriverView
Parameters:
accelSchedule - the acceleration profile

removeAccelSchedule

public void removeAccelSchedule()
Remove the acceleration profile.

Specified by:
removeAccelSchedule in interface VehicleDriverView

checkCurrentTime

public void checkCurrentTime(double currentTime)
Check whether this vehicle's time is current.

Specified by:
checkCurrentTime in interface VehicleSimView
Parameters:
currentTime - the current time

printState

public void printState()
print the state of the driver.

Specified by:
printState in interface VehicleDriverView


Copyright © 2011. All Rights Reserved.