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


C++ Arm::setToArm方法代码示例

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


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

示例1: main


//.........这里部分代码省略.........
    
    try{
        //connect to database
        sql::Connection *con;
        sql::mysql::MySQL_Driver * driver;
        driver = sql::mysql::get_mysql_driver_instance();
        con = driver->connect(url, user, pass);
        con->setSchema(database);
        logger.i("Database is connected");
        
        std::auto_ptr< sql::Statement > stmt(con->createStatement());
        std::auto_ptr< sql::ResultSet > res;

        while(1){
            stmt->execute("CALL get_xyz(@rs)"); 
            
            res.reset(stmt->executeQuery("select @rs as _val"));
            while (res->next()) {
                tmp = res->getString("_val");
                strs = split(tmp, ' ');
            }
            if(tmp.length() == 0){
                usleep(SLEEP_TIME);
                continue;
            }

            logger.i("Data available...");

            if(strs.size() != XYZ_INPUT_COUNT){
                logger.d("Ignore this bad input:" + emerge(strs, ' '));
                continue;
            }
            logger.i("processing input:" + emerge(strs, ' '));
            command_str = strs[0];
            
            if(command_str == CONTROLLING_DISABLE) {
                logger.i("Controlling is not enabled!");
                continue;
            }
            
            //set goal XYZ Position
            c.setX(atof(strs[1].c_str()) + 50);
            c.setY(atof(strs[2].c_str()));
            c.setZ(atof(strs[3].c_str()) - BASE_HEIGHT*2 - 50);
            
            if(c.getZ() < -50 || forbiddenZone.contains(c)){
                logger.d("Ignore input...");
                logger.d(c.toString());
                continue;
            }
            
            currArm->setPosition(c);
            currArm->setWristAngle(atof(strs[4].c_str()));
            currArm->setGripLength(atof(strs[8].c_str()));
            currArm->setWrotAngle(atof(strs[5].c_str()));
            if(!currArm->convertXYZToRaw()){
                logger.d("Input ignore...");
                logger.d(currArm->toString());
                continue;
            }
            ui_input = (currArm->getElbowXYZ()).toUICommandString();
            ui_input += " ";
            ui_input += (currArm->getWristXYZ()).toUICommandString();
            ui_input += " ";
            ui_input += c.toUICommandString();
            ui_input += " ";
            ui_input += to_string(currArm->getWrotAngle());
            ui_input += " ";
            ui_input += to_string(currArm->getGripLength());
            
            logger.i(currArm->toString());
            
            fWait = atoi(strs[7].c_str());
            
            int change = getBiggestChange(currArm,prevArm);
            speed = change / PROPER_SPEED;
            prevArm->setToArm(currArm);
            input_string = "CALL add_input('";
            input_string += command_str;
            input_string += Helper::formatString(to_string(currArm->getBaseRaw()),3);
            input_string += Helper::formatString(to_string(currArm->getShoulderRaw()),3);
            input_string += Helper::formatString(to_string(currArm->getElbowRaw()),3);
            input_string += Helper::formatString(to_string(currArm->getWristRaw()),3);
            input_string += Helper::formatString(to_string(currArm->getWrotRaw()),3);
            input_string += Helper::formatString(to_string(currArm->getGripRaw()),3);
            input_string += Helper::formatString(to_string(speed),4);
            input_string += Helper::formatString(to_string(fWait),1);
            input_string += "')";
            logger.i("Success:" + input_string);
            stmt->execute(input_string);
            stmt->execute("CALL add_ui_input('"+ui_input+"')");
            usleep(speed);
        }

        
    }catch(sql::SQLException &e){
        logger.e(e.what());
        return EXIT_FAILURE;
    }
}
开发者ID:k-langer,项目名称:EMERGE_Capstone,代码行数:101,代码来源:arm_updater.cpp


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