apollo DP cost计算 trajectory_cost 代码注释

本文详细解读 Apollo 自动驾驶框架中动态规划(DP)算法计算轨迹成本的代码实现,包括关键步骤、核心函数及变量解释,帮助理解轨迹优化过程。
摘要由CSDN通过智能技术生成
/******************************************************************************
 * Copyright 2017 The Apollo Authors. All Rights Reserved.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");


 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 *****************************************************************************/

/**
 * @file
 **/

#include "modules/planning/tasks/optimizers/road_graph/trajectory_cost.h"

#include "modules/common/configs/vehicle_config_helper.h"
#include "modules/common/math/vec2d.h"
#include "modules/common/proto/pnc_point.pb.h"
#include "modules/common/util/point_factory.h"
#include "modules/planning/common/planning_gflags.h"

namespace apollo {
   
namespace planning {
   

TrajectoryCost::TrajectoryCost(const DpPolyPathConfig &config,
                               const ReferenceLine &reference_line,
                               const bool is_change_lane_path,
                               const std::vector<const Obstacle *> &obstacles,
                               const common::VehicleParam &vehicle_param,
                               const SpeedData &heuristic_speed_data,
                               const common::SLPoint &init_sl_point,
                               const SLBoundary &adc_sl_boundary)
    : config_(config),
      reference_line_(&reference_line),
      is_change_lane_path_(is_change_lane_path),
      vehicle_param_(vehicle_param),
      heuristic_speed_data_(heuristic_speed_data),
      init_sl_point_(init_sl_point),
      adc_sl_boundary_(adc_sl_boundary) {
   
  const double total_time =
      std::min(heuristic_speed_data_.TotalTime(), FLAGS_prediction_total_time);

  num_of_time_stamps_ = static_cast<uint32_t>(      //总的采样点
      std::floor(total_time / config.eval_time_interval()));      //std::floor(5.88) = 5   ... std::ceil(5.88) =6

  //遍历障碍物列表 
  for (const auto *ptr_obstacle : obstacles) {
   
    if (ptr_obstacle->IsIgnore()) {
   
      continue;         //break跳出整个循环体,执行其他语句 continue跳出本次循环执行下一次循环
    } else if (ptr_obstacle->LongitudinalDecision().has_stop()) {
   
      continue;
    }
    const auto &sl_boundary = ptr_obstacle->PerceptionSLBoundary();

    
    const double adc_left_l =  //自车左边界
        init_sl_point_.l() + vehicle_param_.left_edge_to_center();
    const double adc_right_l =  //自车右边界
        init_sl_point_.l() - vehicle_param_.right_edge_to_center();
    //如果有一点不满足说明发生碰撞??? maybe
    if (adc_left_l + FLAGS_lateral_ignore_buffer < sl_boundary.start_l() ||
        adc_right_l - FLAGS_lateral_ignore_buffer > sl_boundary.end_l()) {
   
      continue;
    }

    bool is_bycycle_or_pedestrian =   //是否是自行车或者行人
        (ptr_obstacle->Perception().type() ==
             perception::PerceptionObstacle::BICYCLE ||
         ptr_obstacle->Perception().type() ==
             perception::PerceptionObstacle::PEDESTRIAN);

    if (ptr_obstacle->IsVirtual()) {
   
      // Virtual obstacle
      continue;
    } else if (ptr_obstacle->IsStatic() || is_bycycle_or_pedestrian) {
     //如果是自行车或者行人或者是静态障碍物那么将sl_boundary push进静态障碍物列表中
      static_obstacle_sl_boundaries_.push_back(std::move(sl_boundary));
    } else {
   
      
      std::vector<Box2d> box_by_time;
      //每一动态障碍物依据时间存入 box_by_time  得到该动态障碍物在整个规划时刻的B
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
### 回答1: trajectory_point是Apollo 7.0软件的一个数据结构,表示车辆在时间上的运动轨迹的一个点。它包含以下字段: - x、y、z:表示车辆在平面坐标系的位置坐标(单位:米)。 - velocity:表示车辆的速度(单位:米/秒)。 - acceleration:表示车辆的加速度(单位:米/秒^2)。 - relative_time:表示车辆位置信息相对于时间轴的偏移量(单位:秒)。 ### 回答2: 百度Apollo 7.0trajectory_point字段是指车辆轨迹点的含义。在自动驾驶系统,车辆的轨迹是指车辆在一段时间内的位置和速度的变化。而trajectory_point字段用于表示车辆在特定时刻的轨迹信息。 具体来说,trajectory_point字段包含以下几个关键信息:时间戳、车辆位置、车辆速度、车辆加速度等。时间戳用于记录该轨迹点的采集时间,以便后续对车辆轨迹的分析和处理。车辆位置可以通过经纬度或者坐标系的二维坐标来表示,用于确定车辆的具体位置。车辆速度表示车辆在该点的行驶速度,可以用来衡量车辆的运动状态。而车辆加速度则表示车辆在该点的加速度情况,可以用来推测车辆加速或减速的程度。 通过分析和处理trajectory_point字段的数据,自动驾驶系统可以获取车辆的实时轨迹信息,以便进行路径规划、决策制定等操作。同时,也可以通过与目标轨迹进行对比,进行车辆运动状态的判断和控制操作。trajectory_point字段在自动驾驶系统具有重要的作用,为系统提供了必要的车辆轨迹信息,以确保车辆在行驶过程的安全和稳定性。 ### 回答3: 百度Apollo 7.0trajectory_point字段是指自动驾驶系统的轨迹点数据。轨迹点是指车辆在行驶过程的离散位置点,它记录了车辆在连续时间段内所处的位置、速度、加速度、航向角等信息。 trajectory_point字段包含了多个轨迹点,每个轨迹点由一组参数组成。其,位置信息包括经度、纬度和海拔高度,用于确定车辆的准确位置。速度和加速度信息表示车辆在该位置点的速度和加速度大小,用于描述车辆的运动状态。 另外,航向角是指车辆行驶方向与正北方向的夹角,表示车辆的朝向。在trajectory_point字段,航向角数据可以用于车辆导航和路径规划等算法,以确保车辆按照预定路径行驶。 通过记录和更新trajectory_point字段的数据,自动驾驶系统可以实时获取车辆的位置、速度、加速度和朝向等信息,从而进行路径规划、障碍物检测和决策控制等任务。此外,trajectory_point字段的数据也可以用于生成车辆的轨迹曲线,为系统提供一种准确的车辆运动描述。 总之,百度Apollo 7.0trajectory_point字段是自动驾驶系统记录车辆位置、速度、加速度和朝向等信息的重要数据字段,它为系统的决策控制和路径规划提供了关键的输入。
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值