CarMoveTo is the block that controls the car movement. A car can move only when it is inside a CarMoveTo block. When a car enters CarMoveTo, it tries to calculate the way from its current location to the specified destination.
The destinations a car can move to include: a road, a parking lot, a bus stop, or a stop line. The specified destination must belong to the same road network as the one the car is currently in. If there is no way from the car’s current location to the specified destination, the car exits the block via the outWayNotFound port.
If a car is set to move to a road, the direction of the road should be additionally specified. The car will try to take the shortest path to get to the beginning of the specified road. Once on the road, the car will move along the specified road until it reaches the end of the road. As soon as a car reaches the end of the road, it should be immediately removed from the model by the CarDispose block or be sent to the other CarMoveTo to move further. If a car is unable to leave the end of the destination road immediately, an error is generated.
If a car is set to move to a parking lot, the car will move to the specified parking lot and try to reserve an available parking space. Cars reserve parking spaces only when they approach the parking lot. If a car is unable to reserve a parking space, it leaves the block via the outWayNotFound port. If a car is able to successfully reserve a parking space, it parks at the space and leaves the block. A car can remain in a parking space until it is removed from the road network or sent to another destination by the CarMoveTo block.
If a car is set to move to a bus stop, the car will move to the specified bus stop. If a bus stop is already occupied by another car, the car approaching the bus stop will stop at the bus stop and wait until the bus stop is vacant. When a car arrives at a bus stop, it parks at the stop and leaves the block. A car can remain at the bus stop until it is removed from the road network or is sent to another destination by the CarMoveTo block.
If a car is set to move to a stop line, there are two ways it can behave at the destination stop line. See the Behavior at stop line parameter for a description.
While the car is moving under the control of the CarMoveTo block, you still can partially control it by using the Car API.
Demo model: CarMoveTo Open the model page in AnyLogic Cloud. There you can run the model or download it (by clicking Model source files). Demo model: CarMoveToOpen the model in your AnyLogic desktop installation.- Moves to
-
The type of the destination to which the car will be sent: Road, Parking lot, Stop line, or Bus stop.
Get value: movesTo
Set new value at runtime: set_movesTo(new value)
Valid values:
CarMoveTo.ROAD
CarMoveTo.PARKING_LOT
CarMoveTo.STOP_LINE
CarMoveTo.BUS_STOP -
[Visible and applies only if Moves to: Road]
The road to which the car will be sent. The movement direction needs to be specified below in the Destination parameter.
If the Road is not specified, or it is not found in the current road network, an error is generated.
If a car cannot find the way to the specified road through the road network, this car leaves the block via its outWayNotFound port.Value type: Road
Local variable: car — The car that is being sent to the destination road - Destination
-
[Visible and applies only if Moves to: Road option]
Specifies the destination (end of forward lane or end of backward lane) of the road to which the car will move. If the road does not have the specified destination (that is, is one-way), an error is generated.Get value: destination
Set new value at runtime: set_destination(new value)
Valid values:
CarMoveTo.END_OF_FORWARD_LANE
CarMoveTo.END_OF_BACKWARD_LANE -
[Visible and applies only if Moves to: Parking lot]
The parking lot to which the car will be sent. The car starts movement from its current location to the specified parking lot. When it approaches the parking lot, it tries to reserve a parking space in the lot. If the car is able to reserve a parking space, it parks at this space and exits this CarMoveTo block. If the car cannot reserve a parking space (the parking lot has no free parking spaces), an error is generated.
If the Parking lot is not specified or is not found in the current road network, an error is generated.
If a car cannot find the way to the specified parking lot through the road network, the car leaves the block via its outWayNotFound port.Value type: ParkingLot
Local variable: car — The car that is being sent to the parking lot -
[Visible and applies only if Moves to: Stop line]
The stop line to which the car will be sent. The car starts movement from its current location to the specified stop line. When it approaches the stop line, it decelerates, stops, and exits this CarMoveTo block (its behavior can be set in the Behavior at stop line option below).
If the Stop line is not specified or is not found in the current road network, an error is generated.
If a car cannot find the way to the specified stop line through the road network, the car leaves the block via its outWayNotFound port.Value type: StopLine
Local variable: car — The car that is being sent to the stop line - Behavior at stop line
-
[Visible and applies only if Moves to: Stop line]
Specifies the behavior at destination stop line:Pass through stop line — The car does not stop before the stop line and exits the CarMoveTo block immediately after passing the specified stop line. The car should be immediately removed from the model or sent to another destination by another CarMoveTo block, otherwise an error will be generated.
Stop before stop line — The car will stop before the specified stop line. The car will exit the CarMoveTo block at zero speed. It is not necessary to immediately remove the car or send it to the next destination.Get value: stopLineBehavior
Local variable: car — The car that is being sent to the stop line
Set new value at runtime: set_stopLineBehavior(new value)
Valid values:
CarMoveTo.PASS_THROUGH_STOP_LINE
CarMoveTo.STOP_BEFORE_STOP_LINE -
[Visible and applies only if Moves to: Bus Stop]
The bus stop to which the car is sent. The car starts movement from its current location to the specified bus stop. When it approaches the bus stop, it tries to reserve a place in the bus stop. If the car is able to reserve place, it occupies this place and exits the CarMoveTo block. If the car cannot reserve place (the bus stop has no free place), the vehicle stops on the road right next to the bus stop, expecting its turn to enter the bus stop.
If the Bus stop is not specified or is not found in the current road network, an error is generated.
If the car cannot find the way to the specified bus stop through the road network, this car leaves the block via its outWayNotFound port.Value type: BusStop
Local variable: car — The car that is being sent to the bus stop - A list of roads that must be included in the automatically calculated route for cars. These roads will be included in the route in the specified order, so you need to ensure that such a route exists.
Value type: Road[]
Local variable: car — the car - A list of roads that you want to exclude from the automatically calculated route for cars.
Value type: Road[]
Local variable: car — the car
- On enter
-
The code to execute when the car enters the block.
Local variable: car — The car that enters the block
- On exit
-
The code to execute when the car reaches its destination. If the destination was a road, the code is executed at the end of the destination road. If the destination was a parking lot, the code is executed when the car parks in a space in the specified parking lot.
Local variable: car — The car that reached its destination
- On way not found
-
The code to execute when a car cannot find its way to the specified destination from its current location.
Local variable: car — The car that is unable to find the way
- Cars
-
Function Description long size() Returns the number of cars inside this block. java.util.List<Agent> getCars() Returns a non-modifiable collection containing the cars that are currently in this block.
- in
- The input port.
- out
- The output port.
- outWayNotFound
- The output port used by a car to leave the block if there is no way from the car’s current location to the specified destination.
-
How can we improve this article?
-