|
|
马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有帐号?立即注册
x
修改了MWC的Position HOLD部分的代码。现在的MWC稳如泰山!
在原代码中加入红色部分的代码
代码分两种情况:
1. 用I2C转接板连接GPS的。
只需要修改两处:
在I2C_GPS_NAV.ino里面修改
// 以下是要修改的代码
static void GPS_calc_poshold(int x_error, int y_error)
{
int32_t p,i,d;
int32_t output;
int32_t x_target_speed, y_target_speed;
// East / West
x_target_speed = pi_poshold_lon.get_p(x_error); // calculate desired speed from lon error
x_target_speed = constrain(x_target_speed,-100,100);
x_rate_error = x_target_speed - x_actual_speed; // calc the speed error
......
......
......
// North / South
y_target_speed = pi_poshold_lat.get_p(y_error); // calculate desired speed from lat error
y_target_speed = constrain(y_target_speed,-100,100);
......
......
......
在GPS.ino里修改
void GPS_NewData() {
uint8_t axis;
#if defined(I2C_GPS)
static uint8_t GPS_pids_initialized;
static uint8_t _i2c_gps_status;
......
......
......
if (_i2c_gps_status & I2C_GPS_STATUS_NEW_DATA) { //Check about new data
if (GPS_update) { GPS_update = 0;} else { GPS_update = 1;} //Fancy flash on GUI :D
if (!GPS_pids_initialized) {
GPS_set_pids();
GPS_pids_initialized = 1;
}
//Read GPS data for distance, heading and gps position
......
......
同时,需要把Pos,PosR,NavR的D修改成0
2. 用串口连接GPS的代码
我没有串口连接GPS的代码,但是懂代码的朋友,应该 自已可以找到GPS.ino里相关的函数进行修改。
|
| |