Behavior Planning--14.implement a cost function in C + +

Source: Internet
Author: User

n most situations, a single cost function is not being sufficient to produce complex vehicle behavior. In the This quiz, we ' d like the You-to-implement one more cost function in C + +. We'll use these-C, functions later in the lesson. The goal with this quiz are to create a cost function that would make the vehicle drive in the fastest possible lane, given Several behavior options. We'll provide the following four inputs to the function:

    • Target speed:currently Set as ten (unitless), the speed in which you would like the vehicle to travel.
    • Intended lane:the intended lane for the given behavior. For PLCR, PLCL, LCR, and LCL, this would is the one lane over from the current lane.
    • Final lane:the Immediate resulting lane of the given behavior. For LCR and LCL, this would is one lane over.
    • A Vector of lane speeds, based on traffic in that lane: {6, 7, 8, 9}.

Your task in the implementation is to create a cost function, that satisifes:

    • The cost decreases as both intended lane and final lane is higher speed lanes.
    • The cost function provides different costs for each possible behavior:kl, PLCR/PLCL, LCR/LCL.
    • The values produced by the cost function is in the range 0 to 1.

You can implement your solution in cost.cpp below.

Cost.cpp

float inefficiency_cost (intint intended_lane,int final_lane, vector<int > lane_speeds) {   float speed_intended=Lane_speeds[intended_lane];    float speed_final=Lane_speeds[final_lane];    float cost= (2.0*target_speed-speed_intended-speed_final)/target_speed;    return Cost ;}

Behavior Planning--14.implement a cost function in C + +

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.