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


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

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


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

示例1: main

int main(int argc, const char **argv){
    Cartesian c;
    
    string url(HOST);
    const string user(USER);
    const string pass(PASS);
    const string database(DB);

    string input_string, tmp, ui_input;
    vector<string> strs;
    string command_str;
    int speed, fWait;
    float distance;
    Logger logger;
    logger.setDebugLevel(Logger::INFO);
    
    PID GripPID(GripServo::MAX, GripServo::MIN);
    PID WrotPID(WrotServo::MAX, WrotServo::MIN);
    PID WristPID(WristServo::MAX, WristServo::MIN);
    PID ElbowPID(ElbowServo::MAX, ElbowServo::MIN);
    PID ShoulderPID(ShoulderServo::MAX, ShoulderServo::MIN);
    PID BasePID(BaseServo::MAX, BaseServo::MIN);
    
    Arm *currArm = new Arm();
    Arm *prevArm = new Arm();
    ForbiddenZone forbiddenZone;
    
    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());
            
//.........这里部分代码省略.........
开发者ID:k-langer,项目名称:EMERGE_Capstone,代码行数:101,代码来源:arm_updater.cpp


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