From 8eb68e5b79c3ddd4e14f9349441e31b5f4a014a3 Mon Sep 17 00:00:00 2001 From: zbr3550 Date: Wed, 23 Mar 2022 13:08:58 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0AC=5FZR=5FApp=EF=BC=8C?= =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E4=B8=80=E4=BA=9B=E5=8F=82=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ArduCopter/Copter.h | 3 ++ ArduCopter/Parameters.cpp | 2 ++ ArduCopter/Parameters.h | 1 + ArduCopter/wscript | 1 + just_build.sh | 2 ++ libraries/AC_ZR_APP/AC_ZR_App.cpp | 51 +++++++++++++++++++++++++++++++ libraries/AC_ZR_APP/AC_ZR_App.h | 48 +++++++++++++++++++++++++++++ 7 files changed, 108 insertions(+) create mode 100755 just_build.sh create mode 100644 libraries/AC_ZR_APP/AC_ZR_App.cpp create mode 100644 libraries/AC_ZR_APP/AC_ZR_App.h diff --git a/ArduCopter/Copter.h b/ArduCopter/Copter.h index 362b1a4558..9f30739074 100644 --- a/ArduCopter/Copter.h +++ b/ArduCopter/Copter.h @@ -70,6 +70,8 @@ #include // ADS-B RF based collision avoidance module library #include // ArduPilot proximity sensor library +#include + // Configuration #include "defines.h" #include "config.h" @@ -993,6 +995,7 @@ private: Mode *mode_from_mode_num(const Mode::Number mode); void exit_mode(Mode *&old_flightmode, Mode *&new_flightmode); + AC_ZR_App zr_app; public: void failsafe_check(); // failsafe.cpp }; diff --git a/ArduCopter/Parameters.cpp b/ArduCopter/Parameters.cpp index 1b4e3354a8..e7333d7d5a 100644 --- a/ArduCopter/Parameters.cpp +++ b/ArduCopter/Parameters.cpp @@ -734,6 +734,8 @@ const AP_Param::Info Copter::var_info[] = { // @Path: Parameters.cpp GOBJECT(g2, "", ParametersG2), + GOBJECT(zr_app, "ZR", AC_ZR_App), + // @Group: // @Path: ../libraries/AP_Vehicle/AP_Vehicle.cpp { AP_PARAM_GROUP, "", Parameters::k_param_vehicle, (const void *)&copter, {group_info : AP_Vehicle::var_info} }, diff --git a/ArduCopter/Parameters.h b/ArduCopter/Parameters.h index e3fe66cf27..74eeb1a435 100644 --- a/ArduCopter/Parameters.h +++ b/ArduCopter/Parameters.h @@ -376,6 +376,7 @@ public: // 254,255: reserved k_param_vehicle = 257, // vehicle common block of parameters + k_param_zr_app = 258, // 253 - Logging Group // the k_param_* space is 9-bits in size // 511: reserved diff --git a/ArduCopter/wscript b/ArduCopter/wscript index 863834ad4e..2b5256c976 100644 --- a/ArduCopter/wscript +++ b/ArduCopter/wscript @@ -31,6 +31,7 @@ def build(bld): 'AP_OSD', 'AC_AutoTune', 'AP_KDECAN', + 'AC_ZR_APP', ], ) diff --git a/just_build.sh b/just_build.sh new file mode 100755 index 0000000000..7adeb3257d --- /dev/null +++ b/just_build.sh @@ -0,0 +1,2 @@ +./waf configure --board Pixhawk4 +./waf copter \ No newline at end of file diff --git a/libraries/AC_ZR_APP/AC_ZR_App.cpp b/libraries/AC_ZR_APP/AC_ZR_App.cpp new file mode 100644 index 0000000000..77ed3858f4 --- /dev/null +++ b/libraries/AC_ZR_APP/AC_ZR_App.cpp @@ -0,0 +1,51 @@ +/* + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . + */ +#include "AC_ZR_App.h" + + +AC_ZR_App *AC_ZR_App::_singleton; + +// table of user settable parameters +const AP_Param::GroupInfo AC_ZR_App::var_info[] = { + // @Param: _TYPE + // @DisplayName: 1st GPS type + // @Description: GPS type of 1st GPS + // @Values: 0:None,1:AUTO,2:uBlox,3:MTK,4:MTK19,5:NMEA,6:SiRF,7:HIL,8:SwiftNav,9:UAVCAN,10:SBF,11:GSOF,13:ERB,14:MAV,15:NOVA,16:HemisphereNMEA,17:uBlox-MovingBaseline-Base,18:uBlox-MovingBaseline-Rover,19:MSP,20:AllyStar,21:ExternalAHRS + // @RebootRequired: True + // @User: Advanced + AP_GROUPINFO("_TYPE", 0, AC_ZR_App, _type, 1), + + AP_GROUPINFO("_ID_TYPE", 1, AC_ZR_App, sysid_type, 0 ), + AP_GROUPINFO("_ID_BOARD_ID", 2, AC_ZR_App, sysid_board_id, 100), + AP_GROUPINFO("_ID_DL1", 3, AC_ZR_App, sysid_dl1, 0x8175), + AP_GROUPINFO("_ID_DL2", 4, AC_ZR_App, sysid_dl2, 0x6fda), + AP_GROUPINFO("_ID_DL3", 5, AC_ZR_App, sysid_dl3, 0xf38f), + AP_GROUPINFO("_ID_DL4", 6, AC_ZR_App, sysid_dl4, 0xbf48), + + + AP_GROUPEND +}; + +// constructor +AC_ZR_App::AC_ZR_App() +{ + + AP_Param::setup_object_defaults(this, var_info); + + if (_singleton != nullptr) { + AP_HAL::panic("AC_ZR_App must be singleton"); + } + _singleton = this; +} diff --git a/libraries/AC_ZR_APP/AC_ZR_App.h b/libraries/AC_ZR_APP/AC_ZR_App.h new file mode 100644 index 0000000000..6aad2817af --- /dev/null +++ b/libraries/AC_ZR_APP/AC_ZR_App.h @@ -0,0 +1,48 @@ +/* + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . + */ +#pragma once + +#include +#include + +class AC_ZR_App +{ +public: + AC_ZR_App(); + /* Do not allow copies */ + AC_ZR_App(const AC_ZR_App &other) = delete; + AC_ZR_App &operator=(const AC_ZR_App&) = delete; + + static AC_ZR_App *get_singleton() { + return _singleton; + } + + static const struct AP_Param::GroupInfo var_info[]; + +protected: + + AP_Int8 _type; + AP_Int8 sysid_type; // modify by @Brown + AP_Int32 sysid_board_id; + AP_Int32 sysid_dl1; + AP_Int32 sysid_dl2; + AP_Int32 sysid_dl3; + AP_Int32 sysid_dl4; + +private: + static AC_ZR_App *_singleton; + + void get_deadline_params(int32_t &deadline); +};