オンデマンドルート用の車両を作成する

Fleet Engine でオンデマンド走行用の車両を作成するには、CreateVehicle を使用します。 CreateVehicleRequest を持つエンドポイントです。このエンドポイントには、 Fleet Engine On-demand Admin ロール。

オンデマンドの車両のフィールド

オンデマンドの賃走用の車両を作成する場合は、必須フィールドを設定する必要があります。マイページ 特定の車両フィールドが他の車両に及ぼす影響についても 機能について説明します。詳しくは、車両フィールドを更新するをご覧ください。

オンデマンド賃走の必須項目

  • vehicle_state: デフォルトは不明ですが、「オンライン」または「オンライン」に設定する必要があります。 オフライン。車両の状態フィールドの設定について詳しくは、更新 車両フィールド
  • supported_trip_types: デフォルトは不明ですが、次のように設定する必要があります。 SHARED、EXCLUSIVE、またはその両方です。オンデマンドの賃走旅行タイプを確認してください ガイドをご覧ください。
  • maximum_capacity: 車両に乗車できる乗客の人数。 (定義上)ドライバは含まれません。
  • vehicle_type: 値は AUTOTAXITRUCKTWO-WHEELER です。 BICYCLE または PEDESTRIAN。車両のフィルタに使用可能 できます。到着予定時刻やルートの計算にも影響します。フリート エンジン さまざまな移動手段に対応するルートと 次の車両タイプグループに基づいて作成されます。
    • AUTOTAXI、または TRUCK: 高速道路など。
    • TWO_WHEELER: たとえば、オートバイが通行できないルートは返されません できます。
    • BICYCLE: 自転車専用道路など。
    • PEDESTRIAN: 歩行者専用の橋や歩道など。

その他のフィールド

車両の作成時に設定できるその他のフィールドについては、車両を更新する フィールド

車両作成の例

CreateVehicle から返される値は、作成された Vehicle エンティティです。

Java

static final String PROJECT_ID = "project-id";

VehicleServiceBlockingStub vehicleService =
    VehicleService.newBlockingStub(channel);

String parent = "providers/" + PROJECT_ID;
Vehicle vehicle = Vehicle.newBuilder()
    .setVehicleState(VehicleState.OFFLINE)  // Initial state
    .addSupportedTripTypes(TripType.EXCLUSIVE)
    .setMaximumCapacity(4)
    .setVehicleType(VehicleType.newBuilder().setCategory(VehicleType.Category.AUTO))
    .addAttributes(VehicleAttribute.newBuilder()
        .setKey("on_trip").setValue("false"))  // Opaque to the Fleet Engine
    // Add .setBackToBackEnabled(true) to make this vehicle eligible for trip
    // matching while even if it is on a trip.  By default this is disabled.
    .build();

CreateVehicleRequest createVehicleRequest =
    CreateVehicleRequest.newBuilder()  // no need for the header
        .setParent(parent)
        .setVehicleId("vid-8241890")  // Vehicle ID assigned by Rideshare or Delivery Provider
        .setVehicle(vehicle)  // Initial state
        .build();

// In this case, the Vehicle is being created in the OFFLINE state and
// no initial position is being provided.  When the Driver App checks
// in with the Rideshare or Delivery Provider, the state can be set to ONLINE and
// the Driver App will update the Vehicle Location.

try {
  Vehicle createdVehicle =
      vehicleService.createVehicle(createVehicleRequest);
} catch (StatusRuntimeException e) {
  Status s = e.getStatus();
  switch (s.getCode()) {
    case ALREADY_EXISTS:
      break;
    case PERMISSION_DENIED:
      break;
  }
  return;
}
// If no Exception, Vehicle created successfully.

REST

curl -X POST \
  "https://fleetengine.googleapis.com/v1/providers/project-id/vehicles?vehicleId=vid-8241890" \
  -H "Authorization: Bearer $JWT" \
  -H "Content-Type: application/json" \
  --data-binary @- << EOM
{
    "vehicleState": "OFFLINE",
    "supportedTripTypes": ["EXCLUSIVE"],
    "maximumCapacity": 4,
    "vehicleType": {"category": "AUTO"},
    "attributes": [{"key": "on_trip", "value": "false"}]
}
EOM

providers.vehicles.create リファレンスをご覧ください。

次のステップ