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!

  • 相关阅读:
    拆分字符串为单条记录
    Howto: Change Windows Hostname and Keep Oracle 10g Running
    关于Oracle的MTS
    linux/centos Header V3 DSA signature: NOKEY, key ID 错误解决方法
    cacti0.8.7d安装
    Identifying Host Names and IP Addresses
    修改Oracle字符集(character set)
    企业管理器(OEM)介绍: Grid Control 和 Database Control
    搞OMS真折腾
    ORA12560: TNS: 协议适配器错误
  • 原文地址:https://www.cnblogs.com/fuhang/p/8983828.html
Copyright © 2011-2022 走看看