From 7ff5a5bbfa815eeb50f19a4c3bf92bf6cc314712 Mon Sep 17 00:00:00 2001 From: zbr Date: Sat, 7 Nov 2020 17:09:42 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A07s=E7=94=B5=E9=87=8F=E8=A1=A8?= =?UTF-8?q?=EF=BC=8C=E5=A2=9E=E5=8A=A0MAVFTP=E5=A0=86=E6=A0=88=E5=A4=A7?= =?UTF-8?q?=E5=B0=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ArduCopter/zr_flight.cpp | 42 +++++++++++++++++-- copy.sh | 2 + just_build.sh | 2 + libraries/AP_BattMonitor/AP_BattMonitor.cpp | 8 ++++ libraries/AP_BattMonitor/AP_BattMonitor.h | 2 +- .../AP_BattMonitor/AP_BattMonitor_Params.cpp | 2 + .../AP_BattMonitor/AP_BattMonitor_Params.h | 2 + libraries/AP_HAL/AP_HAL_Boards.h | 2 +- libraries/GCS_MAVLink/GCS_FTP.cpp | 2 +- sitl.sh | 1 + 10 files changed, 58 insertions(+), 7 deletions(-) create mode 100755 copy.sh create mode 100755 just_build.sh create mode 100755 sitl.sh diff --git a/ArduCopter/zr_flight.cpp b/ArduCopter/zr_flight.cpp index f79a80fb22..ad4578ca17 100644 --- a/ArduCopter/zr_flight.cpp +++ b/ArduCopter/zr_flight.cpp @@ -68,6 +68,20 @@ void Copter::zr_SuperSlowLoop(){ 19.88,19.73,19.53,19.34,19.19,19.00,18.80,18.51,18.00,17.40, 16.80 }; + static float batt_mah_teb_7s[] = + { + 29.30,29.13,28.97,28.86,28.77,28.71,28.67,28.64,28.61,28.59, + 28.56,28.53,28.50,28.46,28.43,28.38,28.33,28.28,28.21,28.16, + 28.10,28.03,27.94,27.87,27.80,27.75,27.66,27.59,27.52,27.46, + 27.38,27.32,27.26,27.19,27.13,27.07,27.00,26.93,26.85,26.79, + 26.74,26.67,26.61,26.54,26.47,26.4,26.35,26.28,26.21,26.16, + 26.1,26.05,25.98,25.91,25.85,25.79,25.74,25.69,25.63,25.58, + 25.54,25.5,25.45,25.41,25.36,25.32,25.27,25.23,25.18,25.13, + 25.08,25.03,24.97,24.93,24.86,24.8,24.74,24.67,24.6,24.52, + 24.46,24.39,24.3,24.25,24.22,24.18,24.1,24.02,23.94,23.81, + 23.65,23.52,23.32,23.19,22.95,22.74,22.52,22.28,22.04,21.8, + 21.6, + }; if(motors->armed()){ if(before_fly){ @@ -86,10 +100,30 @@ void Copter::zr_SuperSlowLoop(){ 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) + cnt = 0; + switch (battery.get_batt_type(1)) + { + case 0: + /* code */ + break; + case 1: + 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; + } + break; + case 2: + for(cnt = 0; cnt<102; cnt++ ){ + delt_volt = batt_mah_teb_7s[cnt] - battery.voltage(); + // delt_volt = batt_mah_teb[cnt] - test_volt; + if(delt_volt <= 0) + break; + } + break; + + default: break; } cacl_volt_pst = 100 - cnt; diff --git a/copy.sh b/copy.sh new file mode 100755 index 0000000000..675504696f --- /dev/null +++ b/copy.sh @@ -0,0 +1,2 @@ +sudo cp ./build/Pixhawk4/bin/arducopter.apj /mnt/f/_01-work/100\=data/固件/zr-v4/wsl/zr-v4.0.8-rc2.px4 + diff --git a/just_build.sh b/just_build.sh new file mode 100755 index 0000000000..16ab51fd80 --- /dev/null +++ b/just_build.sh @@ -0,0 +1,2 @@ +./waf configure --board Pixhawk4 +./waf copter diff --git a/libraries/AP_BattMonitor/AP_BattMonitor.cpp b/libraries/AP_BattMonitor/AP_BattMonitor.cpp index 126ab5c6e5..8ab0394ece 100644 --- a/libraries/AP_BattMonitor/AP_BattMonitor.cpp +++ b/libraries/AP_BattMonitor/AP_BattMonitor.cpp @@ -499,6 +499,14 @@ void AP_BattMonitor::request_history(void) } } +uint8_t AP_BattMonitor::get_batt_type(uint8_t i) +{ + + if (drivers[i] != nullptr && _params[i].type() == AP_BattMonitor_Params::BattMonitor_TYPE_ANALOG_VOLTAGE_AND_CURRENT) { + return _params[i].batt_type(); + } + return 0; +} /* reset battery remaining percentage for batteries that integrate to diff --git a/libraries/AP_BattMonitor/AP_BattMonitor.h b/libraries/AP_BattMonitor/AP_BattMonitor.h index 7cee5334be..c785a22960 100644 --- a/libraries/AP_BattMonitor/AP_BattMonitor.h +++ b/libraries/AP_BattMonitor/AP_BattMonitor.h @@ -166,7 +166,7 @@ public: void request_info(void) ; //battgo void request_history(void) ; //battgo - + uint8_t get_batt_type(uint8_t i); protected: /// parameters diff --git a/libraries/AP_BattMonitor/AP_BattMonitor_Params.cpp b/libraries/AP_BattMonitor/AP_BattMonitor_Params.cpp index 5ae21589b0..906e92bbd6 100644 --- a/libraries/AP_BattMonitor/AP_BattMonitor_Params.cpp +++ b/libraries/AP_BattMonitor/AP_BattMonitor_Params.cpp @@ -171,6 +171,8 @@ const AP_Param::GroupInfo AP_BattMonitor_Params::var_info[] = { AP_GROUPINFO("DROPOUT_V", 20, AP_BattMonitor_Params, _arming_dropout_voltage, 0), AP_GROUPINFO("CELL_TOTAL", 21, AP_BattMonitor_Params, _batt_cells_amount, 0), + + AP_GROUPINFO("BAT_TYPE", 22, AP_BattMonitor_Params, _batt_type, 1), AP_GROUPEND diff --git a/libraries/AP_BattMonitor/AP_BattMonitor_Params.h b/libraries/AP_BattMonitor/AP_BattMonitor_Params.h index 18cca08943..31488e8ea2 100644 --- a/libraries/AP_BattMonitor/AP_BattMonitor_Params.h +++ b/libraries/AP_BattMonitor/AP_BattMonitor_Params.h @@ -36,6 +36,7 @@ public: BattMonitor_Type type(void) const { return (enum BattMonitor_Type)_type.get(); } BattMonitor_LowVoltage_Source failsafe_voltage_source(void) { return (enum BattMonitor_LowVoltage_Source)_failsafe_voltage_source.get(); } + int8_t batt_type( ) const { return _batt_type;} ; AP_Int8 _type; /// 0=disabled, 3=voltage only, 4=voltage and current AP_Int8 _volt_pin; /// board pin used to measure battery voltage @@ -58,4 +59,5 @@ public: AP_Float _arming_minimum_voltage; /// voltage level required to arm AP_Float _arming_dropout_voltage; /// voltage level required to arm AP_Int8 _batt_cells_amount; /// voltage level required to arm + AP_Int8 _batt_type; /// voltage level required to arm }; diff --git a/libraries/AP_HAL/AP_HAL_Boards.h b/libraries/AP_HAL/AP_HAL_Boards.h index fe5760461f..71bdf2019c 100644 --- a/libraries/AP_HAL/AP_HAL_Boards.h +++ b/libraries/AP_HAL/AP_HAL_Boards.h @@ -162,7 +162,7 @@ #endif #ifndef HAL_WITH_UAVCAN -#define HAL_WITH_UAVCAN 1 +#define HAL_WITH_UAVCAN 0 #endif #ifndef HAL_RCINPUT_WITH_AP_RADIO diff --git a/libraries/GCS_MAVLink/GCS_FTP.cpp b/libraries/GCS_MAVLink/GCS_FTP.cpp index 6f1aae2a4a..2e2f44aa27 100644 --- a/libraries/GCS_MAVLink/GCS_FTP.cpp +++ b/libraries/GCS_MAVLink/GCS_FTP.cpp @@ -42,7 +42,7 @@ bool GCS_MAVLINK::ftp_init(void) { } if (!hal.scheduler->thread_create(FUNCTOR_BIND_MEMBER(&GCS_MAVLINK::ftp_worker, void), - "FTP", 1024, AP_HAL::Scheduler::PRIORITY_IO, 0)) { + "FTP", 3072, AP_HAL::Scheduler::PRIORITY_IO, 0)) { goto failed; } diff --git a/sitl.sh b/sitl.sh new file mode 100755 index 0000000000..68405a1405 --- /dev/null +++ b/sitl.sh @@ -0,0 +1 @@ +./Tools/autotest/sim_vehicle.py -j4 -L CYDS --console --map -v ArduCopter