本文整理汇总了C++中Arm::getGripLength方法的典型用法代码示例。如果您正苦于以下问题:C++ Arm::getGripLength方法的具体用法?C++ Arm::getGripLength怎么用?C++ Arm::getGripLength使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Arm
的用法示例。
在下文中一共展示了Arm::getGripLength方法的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());
//.........这里部分代码省略.........