CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutSign UpSign In
Ardupilot

Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place. Commercial Alternative to JupyterHub.

GitHub Repository: Ardupilot/ardupilot
Path: blob/master/ArduSub/Sub.cpp
Views: 1798
1
/*
2
This program is free software: you can redistribute it and/or modify
3
it under the terms of the GNU General Public License as published by
4
the Free Software Foundation, either version 3 of the License, or
5
(at your option) any later version.
6
7
This program is distributed in the hope that it will be useful,
8
but WITHOUT ANY WARRANTY; without even the implied warranty of
9
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10
GNU General Public License for more details.
11
12
You should have received a copy of the GNU General Public License
13
along with this program. If not, see <http://www.gnu.org/licenses/>.
14
*/
15
#include "Sub.h"
16
17
#define FORCE_VERSION_H_INCLUDE
18
#include "version.h"
19
#undef FORCE_VERSION_H_INCLUDE
20
21
const AP_HAL::HAL& hal = AP_HAL::get_HAL();
22
23
/*
24
constructor for main Sub class
25
*/
26
Sub::Sub()
27
:
28
control_mode(Mode::Number::MANUAL),
29
motors(MAIN_LOOP_RATE),
30
auto_yaw_mode(AUTO_YAW_LOOK_AT_NEXT_WP),
31
inertial_nav(ahrs),
32
ahrs_view(ahrs, ROTATION_NONE),
33
attitude_control(ahrs_view, aparm, motors),
34
pos_control(ahrs_view, inertial_nav, motors, attitude_control),
35
wp_nav(inertial_nav, ahrs_view, pos_control, attitude_control),
36
loiter_nav(inertial_nav, ahrs_view, pos_control, attitude_control),
37
circle_nav(inertial_nav, ahrs_view, pos_control),
38
param_loader(var_info),
39
flightmode(&mode_manual),
40
auto_mode(Auto_WP),
41
guided_mode(Guided_WP)
42
{
43
#if CONFIG_HAL_BOARD != HAL_BOARD_SITL
44
failsafe.pilot_input = true;
45
#endif
46
if (_singleton != nullptr) {
47
AP_HAL::panic("Can only be one Sub");
48
}
49
_singleton = this;
50
}
51
52
Sub *Sub::_singleton = nullptr;
53
54
Sub sub;
55
AP_Vehicle& vehicle = sub;
56
57