From de93779d4c9a60f58ce6a9573b360bc0e85c7a4b Mon Sep 17 00:00:00 2001 From: z Date: Tue, 21 Apr 2020 09:04:52 +0800 Subject: [PATCH 1/2] battery volt mah edit --- ArduCopter/Parameters.cpp | 4 +-- ArduCopter/Parameters.h | 2 +- ArduCopter/UserCode.cpp | 47 ++++++++++++++++++----------- Tools/ardupilotwaf/git_submodule.py | 2 ++ 4 files changed, 34 insertions(+), 21 deletions(-) diff --git a/ArduCopter/Parameters.cpp b/ArduCopter/Parameters.cpp index f6ab7685dd..ff5acdd14d 100644 --- a/ArduCopter/Parameters.cpp +++ b/ArduCopter/Parameters.cpp @@ -1624,7 +1624,7 @@ const char* Copter::get_sysid_board_id(void) int32_t nameValue1 =(int32_t) g.sysid_board_name_1st; int32_t nameValue2 = (int32_t)g.sysid_board_name_2nd; - char name[6] = {' ',' ',' ',' ',' ','.'}; + char name[7] = {' ',' ',' ',' ',' '}; // memset(name,0,6); nameValue2 = nameValue2 & 0xffffff; // name[5] = "a"; @@ -1633,6 +1633,6 @@ const char* Copter::get_sysid_board_id(void) name[2] = nameValue2>>16& 0xFF; name[1] = nameValue1&0xFF; name[0] = nameValue1>>8 & 0xFF; - snprintf(buf, sizeof(buf), "Version: zr-v4.0 ,Board ID: ZRZK.%5s%d",name,(int)g.sysid_board_id); + snprintf(buf, sizeof(buf), "Version: zr-v4.0 ,Board ID: ZRZK.%s.%d",name,(int)g.sysid_board_id); return buf; } \ No newline at end of file diff --git a/ArduCopter/Parameters.h b/ArduCopter/Parameters.h index 7b55d373c6..8945b5c5d8 100644 --- a/ArduCopter/Parameters.h +++ b/ArduCopter/Parameters.h @@ -397,7 +397,7 @@ public: AP_Int16 throttle_behavior; AP_Float pilot_takeoff_alt; - AP_Int16 rtl_altitude; + AP_Int32 rtl_altitude; AP_Int16 rtl_speed_cms; AP_Float rtl_cone_slope; #if RANGEFINDER_ENABLED == ENABLED diff --git a/ArduCopter/UserCode.cpp b/ArduCopter/UserCode.cpp index e3d2895280..d84818aa07 100644 --- a/ArduCopter/UserCode.cpp +++ b/ArduCopter/UserCode.cpp @@ -57,28 +57,39 @@ void Copter::userhook_SlowLoop() #endif #ifdef USERHOOK_SUPERSLOWLOOP +static float batt_mah_teb[] = +{ + 25.20,24.90,24.84,24.76,24.69,24.64,24.60,24.57,24.54,24.52, + 24.50,24.48,24.45,24.43,24.40,24.36,24.32,24.26,24.21,24.14, + 24.07,24.00,23.94,23.88,23.79,23.71,23.65,23.58,23.51,23.46, + 23.41,23.36,23.30,23.24,23.19,23.13,23.07,23.01,22.95,22.91, + 22.86,22.81,22.76,22.70,22.65,22.59,22.54,22.48,22.43,22.37, + 22.31,22.26,22.21,22.16,22.11,22.06,22.01,21.96,21.92,21.88, + 21.84,21.79,21.76,21.72,21.69,21.64,21.59,21.54,21.49,21.45, + 21.40,21.34,21.29,21.24,21.18,21.13,21.07,21.02,20.96,20.90, + 20.85,20.80,20.75,20.69,20.63,20.56,20.47,20.29,20.16,20.04, + 19.88,19.73,19.53,19.34,19.19,19.00,18.80,18.51,18.00,17.40, + 16.80 +}; void Copter::userhook_SuperSlowLoop() { // put your 1Hz code here - // if(!motors->armed()) - // { - // camera.set_trigger_distance(0); // @Brown , stop take photos - // } - - // float proximity_alt_diff; - // AP_Proximity *proximity = AP::proximity(); - // if (proximity && proximity->get_horizontal_distance(0,proximity_alt_diff)) { + static bool before_fly = true; + if(motors->armed()) + before_fly = false; + if(before_fly){ + uint8_t cnt,cacl_volt_pst; + float delt_volt; + for(cnt = 0; cnt<102; cnt++ ){ + delt_volt = batt_mah_teb[cnt] - battery.voltage(); + // delt_volt = batt_mah_teb[cnt] - test_volt; + if(delt_volt <= 0) + break; + } + cacl_volt_pst = 100 - cnt; + battery.reset_remaining(1, cacl_volt_pst); + } - // if(proximity_alt_diff < 40.0) - // { - - // if(control_mode != Mode::Number::BRAKE) - // gcs().send_text(MAV_SEVERITY_INFO, "Dist: %f, stop",proximity_alt_diff); - // control_mode = Mode::Number::BRAKE; - - // } - - // } } #endif diff --git a/Tools/ardupilotwaf/git_submodule.py b/Tools/ardupilotwaf/git_submodule.py index 579e600ebb..464ce5cd5f 100644 --- a/Tools/ardupilotwaf/git_submodule.py +++ b/Tools/ardupilotwaf/git_submodule.py @@ -133,6 +133,7 @@ def git_submodule_update(self, name): @feature('git_submodule') @before_method('process_source') def process_module_dependencies(self): + return self.git_submodule = getattr(self, 'git_submodule', '') if not self.git_submodule: self.bld.fatal('git_submodule: empty or missing git_submodule argument') @@ -158,6 +159,7 @@ def git_submodule_post_fun(bld): bld.add_post_fun(_post_fun) def _git_head_hash(ctx, path, short=False): + return 1 cmd = [ctx.env.get_flat('GIT'), 'rev-parse'] if short: cmd.append('--short=8') From a728e9ecf80f43f923d89c5d48c67c5f6333c842 Mon Sep 17 00:00:00 2001 From: z Date: Sun, 26 Apr 2020 09:48:40 +0800 Subject: [PATCH 2/2] fix id issus --- ArduCopter/Parameters.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ArduCopter/Parameters.cpp b/ArduCopter/Parameters.cpp index ff5acdd14d..c86cfb71ba 100644 --- a/ArduCopter/Parameters.cpp +++ b/ArduCopter/Parameters.cpp @@ -1633,6 +1633,6 @@ const char* Copter::get_sysid_board_id(void) name[2] = nameValue2>>16& 0xFF; name[1] = nameValue1&0xFF; name[0] = nameValue1>>8 & 0xFF; - snprintf(buf, sizeof(buf), "Version: zr-v4.0 ,Board ID: ZRZK.%s.%d",name,(int)g.sysid_board_id); + snprintf(buf, sizeof(buf), "Version: zr-v4.0.1,Board ID: ZRZK.%s.%d",name,(int)g.sysid_board_id); return buf; } \ No newline at end of file