Q1 : Timer.ypr_setpoint 在那裏設初始值?
A1 : 在 net.cpp ...
case UPDATE_REMOTE:
//set rcinput values values
parser.parse(data,Timer.thr,Timer.ypr_setpoint);
break;
void Parser::parse(unsigned char data[256],float &t,float ypr[]){
//returns thrust, yaw, pitch and roll walues form char data
//Processing packet
std::string packet( reinterpret_cast< char const* > (data));
std::istringstream ss(packet);
//printf("%s \n", packet.c_str());
//Getting target values from packet
do
{
std::string sub;
ss >> sub;
float cmd;
if (sub == "\"thr\":" ){ // 油門
ss >> sub;
std::istringstream( sub ) >> cmd;
t = (cmd*10 + 1080);
}
else if(sub == "\"yaw\":"){
ss >> sub;
std::istringstream( sub ) >> cmd;
ypr[0] = cmd*3.5;
}
else if(sub == "\"pitch\":"){
ss >> sub;
std::istringstream( sub ) >> cmd;
ypr[1] = cmd;
}
else if(sub == "\"roll\":"){
ss >> sub;
std::istringstream( sub ) >> cmd;
ypr[2] = cmd;
}
} while (ss);
}
他的ESC 的輸出最小值是 1000...
thr 就是後面會用到的throttle.....
Q2 : throttle 的初始值在那裏設定?
A2 :
在time.cpp 裡面會呼叫 ..
ESC.update(Timer.thr,Timer.PIDout);
然後servo.cpp 的裡面有 update 的實作
在time.cpp 裡面會呼叫 ..
ESC.update(Timer.thr,Timer.PIDout);
然後servo.cpp 的裡面有 update 的實作
void Servo::update(float throttle, float PIDoutput[DIM])
servoval[0] =(int)(throttle + PIDoutput[PITCH] + PIDoutput[YAW]);
servoval[2] =(int)(throttle - PIDoutput[PITCH] + PIDoutput[YAW]);
servoval[1] =(int)(throttle - PIDoutput[ROLL] - PIDoutput[YAW]);
servoval[3] =(int)(throttle + PIDoutput[ROLL] - PIDoutput[YAW]);
沒有留言:
張貼留言