aim4.driver
Class AutoDriver

java.lang.Object
  extended by aim4.driver.Driver
      extended by aim4.driver.AutoDriver
All Implemented Interfaces:
AutoDriverCoordinatorView, AutoDriverPilotView, DriverSimView
Direct Known Subclasses:
AutoV2VDriver, ProxyDriver

public class AutoDriver
extends Driver
implements AutoDriverCoordinatorView, AutoDriverPilotView

An agent that drives a AutoVehicleDriverView while coordinating with IntersectionManagers and other Vehicles. Such an agent consists of two sub-agents, a Coordinator and a Pilot. The two agents communicate by setting state in this class.


Field Summary
 
Fields inherited from class aim4.driver.Driver
currentLane, currentlyOccupiedLanes
 
Constructor Summary
AutoDriver(AutoVehicleDriverView vehicle, BasicMap basicMap)
           
 
Method Summary
 void act()
          Take control actions for driving the agent's Vehicle.
 double distanceFromPrevIntersection()
          Find the distance from the previous intersection in the Lane in which the Vehicle is, from the position at which the Vehicle is.
 double distanceToNextIntersection()
          Find the distance to the next intersection in the Lane in which the Vehicle is, from the position at which the Vehicle is.
 Coordinator getCurrentCoordinator()
          Get the current coordinator of the vehicle.
 IntersectionManager getCurrentIM()
          Get the IntersectionManager with which the agent is currently interacting.
 AutoVehicleDriverView getVehicle()
          Get the Vehicle this DriverAgent is controlling.
 boolean inCurrentIntersection()
          Whether or not the Vehicle controlled by this driver agent is inside the intersection managed by the current IntersectionManager.
 IntersectionManager nextIntersectionManager()
          Find the next IntersectionManager that the Vehicle will need to interact with, in this Lane.
 
Methods inherited from class aim4.driver.Driver
addCurrentlyOccupiedLane, getCurrentLane, getCurrentlyOccupiedLanes, getDestination, getSpawnPoint, setCurrentLane, setDestination, setSpawnPoint
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface aim4.driver.AutoDriverCoordinatorView
addCurrentlyOccupiedLane, getCurrentLane, getDestination, setCurrentLane
 
Methods inherited from interface aim4.driver.AutoDriverPilotView
getCurrentLane, setCurrentLane
 

Constructor Detail

AutoDriver

public AutoDriver(AutoVehicleDriverView vehicle,
                  BasicMap basicMap)
Method Detail

act

public void act()
Take control actions for driving the agent's Vehicle. This allows both the Coordinator and the Pilot to act (in that order).

Specified by:
act in interface DriverSimView
Overrides:
act in class Driver

getVehicle

public AutoVehicleDriverView getVehicle()
Get the Vehicle this DriverAgent is controlling.

Specified by:
getVehicle in interface AutoDriverPilotView
Specified by:
getVehicle in interface DriverSimView
Specified by:
getVehicle in class Driver
Returns:
the Vehicle this DriverAgent is controlling

getCurrentCoordinator

public Coordinator getCurrentCoordinator()
Get the current coordinator of the vehicle.

Returns:
the current coordinator of the vehicle.

getCurrentIM

public IntersectionManager getCurrentIM()
Get the IntersectionManager with which the agent is currently interacting.

Specified by:
getCurrentIM in interface AutoDriverCoordinatorView
Specified by:
getCurrentIM in interface AutoDriverPilotView
Returns:
the IntersectionManager with which the agent is currently interacting

nextIntersectionManager

public IntersectionManager nextIntersectionManager()
Find the next IntersectionManager that the Vehicle will need to interact with, in this Lane. This version overrides the version in Driver, but only to memoize it for speed.

Specified by:
nextIntersectionManager in interface AutoDriverCoordinatorView
Overrides:
nextIntersectionManager in class Driver
Returns:
the nextIntersectionManager that the Vehicle will need to interact with, in this Lane

distanceToNextIntersection

public double distanceToNextIntersection()
Find the distance to the next intersection in the Lane in which the Vehicle is, from the position at which the Vehicle is. This version overrides the version in Driver, but only to memoize it for speed.

Specified by:
distanceToNextIntersection in interface AutoDriverCoordinatorView
Specified by:
distanceToNextIntersection in interface AutoDriverPilotView
Overrides:
distanceToNextIntersection in class Driver
Returns:
the distance to the next intersection given the current Lane and position of the Vehicle.

distanceFromPrevIntersection

public double distanceFromPrevIntersection()
Find the distance from the previous intersection in the Lane in which the Vehicle is, from the position at which the Vehicle is. This subtracts the length of the Vehicle from the distance from the front of the Vehicle. It overrides the version in DriverAgent, but only to memoize it.

Specified by:
distanceFromPrevIntersection in interface AutoDriverCoordinatorView
Overrides:
distanceFromPrevIntersection in class Driver
Returns:
the distance from the previous intersection given the current Lane and position of the Vehicle.

inCurrentIntersection

public boolean inCurrentIntersection()
Whether or not the Vehicle controlled by this driver agent is inside the intersection managed by the current IntersectionManager.

Specified by:
inCurrentIntersection in interface AutoDriverCoordinatorView
Returns:
whether or not the Vehicle controlled by this CoordinatingDriverAgent is inside the intersection managed by the current IntersectionManager.


Copyright © 2011. All Rights Reserved.