| 1 | /* |
| 2 | * SPDX-FileName: attitude_indicator.hxx |
| 3 | * SPDX-FileComment: a vacuum-powered attitude indicator. |
| 4 | * SPDX-License-Identifier: GPL-2.0-or-later |
| 5 | * SPDX-FileContributor: Written by David Megginson, started 2002. |
| 6 | */ |
| 7 | |
| 8 | #pragma once |
| 9 | |
| 10 | #include <simgear/props/props.hxx> |
| 11 | #include <simgear/structure/subsystem_mgr.hxx> |
| 12 | |
| 13 | #include "gyro.hxx" |
| 14 | |
| 15 | |
| 16 | /** |
| 17 | * Model a vacuum-powered attitude indicator. |
| 18 | * |
| 19 | * Config: |
| 20 | * minimum-vacuum Default 4.5 inHG |
| 21 | * gyro/spin-up-sec If given, seconds to spin up until power-norm (from 0->100%) |
| 22 | * gyro/spin-down-sec If given, seconds the gyro will loose spin without power (from 100%->0) |
| 23 | * limits/spin-thresh |
| 24 | * limits/max-roll-error-deg |
| 25 | * limits/max-pitch-error-deg |
| 26 | * |
| 27 | * Input properties: |
| 28 | * |
| 29 | * /instrumentation/"name"/config/tumble-flag |
| 30 | * /instrumentation/"name"/serviceable |
| 31 | * /instrumentation/"name"/caged-flag |
| 32 | * /instrumentation/"name"/tumble-norm |
| 33 | * /orientation/pitch-deg |
| 34 | * /orientation/roll-deg |
| 35 | * "vacuum-system"/suction-inhg |
| 36 | * |
| 37 | * Output properties: |
| 38 | * |
| 39 | * /instrumentation/"name"/indicated-pitch-deg |
| 40 | * /instrumentation/"name"/indicated-roll-deg |
| 41 | * /instrumentation/"name"/tumble-norm |
| 42 | */ |
| 43 | class AttitudeIndicator : public SGSubsystem |
| 44 | { |
| 45 | public: |
| 46 | AttitudeIndicator ( SGPropertyNode *node ); |
| 47 | virtual ~AttitudeIndicator (); |
| 48 | |
| 49 | // Subsystem API. |
| 50 | void bind() override; |
| 51 | void init() override; |
| 52 | void reinit() override; |
| 53 | void unbind() override; |
| 54 | void update(double dt) override; |
| 55 | |
| 56 | // Subsystem identification. |
| 57 | static const char* staticSubsystemClassId() { return "attitude-indicator"; } |
| 58 | |
| 59 | private: |
| 60 | std::string _name; |
| 61 | int _num; |
| 62 | std::string _suction; |
| 63 | |
| 64 | Gyro _gyro; |
| 65 | double _gyro_spin_up, _gyro_spin_down; |
| 66 | double _minVacuum; |
| 67 | SGPropertyNode_ptr _minVacuum_node; |
| 68 | |
| 69 | SGPropertyNode_ptr _tumble_flag_node; |
| 70 | SGPropertyNode_ptr _caged_node; |
| 71 | SGPropertyNode_ptr _tumble_node; |
| 72 | SGPropertyNode_ptr _pitch_in_node; |
| 73 | SGPropertyNode_ptr _roll_in_node; |
| 74 | SGPropertyNode_ptr _suction_node; |
| 75 | SGPropertyNode_ptr _pitch_int_node; |
| 76 | SGPropertyNode_ptr _roll_int_node; |
| 77 | SGPropertyNode_ptr _pitch_out_node; |
| 78 | SGPropertyNode_ptr _roll_out_node; |
| 79 | SGPropertyNode_ptr _spin_node, _gyro_spin_up_node, _gyro_spin_down_node; |
| 80 | |
| 81 | double spin_thresh; |
| 82 | double max_roll_error; |
| 83 | double max_pitch_error; |
| 84 | }; |