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.trip.int.moia-group.io:443 moia.fleet.state.v1beta4.FleetStateService/ListVehicles

Every Vehicle with state online is a Vehicle which is currently driving around and active. Every Vehicle with state ready_for_new_rides is ready to accept new Rides.

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.trip.int.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.trip.int.moia-group.io:443 moia.fleet.state.v1beta4.FleetStateService/PollFleetMissionEvents

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.