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;
}

最新文章

  1. 苹果手机IOS中div contenteditable=true 仿文本域无法输入编辑
  2. 浅谈MySQL数据类型
  3. Js~动态判断PC和手机浏览器
  4. R语言介绍
  5. CentOS6.5菜鸟之旅:识别NTFS分区
  6. JQuery获取浏览器窗口的高度和宽度
  7. [gradle] is applicable for argument types
  8. VS 2012 插件卸载(删除自己安装的插件)
  9. 第一百二十二节,JavaScript表单处理
  10. 删除oracle数据库[转]
  11. (亲测成功)在centos7.5上安装kvm,通过VNC远程连接并创建多台ubuntu虚拟机(ubuntu server版本)
  12. [uboot] (第一章)uboot流程——概述
  13. numpy中array和asarray的区别
  14. 【吴恩达课后测验】Course 1 - 神经网络和深度学习 - 第二周测验【中英】
  15. 手打struts知识点
  16. java web各个技术细节总结
  17. STM32 中 BIT_BAND(位段/位带)和别名区使用入门(转载)
  18. Gitlab+Jenkins学习目录
  19. MoveIt运动规划-1
  20. thinkCMF----列表页跳转

热门文章

  1. spring的基于xml的AOP配置案例和切入点表达式的一些写法
  2. Python各种转义符
  3. Docker Tomcat部署
  4. Python实例 遍历文件夹和文件
  5. Leetcode49. Group Anagrams字母异位词分组
  6. 转:解决Onethink上传视频的问题 超棒的解决方案
  7. webpack学习之—— Configuration(配置)
  8. 通过sql 向数据库插入多行语句
  9. 面试问题:Vuejs如何实现双向绑定
  10. IDEA:将WEB-INF\lib下的Jar包添加到项目中