模吧

 找回密码
 立即注册

QQ登录

只需一步,快速开始

手机号码,快捷登录

1193查看 | 2回复

稳定的MWC

[复制链接]
发表于 2013-10-2 21:23:35 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。

您需要 登录 才可以下载或查看,没有帐号?立即注册

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里相关的函数进行修改。

发表于 2014-3-16 03:20:33 | 显示全部楼层
求沙发
发表于 2014-3-16 03:20:36 | 显示全部楼层
前排,哇咔咔
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

关闭

站长推荐上一条 /1 下一条

QQ|关于模吧|APP下载|广告报价|手机版|企业会员|商城入驻|联系我们|模吧 ( 黔ICP备2022002348号-1 )

© 2013-2020 Moz8.com 模吧,玩出精彩!