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


C++ Agent::getPose方法代码示例

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


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

示例1: positionsCallback

void SimpleDeploymentDummy::positionsCallback(const turtlebot_deployment::PoseWithName::ConstPtr& posePtr)
{
    ROS_DEBUG("SimpleDeployment: Positions received, finding robot in database");
    // Search for agent in the catalog using functor that compares the name to an input string
    std::vector<Agent>::iterator it = std::find_if(agent_catalog_.begin(), agent_catalog_.end(), MatchString(posePtr->name) );

    // If the agent is already in the catalog, update the position and recalculate the distance.
    if ( it != agent_catalog_.end() ) {
        ROS_DEBUG("SimpleDeployment: Robot found, updating pose and distance");

        it->setPose(posePtr->pose);
        it->setDistance(distance(this_agent_.getPose(),posePtr->pose));
    }

    // else (the agent is not yet in the catalog), create an Agent object and push it into the catalog vector
    else {
        ROS_DEBUG("SimpleDeployment: Robot not found in database");

        if ( posePtr->name != this_agent_.getName() ) {
            ROS_DEBUG("SimpleDeployment: Robot is not me. Adding it to database");

            // This initializes an object called "agent" with id = 1, the pose of the incoming message, and the distance from this agent to the agent that published the message
            Agent agent( 1, *posePtr, distance(this_agent_.getPose(), posePtr->pose) );
            agent_catalog_.push_back( agent );
        }
        else {
            ROS_ERROR("SimpleDeployment: Robot is me! Updating position and adding to database");
            this_agent_.setPose(posePtr->pose);
            got_me_ = true;

            // This initializes an object called "agent" with id = 0, the pose of the incoming message, and a distance of 0.0;
            Agent agent( 0, *posePtr, 0.0 );
            agent_catalog_.push_back( agent );
        }
    }

    // Sort agent list on distance (using functor)
    std::sort( agent_catalog_.begin(), agent_catalog_.end(), SortAgentsOnDistance() );
    ROS_DEBUG("SimpleDeployment: Positions processed");
}
开发者ID:aaronma37,项目名称:muro_lab_summer,代码行数:40,代码来源:simple_deployment_dummy.cpp


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