121341443 发表于 2013-10-2 21:23:35

稳定的MWC

http://v.youku.com/v_show/id_XNDQ4MjM0MTI0.html修改了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里相关的函数进行修改。

不帅 发表于 2014-3-16 03:20:33

求沙发

逍遥一派 发表于 2014-3-16 03:20:36

前排,哇咔咔
页: [1]
查看完整版本: 稳定的MWC