| 1 | /* |
| 2 | * SPDX-License-Identifier: CC0-1.0 |
| 3 | * |
| 4 | * mrg.hxx - an electrically-powered master reference gyro |
| 5 | * Written by David Megginson, started 2002. |
| 6 | * |
| 7 | * This file is in the Public Domain and comes with no warranty. |
| 8 | */ |
| 9 | |
| 10 | #pragma once |
| 11 | |
| 12 | |
| 13 | #include <simgear/props/props.hxx> |
| 14 | #include <simgear/structure/subsystem_mgr.hxx> |
| 15 | |
| 16 | #include "gyro.hxx" |
| 17 | |
| 18 | |
| 19 | /** |
| 20 | * Model an electrically-powered master reference gyro. |
| 21 | * |
| 22 | * Input properties: |
| 23 | * |
| 24 | * /instrumentation/"name"/config/tumble-flag |
| 25 | * /instrumentation/"name"/serviceable |
| 26 | * /instrumentation/"name"/caged-flag |
| 27 | * /instrumentation/"name"/tumble-norm |
| 28 | * /orientation/pitch-deg |
| 29 | * /orientation/roll-deg |
| 30 | * |
| 31 | * Output properties: |
| 32 | * |
| 33 | * /instrumentation/"name"/indicated-pitch-deg |
| 34 | * /instrumentation/"name"/indicated-roll-deg |
| 35 | * /instrumentation/"name"/tumble-norm |
| 36 | */ |
| 37 | |
| 38 | class MasterReferenceGyro : public SGSubsystem |
| 39 | { |
| 40 | public: |
| 41 | MasterReferenceGyro ( SGPropertyNode *node ); |
| 42 | MasterReferenceGyro (); |
| 43 | virtual ~MasterReferenceGyro (); |
| 44 | |
| 45 | // Subsystem API. |
| 46 | void bind() override; |
| 47 | void init() override; |
| 48 | void reinit() override; |
| 49 | void unbind() override; |
| 50 | void update(double dt) override; |
| 51 | |
| 52 | // Subsystem identification. |
| 53 | static const char* staticSubsystemClassId() { return "master-reference-gyro"; } |
| 54 | |
| 55 | private: |
| 56 | static const double gravity; //conversion factor |
| 57 | |
| 58 | std::string _name; |
| 59 | int _num; |
| 60 | |
| 61 | double _last_roll; |
| 62 | double _last_pitch; |
| 63 | double _last_hdg; |
| 64 | double _indicated_roll; |
| 65 | double _indicated_pitch; |
| 66 | double _indicated_hdg; |
| 67 | double _indicated_pitch_rate; |
| 68 | double _indicated_roll_rate; |
| 69 | double _indicated_hdg_rate; |
| 70 | double _last_roll_rate; |
| 71 | double _last_pitch_rate; |
| 72 | double _last_yaw_rate; |
| 73 | double _last_g; |
| 74 | double _erect_time; |
| 75 | double _g_error; |
| 76 | |
| 77 | Gyro _gyro; |
| 78 | |
| 79 | SGPropertyNode_ptr _tumble_flag_node; |
| 80 | SGPropertyNode_ptr _caged_node; |
| 81 | SGPropertyNode_ptr _off_node; |
| 82 | SGPropertyNode_ptr _tumble_node; |
| 83 | SGPropertyNode_ptr _pitch_in_node; |
| 84 | SGPropertyNode_ptr _roll_in_node; |
| 85 | SGPropertyNode_ptr _hdg_in_node; |
| 86 | SGPropertyNode_ptr _hdg_mag_in_node; |
| 87 | SGPropertyNode_ptr _g_in_node; |
| 88 | SGPropertyNode_ptr _electrical_node; |
| 89 | SGPropertyNode_ptr _pitch_int_node; |
| 90 | SGPropertyNode_ptr _roll_int_node; |
| 91 | SGPropertyNode_ptr _hdg_int_node; |
| 92 | SGPropertyNode_ptr _pitch_out_node; |
| 93 | SGPropertyNode_ptr _roll_out_node; |
| 94 | SGPropertyNode_ptr _hdg_out_node; |
| 95 | SGPropertyNode_ptr _hdg_mag_out_node; |
| 96 | SGPropertyNode_ptr _pitch_rate_out_node; |
| 97 | SGPropertyNode_ptr _roll_rate_out_node; |
| 98 | SGPropertyNode_ptr _hdg_rate_out_node; |
| 99 | SGPropertyNode_ptr _error_out_node; |
| 100 | SGPropertyNode_ptr _yaw_rate_node; |
| 101 | SGPropertyNode_ptr _roll_rate_node; |
| 102 | SGPropertyNode_ptr _pitch_rate_node; |
| 103 | SGPropertyNode_ptr _responsiveness_node; |
| 104 | SGPropertyNode_ptr _hdg_input_source_node; |
| 105 | SGPropertyNode_ptr _fast_erect_node; |
| 106 | }; |