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


C++ Station::isValid方法代码示例

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


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

示例1: GRRTsolve

Trajectory PlanningProblem::GRRTsolve()
{
    this->planningResult = false;
    randomTree.clear();
    float start_time = currentTimeMSec();
    int tryExtensionCounter = 0;
    randomTree.appendNewStation(NULL, initialState);

    for(int step=0; step < MAX_RRT_STEP_TRY/5; step++)
    {
        Station target;
        float toss = uni_rand(0, 1);
        if(toss < GOAL_PROB)
            target.setPosition(goal.goal_point.getPosition());
        else {
            Station tempSt = SampleStateUniform();
            target.setPosition(tempSt.getPosition());
        }

        if( !target.isValid() )
            continue;
//            throw "can not sampled!";
        SpatialVertex* near_ver = randomTree.getNearestVertex(target);
        if(near_ver == NULL)
            continue;

        int greedyCounter = 0;
        while(greedyCounter < 5){
            tryExtensionCounter ++;
            Station extended = RRTExtend(near_ver->state, target, agent->radius() * 2);
            if(!extended.isValid())
                break;
            randomTree.appendNewStation(near_ver, extended);
            if(Station::dubinDistance(extended, target) < agent->radius() ) {
                if((target.getPosition() - goal.goal_point.getPosition()).lenght2D() < agent->radius() /2)
                    planningResult = true;
                break;
            }
//            if(target != goal.goal_point)  break;
            greedyCounter ++;
        }

        cout << "Step = " << step << endl;

    }

    if(planningResult)
    {
        float finish_time = currentTimeMSec();
        this->planningTime = finish_time - start_time;
//        cout << "Greedy RRT Planning succeed in " << planningTime << "mili seconds" << endl;
        return buildTrajectoryFromRandomTree();
    }
    return Trajectory();
}
开发者ID:amiryanj,项目名称:cyrus_ssl,代码行数:55,代码来源:planningproblem.cpp

示例2: RRTConnectSolve

// *************************************************
// ************** under construction ***************
// *************************************************
Trajectory PlanningProblem::RRTConnectSolve(double arg1)
{
    double start_time = currentTimeMSec();
    randomTree.clear();
    backward_tree.clear();
    randomTree.appendNewStation(NULL, initialState);
    backward_tree.appendNewStation(NULL, goal.goal_point);

    for(uint i=0; i< MAX_RRT_STEP_TRY ; ++i)
    {
        Station randSt = SampleStateUniform();
        if(!randSt.isValid())
            continue;
        SpatialVertex* near_ver = randomTree.getNearestVertex(randSt);
        if(near_ver == NULL)
            continue;
        Station extended_ = RRTExtend(near_ver->state, randSt, arg1);
        if(!extended_.isValid())
            continue;
        randomTree.appendNewStation(near_ver, extended_);

        for(int j=0; j<10; j++) {
            SpatialVertex* back_near = backward_tree.getNearestVertex(extended_);
            Station back_extended = RRTExtend(back_near->state, extended_, arg1);
            if(!back_extended.isValid())
                break;
            backward_tree.appendNewStation(back_near, back_extended);

            if(Station::euclideanDistance(back_extended, extended_) < agent->radius()) {
                while(back_near != NULL) {
                    Station on_back_tree_st = back_near->state;
                    on_back_tree_st.setPosition(Vector3D(back_near->state.getPosition().to2D(),
                                                         back_near->state.getPosition().Teta() + M_PI));
                    randomTree.appendNewStation(randomTree.lastAddedVertex(), on_back_tree_st);
                    back_near = back_near->parent;
                }
                planningTime = currentTimeMSec() - start_time;
                return buildTrajectoryFromRandomTree();
            }
        }
    }
    planningTime = currentTimeMSec() - start_time;
    return Trajectory();
}
开发者ID:amiryanj,项目名称:cyrus_ssl,代码行数:47,代码来源:planningproblem.cpp


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