zoukankan      html  css  js  c++  java
  • behavior planning——10 behaior planning pseudocode

    One way to implement a transition function is by generating rough trajectories for each accessible "next state" and then finding the best. To "find the best" we generally use cost functions. We can then figure out how costly each rough trajectory is and then select the state with the lowest cost trajectory.

    We'll discuss this in more detail later, but first read carefully through the pseudocode below to get a better sense for how a transition function might work.

    def transition_function(predictions, current_fsm_state, current_pose, cost_functions, weights):
        # only consider states which can be reached from current FSM state.
        possible_successor_states = successor_states(current_fsm_state)
    
        # keep track of the total cost of each state.
        costs = []
        for state in possible_successor_states:
            # generate a rough idea of what trajectory we would
            # follow IF we chose this state.
            trajectory_for_state = generate_trajectory(state, current_pose, predictions)
    
            # calculate the "cost" associated with that trajectory.
            cost_for_state = 0
            for i in range(len(cost_functions)) :
                # apply each cost function to the generated trajectory
                cost_function = cost_functions[i]
                cost_for_cost_function = cost_function(trajectory_for_state, predictions)
    
                # multiply the cost by the associated weight
                weight = weights[i]
                cost_for_state += weight * cost_for_cost_function
             costs.append({'state' : state, 'cost' : cost_for_state})
    
        # Find the minimum cost state.
        best_next_state = None
        min_cost = 9999999
        for i in range(len(possible_successor_states)):
            state = possible_successor_states[i]
            cost  = costs[i]
            if cost < min_cost:
                min_cost = cost
                best_next_state = state 
    
        return best_next_state

    Obviously we are glossing over some important details here. Namely: what are these cost functions and how do we create them? We'll talk about that next!

  • 相关阅读:
    21天学通 C++(第8版) 内涵目录
    Python Linux系统管理与自动化运维
    零起点PYTHON足彩大数据与机器学习实盘分析
    Elasticsearch探索之路的障碍
    WEB程序设计 第7版
    Qt使用电容屏
    Hi3531D 交叉编译 Qt5.12.8
    Hi3531D 静态交叉编译 Qt5.13.2
    Qt 常用JSON解析示例
    Windows下搭建UBuntu + Qt 5开发环境
  • 原文地址:https://www.cnblogs.com/fuhang/p/8983828.html
Copyright © 2011-2022 走看看