cleanup: extract globals->get_controls()
This commit is contained in:
parent
2bcf5b7fe7
commit
d1fb32b315
2 changed files with 13 additions and 14 deletions
|
@ -73,34 +73,33 @@ void FGUFO::init() {
|
||||||
|
|
||||||
// Run an iteration of the EOM (equations of motion)
|
// Run an iteration of the EOM (equations of motion)
|
||||||
void FGUFO::update( double dt ) {
|
void FGUFO::update( double dt ) {
|
||||||
// cout << "FGLaRCsim::update()" << endl;
|
|
||||||
|
|
||||||
if (is_suspended())
|
if (is_suspended())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
lowpass::set_delta(dt);
|
lowpass::set_delta(dt);
|
||||||
double time_step = dt;
|
double time_step = dt;
|
||||||
|
FGControls *ctrl = globals->get_controls();
|
||||||
|
|
||||||
// read the throttle
|
// read the throttle
|
||||||
double throttle = globals->get_controls()->get_throttle( 0 );
|
double throttle = ctrl->get_throttle( 0 );
|
||||||
double brake_left = globals->get_controls()->get_brake_left();
|
double brake_left = ctrl->get_brake_left();
|
||||||
double brake_right = globals->get_controls()->get_brake_right();
|
double brake_right = ctrl->get_brake_right();
|
||||||
|
|
||||||
if (brake_left > 0.5 || brake_right > 0.5)
|
if (brake_left > 0.5 || brake_right > 0.5)
|
||||||
throttle = -throttle;
|
throttle = -throttle;
|
||||||
|
|
||||||
throttle = Throttle->filter(throttle);
|
double velocity = Throttle->filter(throttle) * Speed_Max->getDoubleValue(); // meters/sec
|
||||||
|
|
||||||
|
|
||||||
// read and lowpass-filter the state of the control surfaces
|
// read and lowpass-filter the state of the control surfaces
|
||||||
double aileron = Aileron->filter(globals->get_controls()->get_aileron());
|
double aileron = Aileron->filter(ctrl->get_aileron());
|
||||||
double elevator = Elevator->filter(globals->get_controls()->get_elevator());
|
double elevator = Elevator->filter(ctrl->get_elevator());
|
||||||
double rudder = Rudder->filter(globals->get_controls()->get_rudder());
|
double rudder = Rudder->filter(ctrl->get_rudder());
|
||||||
|
|
||||||
aileron += Aileron_Trim->filter(globals->get_controls()->get_aileron_trim());
|
aileron += Aileron_Trim->filter(ctrl->get_aileron_trim());
|
||||||
elevator += Elevator_Trim->filter(globals->get_controls()->get_elevator_trim());
|
elevator += Elevator_Trim->filter(ctrl->get_elevator_trim());
|
||||||
rudder += Rudder_Trim->filter(globals->get_controls()->get_rudder_trim());
|
rudder += Rudder_Trim->filter(ctrl->get_rudder_trim());
|
||||||
|
|
||||||
double velocity = throttle * Speed_Max->getDoubleValue(); // meters/sec
|
|
||||||
|
|
||||||
double old_pitch = get_Theta();
|
double old_pitch = get_Theta();
|
||||||
double pitch_rate = SGD_PI_4; // assume I will be pitching up
|
double pitch_rate = SGD_PI_4; // assume I will be pitching up
|
||||||
|
|
|
@ -62,7 +62,7 @@ public:
|
||||||
FGUFO( double dt );
|
FGUFO( double dt );
|
||||||
~FGUFO();
|
~FGUFO();
|
||||||
|
|
||||||
// reset flight params to a specific position
|
// reset flight params to a specific position
|
||||||
void init();
|
void init();
|
||||||
|
|
||||||
// update position based on inputs, positions, velocities, etc.
|
// update position based on inputs, positions, velocities, etc.
|
||||||
|
|
Loading…
Add table
Reference in a new issue