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/libraries/AC_CustomControl/AC_CustomControl_Empty.cpp
Views: 1798
1
#include "AC_CustomControl_config.h"
2
3
#if AP_CUSTOMCONTROL_EMPTY_ENABLED
4
5
#include "AC_CustomControl_Empty.h"
6
7
#include <GCS_MAVLink/GCS.h>
8
9
// table of user settable parameters
10
const AP_Param::GroupInfo AC_CustomControl_Empty::var_info[] = {
11
// @Param: PARAM1
12
// @DisplayName: Empty param1
13
// @Description: Dummy parameter for empty custom controller backend
14
// @User: Advanced
15
AP_GROUPINFO("PARAM1", 1, AC_CustomControl_Empty, param1, 0.0f),
16
17
// @Param: PARAM2
18
// @DisplayName: Empty param2
19
// @Description: Dummy parameter for empty custom controller backend
20
// @User: Advanced
21
AP_GROUPINFO("PARAM2", 2, AC_CustomControl_Empty, param2, 0.0f),
22
23
// @Param: PARAM3
24
// @DisplayName: Empty param3
25
// @Description: Dummy parameter for empty custom controller backend
26
// @User: Advanced
27
AP_GROUPINFO("PARAM3", 3, AC_CustomControl_Empty, param3, 0.0f),
28
29
AP_GROUPEND
30
};
31
32
// initialize in the constructor
33
AC_CustomControl_Empty::AC_CustomControl_Empty(AC_CustomControl& frontend, AP_AHRS_View*& ahrs, AC_AttitudeControl*& att_control, AP_MotorsMulticopter*& motors, float dt) :
34
AC_CustomControl_Backend(frontend, ahrs, att_control, motors, dt)
35
{
36
AP_Param::setup_object_defaults(this, var_info);
37
}
38
39
// update controller
40
// return roll, pitch, yaw controller output
41
Vector3f AC_CustomControl_Empty::update(void)
42
{
43
// reset controller based on spool state
44
switch (_motors->get_spool_state()) {
45
case AP_Motors::SpoolState::SHUT_DOWN:
46
case AP_Motors::SpoolState::GROUND_IDLE:
47
// We are still at the ground. Reset custom controller to avoid
48
// build up, ex: integrator
49
reset();
50
break;
51
52
case AP_Motors::SpoolState::THROTTLE_UNLIMITED:
53
case AP_Motors::SpoolState::SPOOLING_UP:
54
case AP_Motors::SpoolState::SPOOLING_DOWN:
55
// we are off the ground
56
break;
57
}
58
59
// arducopter main attitude controller already ran
60
// we don't need to do anything else
61
62
GCS_SEND_TEXT(MAV_SEVERITY_INFO, "empty custom controller working");
63
64
// return what arducopter main controller outputted
65
return Vector3f(_motors->get_roll(), _motors->get_pitch(), _motors->get_yaw());
66
}
67
68
// reset controller to avoid build up on the ground
69
// or to provide bumpless transfer from arducopter main controller
70
void AC_CustomControl_Empty::reset(void)
71
{
72
}
73
74
#endif // AP_CUSTOMCONTROL_EMPTY_ENABLED
75
76