Prepare Fleet for Service#
When a Fleet is being prepared for service, there are a number of steps to complete before the Fleet is ready to fulfil Rides. These include:
Check the Fleet’s availability
Subscribe to events about Vehicles’ movements and Missions handled by Vehicles in the Fleet
Recheck regularly for changes in the Fleet’s availability
Check Fleet’s Availability#
Given a specific Fleet with id fleet_id
we first get the information about which Vehicles in our Fleet are currently available for service.
For this, we request the list of Vehicles for a specific Fleet by calling the ListVehicles
endpoint.
This endpoint uses pagination.
To get the complete list of Vehicles, we repeat the request until next_page_token
in the response is empty.
grpcurl -H "authorization: Bearer $ACCESS_TOKEN" -import-path . -proto fleet_state.proto \
-d "{ \"fleet_id\": \"$FLEET_ID\"}" \
fleet-api.int.eu-central-1.moia-group.io:443 moia.fleet.state.v1beta4.FleetStateService/ListVehicles
Every Vehicle with state online
is a Vehicle which is connected
(meaning it responds to heartbeats), active
(i.e. not blocked for repairs) and responsive
(has not recently rejected missions).
Every Vehicle with state ready_for_new_rides
is online
(as detailed above) and is configured in MOIA’s Fleet Control Center by an Operator as being available
to serve rides (currently termed Pooling
) and has a recent valid location
. Thus showing that a vehicle is setup, configured and in a state where it is ready to receive and process new rides (via updateVehicleMission
).
More details on these parameters can be found below.
Vehicle Online and Ready for New Ride Parameters#
The parameters considered for determining whether a vehicles is online
/ ready_for_new_rides
are:
The vehicle is
active
meaning that it is correctly setup and configured (i.e. being configured as self driving vehicle and not currently blocked for repair).The vehicle is currently
connected
, derived by a heartbeat mechanism. A vehicle needs to be online, for a mission update to be sent to it.The vehicle’s current
location
is known and recent, so a good decision can be made on which rides could be matches to this vehicle.The vehicle is
responsive
, as determined by its recent ability to accept Mission updates.The vehicle is manually set (by an Operator) in MOIA’s Fleet Control Center to be
available
to serve new rides (currently termedPooling
).
ready_for_new_rides
does not imply that a Vehicle has no current ride assigned to it (in the Vehicle’s Mission). The Fleet API allows multiple rides to be planned into a Mission and therefore it is left to Fleet API consumers to check whether a Vehicle could fulfil an additional ride based upon its current Mission and the requirements of this ride.
Subscribe to Events about Vehicle Telemetry#
The Vehicles are sending telemetry data while they are online
.
To receive continuous live updates of the telemetry data for each Vehicle we can call to the non-durable streaming method SubscribeToVehicleTelemetryMovement
for each Vehicle.
This step is only required if live telemetry updates for a Vehicle are required.
grpcurl -H "authorization: Bearer $ACCESS_TOKEN" -import-path . -proto fleet_state.proto -emit-defaults \
-d "{ \"vehicle_id\": \"$VEHICLE_ID\" }" \
-max-time 30 \
fleet-api.int.eu-central-1.moia-group.io:443 moia.fleet.state.v1beta4.FleetStateService/SubscribeToVehicleTelemetryMovement
Subscribe to Mission Events#
Vehicles in the fleet are executing their current Mission at any time. While they are executing their Mission, Mission events are sent out to inform about relevant happenings about Waypoints and Waypoint Actions.
While the fleet is in service, these Mission events contain crucial updates regarding the execution of Missions.
Therefore, we need to keep alive the durable stream SubscribeToFleetMissionEvents
for the fleet.
grpcurl -H "authorization: Bearer $ACCESS_TOKEN" -import-path . -proto fleet_state.proto --emit-defaults \
-d "{\"fleet_id\": \"$FLEET_ID\"}" \
-max-time 30 \
fleet-api.int.eu-central-1.moia-group.io:443 moia.fleet.state.v1beta4.FleetStateService/SubscribeToFleetMissionEvents
Recheck Fleet’s Availability#
The availability of Vehicles can change regularly. Vehicles can go offline or come online again. Therefore, it is important to regularly check the Fleet’s availability by repeating the steps described in Check Fleet’s Availability as well as the subsequent steps to subscribe to relevant events.