Autonomous Trips#
A Trip in an Autonomous Vehicle is similar to a Trip described in the Trip Lifecycle. However, some of the tasks that are otherwise performed by the driver are automated or need to be performed by the Rider.
Listing authentication methods for Boarding an Autonomous Vehicle#
The Customer needs to authenticate for boarding when standing in front of the vehicle at the pickup Stop.
Different vehicles may support different authentication methods for boarding.
For a given Trip, the available authentication methods can be retrieved via the ListBoardingAuthenticationMethods
RPC.
The payload of type ListBoardingAuthenticationMethodsRequest
contains the trip_id
of the Trip for which the boarding authentication methods should be listed, as well as fields to support pagination.
# export TRIP_ID="<replace with trip id>"
grpcurl \
-H "Authorization: Bearer ${ACCESS_TOKEN}" \
-H "Customer-Id: ${CUSTOMER_ID}" \
-import-path ./protos/ \
-proto "moia/ridepooling/trip/v1beta4/trip.proto" \
-proto "google/rpc/error_details.proto" \
-d "{\"trip_id\":\"$TRIP_ID\"}" \
$API_URL moia.ridepooling.trip.v1beta4.TripService/ListBoardingAuthenticationMethods
// replace with the ID of the customer who wants to know the available authentication methods
ctxWithCustomer = metadata.AppendToOutgoingContext(ctx, "customer-id", currCustomer)
boardingAuthenticationMethods, err := tripClient.ListBoardingAuthenticationMethods(
ctxWithCustomer,
&tripv1beta4.ListBoardingAuthenticationMethodsRequest{
TripId: tripId, // replace with tripId for which to list available authentication methods
},
)
if err != nil {
log.Fatalf("Could not list boarding authentication methods %v", err)
}
log.Printf("Successfully listed boarding authentication methods: %v", jsonMarshalOptions.Format(boardingAuthenticationMethods))
const listBoardingAuthenticationMethodsResponse = await client.listBoardingAuthenticationMethods(
{ tripId: orderResponse.tripId },
{
metadata: new grpc.Metadata({
// replace `currCustomerId` with the ID of the customer who is listing boarding authentication methods
"customer-id": currCustomerId,
}),
}
);
console.log(listBoardingAuthenticationMethodsResponse);
The response of type ListBoardingAuthenticationMethodsResponse
contains a list of boarding authentication methods that are available for the given Trip.
The presence of the optional field next_page_token
signifies that there are more results, which can be retrieved by sending another request with the page_token
set.
Authenticating a Customer for Boarding an Autonomous Vehicle via the API#
If ApiBoardingAuthentication
was returned as one of the available boarding authentication methods by the ListBoardingAuthenticationMethods
RPC, authentication may be done via an API call to AuthenticateForBoarding
.
The payload of type AuthenticateForBoardingRequest
contains the trip_id
of the Trip the Customer wants to board as well as a token
that will be provided to the Customer on the Autonomous Vehicle.
# export TRIP_ID="<replace with trip id>"
grpcurl \
-H "Authorization: Bearer ${ACCESS_TOKEN}" \
-H "Customer-Id: ${CUSTOMER_ID}" \
-import-path ./protos/ \
-proto "moia/ridepooling/trip/v1beta4/trip.proto" \
-proto "google/rpc/error_details.proto" \
-d "{\"trip_id\":\"$TRIP_ID\", \"token\":\"1234\"}" \
$API_URL moia.ridepooling.trip.v1beta4.TripService/AuthenticateForBoarding
// replace with the ID of the customer who is boarding the autonomous vehicle
ctxWithCustomer = metadata.AppendToOutgoingContext(ctx, "customer-id", currCustomer)
_, err = tripClient.AuthenticateForBoarding(
ctxWithCustomer,
&tripv1beta4.AuthenticateForBoardingRequest{
TripId: tripId, // replace with tripId to board
Token: "1234", // replace with token displayed on vehicle
},
)
if err != nil {
log.Printf("Could not authenticate the customer for boarding %v", err)
}
log.Print("Successfully authenticated the customer for boarding")
const authenticateForBoardingResponse = await client.authenticateForBoarding(
{
tripId: orderResponse.tripId,
token: "1234",
},
{
metadata: new grpc.Metadata({
// replace `currCustomerId` with the ID of the customer who is boarding the autonomous vehicle
"customer-id": currCustomerId,
}),
}
);
console.log(authenticateForBoardingResponse); // {} empty response
The response of type AuthenticateForBoardingResponse
is an empty message which acknowledges the successful authentication.