避免在自提点和送货点 U 转
使用集合让一切井井有条
根据您的偏好保存内容并对其进行分类。
默认情况下,车辆可以从任何方向到达取货或送货地点,然后从任何方向离开。在某些情况下,这会迫使车辆在访问位置掉头,但由于车辆尺寸、位置处的交通标志或通常的交通状况,掉头可能很困难或无法实现。
为防止车辆在到达指定上车点或送货点后到出发前改变方向,您可以将相应位置的 avoid_u_turns
设置为 true。在此设置下,车辆将以相同的航向到达和离开位置,从而避免掉头。在双向道路上,求解器会考虑两个方向,并选择其中一个方向作为路线优化的一部分。
您还可以将 side_of_road
设置为 true,以获取车辆在最靠近途经点的道路一侧到达和离开的路线。在这种情况下,车辆在到达和出发之间也不会改变航向。您可以将 side_of_road
和 avoid_u_turns
都设置为 true,以实现相同的结果。如需了解详情,请参阅与其他功能的互动。
在实践中,当可以安全地过马路到达途经点时,应使用 avoid_u_turns
。当不建议或无法交叉时,请使用 side_of_road
。
示例:使用 avoid_u_turns
发出 OptimizeTours
请求
可以使用 REST 或 gRPC 发出 OptimizeTours
请求。
在发出请求之前,请将以下参数替换为适合您环境的值:
请求完成后,您会收到一条回复消息。
与其他功能的互动
avoid_u_turns
可与 side_of_road = true
搭配使用。在这种情况下,系统会避免掉头,但求解器会选择一条车辆与途经点位于道路同一侧的路线,这与单独设置 side_of_road = true
类似。
- 如果某个访问请求的
avoid_u_turns = true
为 1,则相应响应中的 ShipmentRoute.Visit
会设置 injected_solution_location_token
字段。其值的确切含义是实现细节,但它会编码有关求解器所选道路一侧的信息。
- 当您使用
ShipmentRoute.Visit
作为输入请求的一部分时,如果该 ShipmentRoute.Visit
对应于 avoid_u_turns = true
中的 VisitRequest
,则 ShipmentRoute.Visit
必须包含求解器之前返回的 injected_solution_location_token
。
限制
系统会尽力避免掉头。在某些情况下,路线可能仍包含掉头:
avoid_u_turns
仅适用于支持 side_of_road
的出行方式。具体而言,此功能不支持 WALKING
出行模式。
avoid_u_turns
不能用于到达地和出发地不同的取货和送货。
- 如果取货或送货地点位于尽头路,则必须掉头才能离开该道路。
- 此功能的目的是避免在上车点和送达地点掉头。
不会避免航点之间的掉头。
- 急转弯到另一条道路不被视为掉头,系统通常不会避开此类转弯。
此功能在开发过程中还存在其他限制。随着该功能的不断完善,我们预计这些限制会逐步解除。
如未另行说明,那么本页面中的内容已根据知识共享署名 4.0 许可获得了许可,并且代码示例已根据 Apache 2.0 许可获得了许可。有关详情,请参阅 Google 开发者网站政策。Java 是 Oracle 和/或其关联公司的注册商标。
最后更新时间 (UTC):2025-08-29。
[null,null,["最后更新时间 (UTC):2025-08-29。"],[[["\u003cp\u003eVehicles typically arrive and depart from locations in any direction, potentially requiring u-turns.\u003c/p\u003e\n"],["\u003cp\u003eThe \u003ccode\u003eavoid_u_turns\u003c/code\u003e setting prevents vehicles from changing direction at a pickup or delivery location, ensuring arrival and departure with the same heading.\u003c/p\u003e\n"],["\u003cp\u003eThe \u003ccode\u003eside_of_road\u003c/code\u003e setting ensures vehicles arrive and leave on the side of the road closest to the waypoint, also avoiding changes in heading.\u003c/p\u003e\n"],["\u003cp\u003e\u003ccode\u003eavoid_u_turns\u003c/code\u003e and \u003ccode\u003eside_of_road\u003c/code\u003e can be used together to prevent u-turns while also maintaining the vehicle's position on the correct side of the road.\u003c/p\u003e\n"],["\u003cp\u003eU-turn avoidance is not supported in all travel modes, such as \u003ccode\u003eWALKING\u003c/code\u003e mode, and is also not supported when the arrival and departure locations for a delivery or pickup differ.\u003c/p\u003e\n"]]],[],null,["\u003cbr /\u003e\n\n| This product or feature is Experimental (pre-GA). Pre-GA products and features might have limited support, and changes to pre-GA products and features might not be compatible with other pre-GA versions. Pre-GA Offerings are covered by the [Google\n| Maps Platform Service Specific Terms](https://cloud.google.com/maps-platform/terms/maps-service-terms). For more information, see the [launch stage descriptions](/maps/launch-stages).\n\n\u003cbr /\u003e\n\nBy default, vehicles can arrive at a pickup or a delivery location from any\ndirection, and then leave in any direction. In some cases, this forces\nthe vehicle to make a u-turn at the visit location, which may be difficult or\nimpossible because of vehicle size, traffic signs at the location, or usual\ntraffic conditions.\n\nTo prevent vehicles from changing direction between the arrival and departure\nfor a given pickup or delivery location, you can set [`avoid_u_turns`](/maps/tt/route-optimization/experimental/u-turn-avoidance/reference/rest/v1/ShipmentModel#VisitRequest.FIELDS.avoid_u_turns) to\ntrue for this location. Under this setting, the vehicle will arrive and leave\nthe location with the same heading, thus avoiding the u-turn. On two-way roads\nthe solver will consider both directions and choose one as part of the route\noptimization.\n\nYou can also set [`side_of_road`](/maps/tt/route-optimization/experimental/u-turn-avoidance/reference/rest/v1/projects/optimizeTours#google.maps.routeoptimization.v1.Waypoint.FIELDS.bool.google.maps.routeoptimization.v1.Waypoint.side_of_road) to true to obtain a route where the vehicle\narrives and leaves on the side of the road closest to the waypoint. In this\ncase, the vehicle also does not change heading between the arrival and the\ndeparture. It is possible to set both `side_of_road` and `avoid_u_turns` to true\nto achieve the same result. For details, see [Interaction with other\nfeatures](#interaction_with_other_features).\n\nIn practice, `avoid_u_turns` should be used when it is safe to cross the road to\nget to the waypoint. Use `side_of_road` when crossing is discouraged or not\npossible.\n\nExample: Make an `OptimizeTours` request with `avoid_u_turns`\n\n`OptimizeTours` requests can be made using either [REST](/maps/tt/route-optimization/experimental/u-turn-avoidance/reference/rest/v1/projects/optimizeTours) or [gRPC](/maps/tt/route-optimization/experimental/u-turn-avoidance/reference/rpc/google.maps.routeoptimization.v1#routeoptimization).\n\nBefore making a request, replace the following parameters with values\nappropriate for your environment:\n\n- Ensure you have [Application Default Credentials](https://cloud.google.com/docs/authentication/provide-credentials-adc) configured as described in [Use OAuth](/maps/documentation/route-optimization/oauth-token).\n- Set \u003cvar label=\"project_number\" translate=\"no\"\u003ePROJECT_NUMBER_OR_ID\u003c/var\u003e to your Cloud\n project number or ID.\n\n The following command sends an `OptimizeTours` request to the Route\n Optimization API and receives a response synchronously. \n\n ```scdoc\n curl -X POST 'https://routeoptimization.googleapis.com/v1/projects/PROJECT_NUMBER_OR_ID:optimizeTours' \\\n -H \"Content-Type: application/json\" \\\n -H \"Authorization: Bearer $(gcloud auth application-default print-access-token)\" \\\n --data @- \u003c\u003cEOM\n {\n \"model\": {\n \"shipments\": [\n {\n \"pickups\": [\n {\n \"arrivalLocation\": {\n \"latitude\": 37.42506261000996,\n \"longitude\": -122.09535511930135\n },\n \"avoidUTurns\": true\n }\n ],\n \"deliveries\": [\n {\n \"arrivalLocation\": {\n \"latitude\": 37.42421503206021,\n \"longitude\": -122.09526063135228\n },\n \"avoidUTurns\": true\n }\n ]\n }\n ],\n \"vehicles\": [\n {\n \"travelMode\": \"DRIVING\",\n \"costPerKilometer\": 1.0\n }\n ],\n }\n }\n EOM\n ```\n | **Note:** this example uses the `--data @-` to read a request from standard input. Use `--data @`\u003cvar label=\"curl_filename\" translate=\"no\"\u003eFilename\u003c/var\u003e to read from a file.\n\nOnce the request completes, you'll receive a response message.\n\nInteraction with other features\n\n- `avoid_u_turns` can be used together with `side_of_road = true`. In this case, u-turns are avoided, but the solver selects a route that the vehicle is on the same side of the road as the waypoint, similar to setting `side_of_road = true` alone.\n- When `avoid_u_turns = true` for a certain visit request, then the `ShipmentRoute.Visit` in the corresponding response has the field `injected_solution_location_token` set. The precise meaning of its value is an implementation detail, but it encodes the information about the side of the road picked by the solver.\n- When you use a `ShipmentRoute.Visit` as part of the input request, if that `ShipmentRoute.Visit` corresponds to a `VisitRequest` in which `avoid_u_turns = true`, then `ShipmentRoute.Visit` must contain an `injected_solution_location_token` previously returned by the solver.\n\nLimitations\n\nU-turn avoidance is best effort. In certain situations, the route may still\ncontain u-turns:\n\n- `avoid_u_turns` works only with travel modes that support [`side_of_road`](/maps/tt/route-optimization/experimental/u-turn-avoidance/reference/rest/v1/projects/optimizeTours#google.maps.routeoptimization.v1.Waypoint.FIELDS.bool.google.maps.routeoptimization.v1.Waypoint.side_of_road). Specifically, it is not supported for the `WALKING` travel mode.\n- `avoid_u_turns` can't be used for pickups and deliveries where the arrival and departure are not the same.\n- When a pickup or a delivery is on a dead-end road, it is necessary to make a u-turn to leave the road.\n- The aim of this feature is avoiding u-turns at pickup and delivery locations. U-turns between waypoints are not avoided.\n- Very sharp turns to a different road are not considered u-turns, and they will generally not be avoided.\n\nThere are additional limitations while this feature is under development. We\nexpect them to be lifted as the feature evolves.\n\n- `avoid_u_turns` can't be used together with [`interpret_injected_solutions_using_labels`](/maps/tt/route-optimization/experimental/u-turn-avoidance/reference/rest/v1/projects/optimizeTours#google.maps.routeoptimization.v1.OptimizeToursRequest.FIELDS.bool.google.maps.routeoptimization.v1.OptimizeToursRequest.interpret_injected_solutions_using_labels)."]]