当前位置: 首页>>代码示例>>C#>>正文


C# Tree.findClosest方法代码示例

本文整理汇总了C#中Tree.findClosest方法的典型用法代码示例。如果您正苦于以下问题:C# Tree.findClosest方法的具体用法?C# Tree.findClosest怎么用?C# Tree.findClosest使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Tree的用法示例。


在下文中一共展示了Tree.findClosest方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: generateRRTObstaclesWithPath

    public void generateRRTObstaclesWithPath(int numNodes, OccupancyGrid occupancy, int pathSearchDepth)
    {
        // Create a new tree which we will populate with nodes, with the root of the tree
        // set to the initial configuration
        tree = new Tree(initialConfiguration);
        // Loop until the graph is the requested size
        for (int i = 0; i < numNodes; i++) {
            bool clearConf = false;
            StateConfig randConf = null;
            StateConfig newConf = null;
            TreeNode<StateConfig> closestNode = null;
            // Generate a random configuration within the configuration space until one is
            // found which does not fall in any occupied cell in the occupancy grid
            while (!clearConf){
                randConf = getRandomConfiguration(limits);
                Tuple<float,float> pos = randConf.getPosition();
                // If the random configuration is occupied, generate a new one.
                if(occupancy.isOccupied(pos.first, pos.second))
                    continue;
                // Find the closest node on the current graph to the point that was generated
                closestNode = tree.findClosest(randConf, Tree.SearchMethod.BFS);
                StateConfig closestConf = closestNode.content;
                // Generate a new configuration by moving along the hyper-edge connecting
                // the closest configuration and the randomly generated one.
                newConf = closestConf + (randConf - closestConf) * increment;
                Tuple<float,float> newPos = newConf.getPosition();
                if (occupancy.isOccupied(newPos.first, newPos.second))
                    continue;

                if (!occupancy.obstacleFreeStraightPath(closestConf.getPosition(), newConf.getPosition(), pathSearchDepth))
                    continue;

                clearConf = true;
            }
            // Add the new configuration as a child of the closest node.
            TreeNode<StateConfig> newNode = tree.addNode(newConf, closestNode);
            // If we are within range of the goal with the new node, stop expanding the tree.
            if (checkGoalDist(newNode))
                break;
        }
    }
开发者ID:heuristicus,项目名称:DD2438,代码行数:41,代码来源:RRT.cs

示例2: generateRRTBasic

 /*
  * Generates an RRT with the specified number of nodes. The goalBias
  * parameter defines how biased the RRT should be towards choosing the
  * goal as the configuration to go towards. It should be a value between
  * 0 and 1.
  */
 public void generateRRTBasic(int numNodes)
 {
     // Create a new tree which we will populate with nodes, with the
     // initial configuration as the root of the tree.
     tree = new Tree(initialConfiguration);
     // Loop until the tree has the requested number of nodes
     for (int i = 0; i < numNodes; i++) {
         // Generate a random configuration within the configuration space
         StateConfig randConf = getRandomConfiguration(limits);
         // Find the closest node on the current graph to the point that was generated
         TreeNode<StateConfig> closestNode = tree.findClosest(randConf, Tree.SearchMethod.BFS);
         StateConfig closestConf = closestNode.content;
         // Generate a new configuration by moving along the hyper-edge connecting
         // the closest configuration and the randomly generated one.
         StateConfig newConf = closestConf + (randConf - closestConf) * increment;
         // Add the new configuration as a child of the closest node.
         TreeNode<StateConfig> newNode = tree.addNode(newConf, closestNode);
         // If we are within range of the goal with the new node, stop expanding the tree.
         if (checkGoalDist(newNode))
             break;
     }
 }
开发者ID:heuristicus,项目名称:DD2438,代码行数:28,代码来源:RRT.cs


注:本文中的Tree.findClosest方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。