In the previous quizzes, you designed a cost function to choose a lane when trying to reach a goal in highway driving:

cost=1−e​−​​∣Δd∣​​​​/​Δs

Here, Δ was the lateral distance between the goal lane and the final chosen lane, and Δ was the longitudinal distance from the vehicle to the goal.

In this quiz, we'd like you to implement the cost function in C++, but with one important change. The finite state machine we use for vehicle behavior also includes states for planning a lane change right or left (PLCR or PLCL), and the cost function should incorporate this information. We will provide the following four inputs to the function:

  • Intended lane: the intended lane for the given behavior. For PLCR, PLCL, LCR, and LCL, this would be the one lane over from the current lane.
  • Final lane: the immediate resulting lane of the given behavior. For LCR and LCL, this would be one lane over.
  • The Δs distance to the goal.
  • The goal lane.

Your task in the implementation will be to modify Δd in the equation above so that it satisifes:

  • Δd is smaller as both intended lane and final lane are closer to the goal lane.
  • The cost function provides different costs for each possible behavior: KL, PLCR/PLCL, LCR/LCL.
  • The values produced by the cost function are in the range 0 to 1.

You can implement your solution in cost.cpp below.

cost.cpp

float goal_distance_cost(int goal_lane, int intended_lane, int final_lane, float distance_to_goal) {
/*
The cost increases with both the distance of intended lane from the goal
and the distance of the final lane from the goal. The cost of being out of the
goal lane also becomes larger as vehicle approaches the goal.
*/
int delta_d = 2.0*goal_lane - intended_lane - final_lane;
float cost = - exp(-(abs(delta_d) / distance_to_goal));
return cost;
}

behavior planning——13. implement a cost function in C++的更多相关文章

  1. behavior planning——14.implement a cost function in C++

    n most situations, a single cost function will not be sufficient to produce complex vehicle behavior ...

  2. behavior planning——11 create a cost function speed penalty

    A  key part of getting transitions to happen when we want  them to is the design of reasonable cost ...

  3. behavior planning——15.cost function design weightTweaking

    Designing cost functions is difficult and getting them all to cooperate to produce reasionable vehic ...

  4. behavior planning——12.example cost funtion -lane change penalty

      In the image above, the blue self driving car (bottom left) is trying to get to the goal (gold sta ...

  5. machine learning(11) -- classification: advanced optimization 去求cost function最小值的方法

    其它的比gradient descent快, 在某些场合得到广泛应用的求cost function的最小值的方法 when have a large machine learning problem, ...

  6. behavior planning——10 behaior planning pseudocode

    One way to implement a transition function is by generating rough trajectories for each accessible & ...

  7. loss function与cost function

    实际上,代价函数(cost function)和损失函数(loss function 亦称为 error function)是同义的.它们都是事先定义一个假设函数(hypothesis),通过训练集由 ...

  8. 【caffe】loss function、cost function和error

    @tags: caffe 机器学习 在机器学习(暂时限定有监督学习)中,常见的算法大都可以划分为两个部分来理解它 一个是它的Hypothesis function,也就是你用一个函数f,来拟合任意一个 ...

  9. 逻辑回归损失函数(cost function)

    逻辑回归模型预估的是样本属于某个分类的概率,其损失函数(Cost Function)可以像线型回归那样,以均方差来表示:也可以用对数.概率等方法.损失函数本质上是衡量”模型预估值“到“实际值”的距离, ...

随机推荐

  1. python元祖和列表

    下面讲到的分别有: 列表:元祖 列表的定义 list(列表)是python中使用最频繁的数据类型,在其他语言中叫做数组 专门储存一串信息 列表[  ]定义,数据之间有逗号分隔 列表的索引是从0开始的 ...

  2. 中介者模式(Mediator、ConcreteMediator、Colleague Class)(租房中介)

    中介者模式就是利用一个中介对象来封装一系列的对象交互,中介者使各对象不需要显式地互相引用,从而使其耦合松散,而且可以独立地改变他们之间的交互. 就像租房的中介系统,房主跟租房者不需要知道彼此只需要,只 ...

  3. IbatchBolt和BaseTransactionalBolt区别

    void prepare(java.util.Map conf, TopologyContext context, BatchOutputCollector collector, T id) T id ...

  4. Sublime Text Version 3.2.1(Build 3207)注册

    Sublime Text Version 3.2.1, Build 3207 一. host添加地址 C:\Windows\System32\drivers\etc\hosts 127.0.0.1 l ...

  5. screen 基础用法(转)

    ####################### 屏幕分割 ######################## 1. screen2. Ctrl-a c    # create a new screen3 ...

  6. Tiles Framework

    tiles framework 详解tiles framework 详解 就是一个页面模版引擎.可以渲染页面,属于视图层. 下面给你拷贝一份详细的tiles介绍,你可以初步了解一下. Tiles框架特 ...

  7. 人物-旅行-潘德明-Info:《近代中国徒步环游世界第一人:潘德明 》

    ylbtech-人物-旅行-潘德明-Info:<近代中国徒步环游世界第一人:潘德明 > 1.返回顶部 1. 近代中国徒步环游世界第一人:潘德明 2016-10-12 18:01 “以世界为 ...

  8. PPT转PDF

    需求:可以上传ppt,前台可以预览. 在用程序将ppt转pdf的过程中,遇到几个问题,记录如下: 1.检索 COM 类工厂中 CLSID 为 {91493441-5A91-11CF-8700-00AA ...

  9. MSSQL → 02:数据库结构

    一.数据库的组成 在SQL Server 2008中,用户如何访问及使用数据库,就需要正确了解数据库中所有对象及其设置.数据库就像一个容器,它里面除了存放着数据的表之外,还有视图.存储过程.触发器.约 ...

  10. linux 下安装编译配置 QT

    注: 1,自己 make qt-everywhere-opensource-src s时,在./configure前主动装好以下3个 sudo apt-get install libX11-dev l ...