ardupilot/libraries/SITL/SIM_ICEngine.h

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

61 lines
1.7 KiB
C
Raw Permalink Normal View History

2016-07-15 05:29:12 -03:00
/*
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 <http://www.gnu.org/licenses/>.
*/
/*
simple internal combustion motor simulation class
*/
#pragma once
#include "SIM_Aircraft.h"
namespace SITL {
class ICEngine {
public:
const uint8_t throttle_servo;
const int8_t choke_servo;
const int8_t ignition_servo;
const int8_t starter_servo;
const float slew_rate; // percent-per-second
2022-01-30 05:52:37 -04:00
ICEngine(uint8_t _throttle, int8_t _choke, int8_t _ignition, int8_t _starter, float _slew_rate, bool _throttle_reversed) :
2016-07-15 05:29:12 -03:00
throttle_servo(_throttle),
choke_servo(_choke),
ignition_servo(_ignition),
starter_servo(_starter),
2022-01-30 05:52:37 -04:00
slew_rate(_slew_rate),
throttle_reversed(_throttle_reversed)
2016-07-15 05:29:12 -03:00
{}
// update motor state
float update(const struct sitl_input &input);
2016-07-15 05:29:12 -03:00
private:
float last_output;
uint64_t start_time_us;
uint64_t last_update_us;
union state {
struct {
bool choke:1;
bool ignition:1;
bool starter:1;
};
uint8_t value;
} state, last_state;
2016-07-23 04:36:10 -03:00
bool overheat:1;
2022-01-30 05:52:37 -04:00
bool throttle_reversed;
2016-07-15 05:29:12 -03:00
};
}