Gear
----
-/controls/gear/parking-brake
+/controls/gear/brake-left
+/controls/gear/brake-right
+/controls/gear/brake-parking
/controls/gear/steering
/controls/gear/gear-down
/controls/gear/antiskid
/controls/gear/tailhook
/controls/gear/tailwheel-lock
-/controls/gear/wheel[%d]/brake
/controls/gear/wheel[%d]/alternate-extension
Anti-Ice
print OUT "</A>\n";
if ( -f "$mdir/$linkname.txt" ) {
- if ( $twidth < $swidth ) {
- print OUT "<BR>\n";
- }
+ print OUT "<BR>\n";
print OUT "<FONT SIZE=-1 id=\"fgfs\">\n";
open( IN, "<$mdir/$linkname.txt" );
while ( <IN> ) {
close( IN );
print OUT "</FONT>\n";
} else {
- if ( $twidth < $swidth ) {
- print OUT "<BR>\n";
- }
+ print OUT "<BR>\n";
print OUT "<FONT SIZE=-1 id=\"fgfs\">\n";
print OUT "$linkname\n";
print OUT "</FONT>\n";
# Connect to flightgear telnet server.
fg = FlightGear('myhost', 5500)
# parking brake on
- fg['/controls/parking-brake'] = 1
+ fg['/controls/gear/brake-parking'] = 1
# Get current heading
heading = fg['/orientation/heading-deg']
double current_angle = atan2( y, x ) * SGD_RADIANS_TO_DEGREES;
double target_angle = current_radiostack->get_navcom1()->get_nav_target_gs();
-
double gs_diff = target_angle - current_angle;
// convert desired vertical path angle into a climb rate
double des_angle = current_angle - 10 * gs_diff;
- // convert to meter/min
- double horiz_vel = cur_fdm_state->get_V_ground_speed()
- * SG_FEET_TO_METER * 60.0;
+ // estimate horizontal speed towards ILS in meters per minute
+ static double horiz_vel = 0.0;
+ static double last_x = 0.0;
+ double dist = last_x - x;
+ last_x = x;
+ double new_vel = ( dist / dt ) * 60.0;
+ horiz_vel = 0.75 * horiz_vel + 0.25 * new_vel;
+ // double horiz_vel = cur_fdm_state->get_V_ground_speed()
+ // * SG_FEET_TO_METER * 60.0;
+ // double horiz_vel = airspeed_node->getFloatValue()
+ // * SG_FEET_TO_METER * 60.0;
+
climb_rate = -sin( des_angle * SGD_DEGREES_TO_RADIANS ) * horiz_vel;
/* climb_error_accum += gs_diff * 2.0; */
/* climb_rate = gs_diff * 200.0 + climb_error_accum; */
drag_chute( false ),
throttle_idle( true ),
dump_valve( false ),
- parking_brake( 0.0 ),
+ brake_left( 0.0 ),
+ brake_right( 0.0 ),
+ brake_parking( 0.0 ),
steering( 0.0 ),
gear_down( true ),
antiskid( true ),
condition[engine] = 0;
}
+ brake_left = brake_right = brake_parking = 0.0;
for ( int wheel = 0; wheel < MAX_WHEELS; wheel++ ) {
- brake[wheel] = 0.0;
alternate_extension[wheel] = false;
}
}
// gear
- fgTie("/controls/gear/parking-brake", this,
- &FGControls::get_parking_brake,
- &FGControls::set_parking_brake);
- fgSetArchivable("/controls/gear/parking-brake");
+ fgTie("/controls/gear/brake-left", this,
+ &FGControls::get_brake_left,
+ &FGControls::set_brake_left);
+ fgSetArchivable("/controls/gear/brake-left");
+
+ fgTie("/controls/gear/brake-right", this,
+ &FGControls::get_brake_right,
+ &FGControls::set_brake_right);
+ fgSetArchivable("/controls/gear/brake-right");
+
+ fgTie("/controls/gear/brake-parking", this,
+ &FGControls::get_brake_parking,
+ &FGControls::set_brake_parking);
+ fgSetArchivable("/controls/gear/brake-parking");
fgTie("/controls/gear/steering", this,
&FGControls::get_steering, &FGControls::set_steering);
for (index = 0; index < MAX_WHEELS; index++) {
char name[MAX_NAME_LEN];
- snprintf(name, MAX_NAME_LEN, "/controls/gear/wheel[%d]/brake", index);
- fgTie(name, this, index,
- &FGControls::get_brake, &FGControls::set_brake);
- fgSetArchivable(name);
-
snprintf(name, MAX_NAME_LEN,
"/controls/gear/wheel[%d]/alternate-extension", index);
fgTie(name, this, index,
fgUntie(name);
}
}
- fgUntie("/controls/gear/parking_brake");
+ fgUntie("/controls/gear/brake-left");
+ fgUntie("/controls/gear/brake-right");
+ fgUntie("/controls/gear/brake-parking");
fgUntie("/controls/gear/steering");
fgUntie("/controls/gear/gear_down");
fgUntie("/controls/gear/antiskid");
fgUntie("/controls/gear/tailwheel-lock");
for (index = 0; index < MAX_WHEELS; index++) {
char name[MAX_NAME_LEN];
- snprintf(name, MAX_NAME_LEN, "/controls/gear/wheel[%d]/brakes", index);
- fgUntie(name);
snprintf(name, MAX_NAME_LEN,
"/controls/gear/wheel[%d]/alternate-extension", index);
fgUntie(name);
void
-FGControls::set_parking_brake( double pos )
+FGControls::set_brake_left( double pos )
+{
+ brake_left = pos;
+ CLAMP(&brake_left, 0.0, 1.0);
+}
+
+void
+FGControls::move_brake_left( double amt )
+{
+ brake_left += amt;
+ CLAMP( &brake_left, 0.0, 1.0 );
+}
+
+void
+FGControls::set_brake_right( double pos )
+{
+ brake_right = pos;
+ CLAMP(&brake_right, 0.0, 1.0);
+}
+
+void
+FGControls::move_brake_right( double amt )
+{
+ brake_right += amt;
+ CLAMP( &brake_right, 0.0, 1.0 );
+}
+
+void
+FGControls::set_brake_parking( double pos )
{
- parking_brake = pos;
- CLAMP(&parking_brake, 0.0, 1.0);
+ brake_parking = pos;
+ CLAMP(&brake_parking, 0.0, 1.0);
}
void
}
-void
-FGControls::set_brake( int wheel, double pos )
-{
- if ( wheel == ALL_WHEELS ) {
- for ( int i = 0; i < MAX_WHEELS; i++ ) {
- brake[i] = pos;
- CLAMP( &brake[i], 0.0, 1.0 );
- }
- } else {
- if ( (wheel >= 0) && (wheel < MAX_WHEELS) ) {
- brake[wheel] = pos;
- CLAMP( &brake[wheel], 0.0, 1.0 );
- }
- }
-}
-
-void
-FGControls::move_brake( int wheel, double amt )
-{
- if ( wheel == ALL_WHEELS ) {
- for ( int i = 0; i < MAX_WHEELS; i++ ) {
- brake[i] += amt;
- CLAMP( &brake[i], 0.0, 1.0 );
- }
- } else {
- if ( (wheel >= 0) && (wheel < MAX_WHEELS) ) {
- brake[wheel] += amt;
- CLAMP( &brake[wheel], 0.0, 1.0 );
- }
- }
-}
-
void
FGControls::set_alternate_extension( int wheel, bool val )
{
bool boost_pump[MAX_TANKS * MAX_BOOSTPUMPS];
// controls/gear/
- double parking_brake;
+ double brake_left;
+ double brake_right;
+ double brake_parking;
double steering;
bool gear_down;
bool antiskid;
bool tailwheel_lock;
// controls/gear/wheel[n]/
- double brake[MAX_WHEELS];
bool alternate_extension[MAX_WHEELS];
// controls/anti-ice/
}
// controls/gear/
- inline double get_parking_brake() const { return parking_brake; }
+ inline double get_brake_left() const { return brake_left; }
+ inline double get_brake_right() const { return brake_right; }
+ inline double get_brake_parking() const { return brake_parking; }
inline double get_steering() const { return steering; }
inline bool get_gear_down() const { return gear_down; }
inline bool get_antiskid() const { return antiskid; }
inline bool get_tailwheel_lock() const { return tailwheel_lock; }
// controls/gear/wheel[n]/
- inline double get_brake(int wheel) const { return brake[wheel]; }
inline bool get_alternate_extension(int wheel) const {
return alternate_extension[wheel];
}
void set_boost_pump( int index, bool val );
// controls/gear/
- void set_parking_brake( double pos );
+ void set_brake_left( double pos );
+ void move_brake_left( double amt );
+ void set_brake_right( double pos );
+ void move_brake_right( double amt );
+ void set_brake_parking( double pos );
void set_steering( double pos );
void move_steering( double amt );
void set_gear_down( bool gear );
void set_tailwheel_lock( bool val );
// controls/gear/wheel[n]/
- void set_brake( int wheel, double pos );
- void move_brake( int wheel, double amt );
void set_alternate_extension( int wheel, bool val );
// controls/anti-ice/
// Parking brake sets minimum braking
// level for mains.
- double parking_brake = globals->get_controls()->get_parking_brake();
- FCS->SetLBrake(FMAX(globals->get_controls()->get_brake(0), parking_brake));
- FCS->SetRBrake(FMAX(globals->get_controls()->get_brake(1), parking_brake));
- FCS->SetCBrake( globals->get_controls()->get_brake(2) );
+ double parking_brake = globals->get_controls()->get_brake_parking();
+ FCS->SetLBrake(FMAX(globals->get_controls()->get_brake_left(), parking_brake));
+ FCS->SetRBrake(FMAX(globals->get_controls()->get_brake_right(), parking_brake));
+ FCS->SetCBrake( 0.0 );
FCS->SetGearCmd( globals->get_controls()->get_gear_down());
for (i = 0; i < Propulsion->GetNumEngines(); i++) {
Throttle_pct = globals->get_controls()->get_throttle( 0 ) * 1.0;
- Brake_pct[0] = globals->get_controls()->get_brake( 1 );
- Brake_pct[1] = globals->get_controls()->get_brake( 0 );
+ Brake_pct[0] = globals->get_controls()->get_brake_right();
+ Brake_pct[1] = globals->get_controls()->get_brake_left();
// Inform LaRCsim of the local terrain altitude
// Runway_altitude = get_Runway_altitude();
// speed and distance traveled
double speed = globals->get_controls()->get_throttle( 0 ) * 2000; // meters/sec
- if ( globals->get_controls()->get_brake( 0 ) ) {
+ if ( globals->get_controls()->get_brake_left() > 0.0
+ || globals->get_controls()->get_brake_right() > 0.0 )
+ {
speed = -speed;
}
// read the throttle
double th = globals->get_controls()->get_throttle( 0 );
- if (globals->get_controls()->get_brake(0)) {
+ if ( globals->get_controls()->get_brake_left() > 0.0
+ || globals->get_controls()->get_brake_right() > 0.0 )
+ {
th = -th;
}
Throttle = th * throttle_damp + Throttle * (1 - throttle_damp);
}
static inline void move_brake(float offset) {
- globals->get_controls()->move_brake(FGControls::ALL_WHEELS, offset);
+ globals->get_controls()->move_brake_left(offset);
+ globals->get_controls()->move_brake_right(offset);
}
static inline void move_throttle(float offset) {
bool half_range[8]={ false,false,false,true,true,true,false,false };
-string button_humannames[7]= { "apply all brakes", "apply left brake",
+string button_humannames[6]= { "apply left brake",
"apply right brake", "step flaps up",
"step flaps down","apply nose-up trim",
"apply nose-down trim"
};
-string button_propnames[7]={ "/controls/gear/wheel[-1]/brake", "/controls/gear/wheel[0]/brake",
- "/controls/gear/wheel[1]/brake", "/controls/flight/flaps",
- "/controls/flight/flaps","/controls/flight/elevator-trim",
+string button_propnames[6]={ "/controls/gear/brake-left",
+ "/controls/gear/brake-right",
+ "/controls/flight/flaps",
+ "/controls/flight/flaps",
+ "/controls/flight/elevator-trim",
"/controls/flight/elevator-trim"
};
-float button_step[7]={ 1.0, 1.0, 1.0, 0.34, -0.34, 0.001, -0.001 };
+float button_step[6]={ 1.0, 1.0, 0.34, -0.34, 0.001, -0.001 };
-string button_repeat[7]={ "false", "false", "false", "false", "false",
+string button_repeat[6]={ "false", "false", "false", "false",
"true", "true" };
cout << endl;
}
- for(control=0;control<=6;control++) {
+ for(control=0;control<=5;control++) {
cout << "Press the button you wish to use to "
<< button_humannames[control]
<< endl;
tmp = scale( brake_left_min->getIntValue(),
brake_left_max->getIntValue(),
analog_in_data[20] );
- fgSetFloat( "/controls/gear/wheel[0]/brake", tmp );
+ fgSetFloat( "/controls/gear/brake-left", tmp );
tmp = scale( brake_right_min->getIntValue(),
brake_right_max->getIntValue(),
analog_in_data[21] );
- fgSetFloat( "/controls/gear/wheel[1]/brake", tmp );
+ fgSetFloat( "/controls/gear/brake-right", tmp );
}
// nav1 volume
fgSetBool( "/controls/circuit-breakers/annunciators", true );
#endif
- fgSetDouble( "/controls/gear/parking-brake",
+ fgSetDouble( "/controls/gear/brake-parking",
switch_matrix[board][7][3] );
fgSetDouble( "/radios/marker-beacon/power-btn",
switch_matrix[board][6][1] );
net->fuel_selector[i] = false;
}
}
- net->num_wheels = FGNetCtrls::FG_MAX_WHEELS;
- tempnode = fgGetNode("/controls/gear", true);
- for ( i = 0; i < FGNetCtrls::FG_MAX_WHEELS; ++i ) {
- node = fgGetNode("/controls/gear/wheel", i);
- if ( node != NULL && node->getChild("brake") != NULL ) {
- if ( tempnode->getChild("parking-brake")->getDoubleValue() > 0.0 ) {
- net->brake[i] = 1.0;
- } else {
- net->brake[i]
- = node->getChild("brake")->getDoubleValue();
- }
- } else {
- net->brake[i] = 0.0;
- }
- }
+ node = fgGetNode("/controls/gear", true);
+ net->brake_left = node->getChild("brake-left")->getDoubleValue();
+ net->brake_right = node->getChild("brake-right")->getDoubleValue();
+ net->brake_parking = node->getChild("brake-parking")->getDoubleValue();
node = fgGetNode("/controls/switches", true);
tempnode = node->getChild("master-bat");
net->fuel_selector[i] = htonl(net->fuel_selector[i]);
}
net->num_tanks = htonl(net->num_tanks);
- for ( i = 0; i < FGNetCtrls::FG_MAX_WHEELS; ++i ) {
- htond(net->brake[i]);
- }
- net->num_wheels = htonl(net->num_wheels);
+ htond(net->brake_left);
+ htond(net->brake_right);
+ htond(net->brake_parking);
net->gear_handle = htonl(net->gear_handle);
net->master_bat = htonl(net->master_bat);
net->master_alt = htonl(net->master_alt);
for ( i = 0; i < net->num_tanks; ++i ) {
net->fuel_selector[i] = htonl(net->fuel_selector[i]);
}
- net->num_wheels = htonl(net->num_wheels);
- for ( i = 0; i < net->num_wheels; ++i ) {
- htond(net->brake[i]);
- }
+ htond(net->brake_left);
+ htond(net->brake_right);
+ htond(net->brake_parking);
net->gear_handle = htonl(net->gear_handle);
net->master_bat = htonl(net->master_bat);
net->master_alt = htonl(net->master_alt);
node->getChild( "fuel_selector" )
->setBoolValue( net->fuel_selector[i] );
}
- for ( i = 0; i < FGNetCtrls::FG_MAX_WHEELS; ++i ) {
- node = fgGetNode( "/controls/gear/wheel", i );
- if ( node != NULL ) {
- node->getChild( "brake" )->setDoubleValue( net->brake[i] );
- }
+ node = fgGetNode( "/controls/gear" );
+ if ( node != NULL ) {
+ node->getChild( "brake-left" )->setDoubleValue( net->brake_left );
+ node->getChild( "brake-right" )->setDoubleValue( net->brake_right );
+ node->getChild( "brake-parking" )->setDoubleValue( net->brake_parking );
}
node = fgGetNode( "/controls/gear", true );
# error This library requires C++
#endif
-const int FG_NET_CTRLS_VERSION = 18;
+const int FG_NET_CTRLS_VERSION = 19;
// Define a structure containing the control parameters
bool fuel_selector[FG_MAX_TANKS]; // false = off, true = on
// Brake controls
- int num_wheels; // number of valid wheels
- double brake[FG_MAX_WHEELS]; // 0 ... 1
+ double brake_left;
+ double brake_right;
+ double brake_parking;
// Landing Gear
bool gear_handle; // true=gear handle down; false= gear handle up
}
// Brake controls
- for ( i = 0; i < ctrls1.num_wheels; ++i ) {
- result.ctrls.brake[i]
- = weight( ctrls1.brake[i], ctrls2.brake[i], ratio );
- }
+ result.ctrls.brake_left
+ = weight( ctrls1.brake_left, ctrls2.brake_right, ratio );
+ result.ctrls.brake_right
+ = weight( ctrls1.brake_right, ctrls2.brake_right, ratio );
+ result.ctrls.brake_parking
+ = weight( ctrls1.brake_parking, ctrls2.brake_parking, ratio );
// Landing Gear
result.ctrls.gear_handle = ctrls1.gear_handle;