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


C++ ArSick::getDegreesChoicesString方法代码示例

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


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

示例1: main

int main(int argc, char **argv)
{
    Aria::init();
    ArArgumentParser argParser(&argc, argv);
    argParser.loadDefaultArguments();
    ArRobot robot;
    ArSick laser;
    std::ofstream stream; // for loggin
    time_t timer;
    char buffer[120];
    //for loggin
    ArRobotConnector robotConnector(&argParser, &robot);
    ArLaserConnector laserConnector(&argParser, &robot, &robotConnector);
    int32_t count = 0;
    readyLog(stream);
    if (!robotConnector.connectRobot())
    {
        ArLog::log(ArLog::Terse, "Could not connect to the robot.");
        if (argParser.checkHelpAndWarnUnparsed())
        {
            // -help not given, just exit.
            Aria::logOptions();
            Aria::exit(1);
            return 1;
        }
    }


    // Trigger argument parsing
    if (!Aria::parseArgs() || !argParser.checkHelpAndWarnUnparsed())
    {
        Aria::logOptions();
        Aria::exit(1);
        return 1;
    }

    ArKeyHandler keyHandler;
    Aria::setKeyHandler(&keyHandler);
    robot.attachKeyHandler(&keyHandler);

    puts("This program will make the robot wander around. It uses some avoidance\n"
        "actions if obstacles are detected, otherwise it just has a\n"
        "constant forward velocity.\n\nPress CTRL-C or Escape to exit.");

    //ArSonarDevice sonar;
    //robot.addRangeDevice(&sonar);
    robot.addRangeDevice(&laser);

    robot.runAsync(true);



    // try to connect to laser. if fail, warn but continue, using sonar only
    if (!laserConnector.connectLasers())
    {
        ArLog::log(ArLog::Normal, "Warning: unable to connect to requested lasers, will wander using robot sonar only.");
    }

    double sampleAngle, dist;
    auto sampleRange = laser.currentReadingPolar(-20, 20, &sampleAngle);
    auto degreeStr = laser.getDegreesChoicesString();

    std::cout << "auto sampleRange = laser.currentReadingPolar(-20, 20, &sampleAngle);" << sampleRange << std::endl;
    std::cout << "auto degreeStr = laser.getDegreesChoicesString(); : " << degreeStr << std::endl;


    // turn on the motors, turn off amigobot sounds
    robot.enableMotors();
    //robot.getLaserMap()
    robot.comInt(ArCommands::SOUNDTOG, 0);

    // add a set of actions that combine together to effect the wander behavior
    ArActionStallRecover recover;
    ArActionBumpers bumpers;
    ArActionAvoidFront avoidFrontNear("Avoid Front Near", 100, 0);
    ArActionAvoidFront avoidFrontFar;
    ArActionConstantVelocity constantVelocity("Constant Velocity", 400);
    
    robot.addAction(&recover, 100);
    robot.addAction(&bumpers, 75);
    robot.addAction(&avoidFrontNear, 50);
    robot.addAction(&avoidFrontFar, 49);
    robot.addAction(&constantVelocity, 25);

    stream << "IMPORTANT !! == robot.getRobotRadius() : " << robot.getRobotRadius << std::endl;
    std::string timestamp;
    while (1)
    {
        //

        //
        time(&timer);
        strftime(buffer, 80, " - timestamp : %I:%M:%S", localtime(&timer));
        timestamp = buffer;
        dist = robot.checkRangeDevicesCurrentPolar(-70, 70, &sampleAngle) - robot.getRobotRadius();
        stream << count << timestamp << "checkRangeDevicesCurrentPolar(-70, 70, &angle)  :  " << dist << std::endl;
        Sleep(500);
        count++;
    }

//.........这里部分代码省略.........
开发者ID:pmnxis,项目名称:GotoSomewhere-withLaser_LMS5xx,代码行数:101,代码来源:lasers.cpp


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