behavior planning——13. implement a cost function in C++
In the previous quizzes, you designed a cost function to choose a lane when trying to reach a goal in highway driving:
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++的更多相关文章
- 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 ...
- 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 ...
- behavior planning——15.cost function design weightTweaking
Designing cost functions is difficult and getting them all to cooperate to produce reasionable vehic ...
- 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 ...
- machine learning(11) -- classification: advanced optimization 去求cost function最小值的方法
其它的比gradient descent快, 在某些场合得到广泛应用的求cost function的最小值的方法 when have a large machine learning problem, ...
- behavior planning——10 behaior planning pseudocode
One way to implement a transition function is by generating rough trajectories for each accessible & ...
- loss function与cost function
实际上,代价函数(cost function)和损失函数(loss function 亦称为 error function)是同义的.它们都是事先定义一个假设函数(hypothesis),通过训练集由 ...
- 【caffe】loss function、cost function和error
@tags: caffe 机器学习 在机器学习(暂时限定有监督学习)中,常见的算法大都可以划分为两个部分来理解它 一个是它的Hypothesis function,也就是你用一个函数f,来拟合任意一个 ...
- 逻辑回归损失函数(cost function)
逻辑回归模型预估的是样本属于某个分类的概率,其损失函数(Cost Function)可以像线型回归那样,以均方差来表示:也可以用对数.概率等方法.损失函数本质上是衡量”模型预估值“到“实际值”的距离, ...
随机推荐
- HTML 和 XHTML 区别
1.初级改善 为页面添加正确的DOCTYPE 很多设计师和开发者都不知道什么是DOCTYPE,DOCTYPE有什么用. DOCTYPE是document type的简写.主要用来说明你用的XHTML或 ...
- TomCat 启动默认加载项目
在最后加上这句代码即可:<Context path="" docBase="\项目名称" reloadable="true" cros ...
- dom4解析 XML
Java XML解析工具 dom4j介绍及使用实例 Java XML解析工具 dom4j介绍及使用实例 dom4j介绍 dom4j的项目地址:http://sourceforge.net/projec ...
- 简单描述如何安装配置一个apache开源版hadoop,只描述即可,无需列出完整步骤,能列出步骤更好
1 ) 安装JDK并配置环境变量(/etc/profile) 2) 关闭防火墙 3) 配置hosts文件,方便hadoop通过主机名访问(/etc/hosts) 4) 设置ssh免密码登录 5) 解压 ...
- Data Lake Analytics: 使用DataWorks来调度DLA任务
DataWorks作为阿里云上广受欢迎的大数据开发调度服务,最近加入了对于Data Lake Analytics的支持,意味着所有Data Lake Analytics的客户可以获得任务开发.任务依赖 ...
- CSS Tools: Reset CSS
样式初始化 /* http://meyerweb.com/eric/tools/css/reset/ v2.0 | 20110126 License: none (public domain) */ ...
- 加快liferay 7的启动速度
在启动Liferay的过程中,你会发现在某个时刻,会特别慢,停留了很久,它是停在validate LPKGs,检验LPKG files是否被篡改,这个过程在开发的过程中十分令人头疼. 现在Lifera ...
- Lunix文件的读写权限问题
今天把在windows平台build好的lunix执行文件复制到Lunix的虚拟机上,发现可执行文件不能执行了,后来才发现文件时有读写和可执行权限的,但是是可以更改的,右键属性,把可执行属性勾选上就可 ...
- golang数据运算符
- 闲鱼Flutter&FaaS云端一体化架构
讲师介绍 国有,闲鱼架构团队负责人.在7月13号落幕的2019年Archsummit峰会上就近一年来闲鱼在Flutter&FaaS一体化项目上的探索和实践进行了分享. 传统Native+Web ...