FG_RAD_2_DEG(FG_Longitude) * 3600.0,
FG_RAD_2_DEG(FG_Latitude) * 3600.0,
FG_Altitude, FG_Phi, FG_Theta, FG_Psi);
- printf("Mach = %.2f Elev = %.2f, Aileron = %.2f, Rudder = %.2f\n",
- FG_Mach_number, c->elev, c->aileron, c->rudder);
+ printf("Mach = %.2f Elev = %.2f, Aileron = %.2f, Rudder = %.2f Power = %.2f\n",
+ FG_Mach_number, FG_Elevator, FG_Aileron, FG_Rudder, FG_Throttle[0]);
}
/* $Log$
-/* Revision 1.5 1997/05/30 19:30:14 curt
-/* The LaRCsim flight model is starting to look like it is working.
+/* Revision 1.6 1997/05/31 19:16:26 curt
+/* Elevator trim added.
/*
+ * Revision 1.5 1997/05/30 19:30:14 curt
+ * The LaRCsim flight model is starting to look like it is working.
+ *
* Revision 1.4 1997/05/30 03:54:11 curt
* Made a bit more progress towards integrating the LaRCsim flight model.
*
#---------------------------------------------------------------------------
-TARGET = stamp-done
+TARGET = libcontrols.a
-CFILES =
+CFILES = controls.c
HFILES = controls.h
OFILES = $(CFILES:.c=.o)
# Primary Targets
#---------------------------------------------------------------------------
-$(TARGET): $(OFILES) $(HFILES)
- touch stamp-done
+$(TARGET): $(OFILES)
+ $(AR) rv $(TARGET) $(OFILES)
all: $(TARGET)
controls.h: ../limits.h
touch controls.h
+controls.o: controls.c controls.h ../aircraft/aircraft.h
+ $(CC) $(CFLAGS) $(INCLUDES) -c controls.c
+
#---------------------------------------------------------------------------
# $Log$
+# Revision 1.3 1997/05/31 19:16:27 curt
+# Elevator trim added.
+#
# Revision 1.2 1997/05/23 15:40:32 curt
# Added GNU copyright headers.
#
struct control_params {
double aileron;
- double elev;
+ double elevator;
+ double elevator_trim;
double rudder;
- double throttle[MAX_ENGINES];
+ double throttle[FG_MAX_ENGINES];
};
+#define FG_Elevator c->elevator
+#define FG_Aileron c->aileron
+#define FG_Rudder c->rudder
+#define FG_Throttle c->throttle
+#define FG_Throttle_All -1
+#define FG_Elev_Trim c->elevator_trim
+
+/*
+#define Left_button cockpit_.left_pb_on_stick
+#define Right_button cockpit_.right_pb_on_stick
+#define First_trigger cockpit_.trig_pos_1
+#define Second_trigger cockpit_.trig_pos_2
+#define Left_trim cockpit_.left_trim
+#define Right_trim cockpit_.right_trim
+#define SB_extend cockpit_.sb_extend
+#define SB_retract cockpit_.sb_retract
+#define Gear_sel_up cockpit_.gear_sel_up
+*/
+
+
+void fgControlsInit();
+
+void fgElevMove(double amt);
+void fgElevSet(double pos);
+void fgElevTrimMove(double amt);
+void fgElevTrimSet(double pos);
+void fgAileronMove(double amt);
+void fgAileronSet(double pos);
+void fgRudderMove(double amt);
+void fgRudderSet(double pos);
+void fgThrottleMove(int engine, double amt);
+void fgThrottleSet(int engine, double pos);
+
+
+
#endif CONTROLS_H
/* $Log$
-/* Revision 1.2 1997/05/23 15:40:33 curt
-/* Added GNU copyright headers.
+/* Revision 1.3 1997/05/31 19:16:27 curt
+/* Elevator trim added.
/*
+ * Revision 1.2 1997/05/23 15:40:33 curt
+ * Added GNU copyright headers.
+ *
* Revision 1.1 1997/05/16 15:59:48 curt
* Initial revision.
*
$Header$
$Log$
+Revision 1.2 1997/05/31 19:16:27 curt
+Elevator trim added.
+
Revision 1.1 1997/05/29 00:09:54 curt
Initial Flight Gear revision.
typedef struct {
float long_stick, lat_stick, rudder_pedal;
+ float long_trim;
float throttle[4];
short forward_trim, aft_trim, left_trim, right_trim;
short left_pb_on_stick, right_pb_on_stick, trig_pos_1, trig_pos_2;
#define First_trigger cockpit_.trig_pos_1
#define Second_trigger cockpit_.trig_pos_2
#define Long_control cockpit_.long_stick
+#define Long_trim cockpit_.long_trim
#define Lat_control cockpit_.lat_stick
#define Fwd_trim cockpit_.forward_trim
#define Aft_trim cockpit_.aft_trim
c = ¤t_aircraft.controls;
- Lat_control = -c->aileron;
- Long_control = -c->elev;
- Rudder_pedal = c->rudder;
- Throttle_pct = c->throttle[0];
+ Lat_control = FG_Aileron;
+ Long_control = FG_Elevator;
+ Long_trim = FG_Elev_Trim;
+ Rudder_pedal = FG_Rudder;
+ Throttle_pct = FG_Throttle[0];
/* printf("Mach = %.2f ", Mach_number);
printf("%.4f,%.4f,%.2f ", Latitude, Longitude, Altitude);
/* Flight Gear Modification Log
*
* $Log$
+ * Revision 1.7 1997/05/31 19:16:28 curt
+ * Elevator trim added.
+ *
* Revision 1.6 1997/05/31 04:13:53 curt
* WE CAN NOW FLY!!!
*
static SCALAR scale = 1.0;
static SCALAR trim_inc = 0.0002;
- static SCALAR long_trim;
+ /* static SCALAR long_trim; */
static DATA U_0;
static DATA X_0;
N_r = -0.7605;
N_da = -0.2218;
N_dr = -4.597;
-
-
- /* initialize trim 'actuator' */
- long_trim = 1.969572E-03;
}
u = V_rel_wind - U_0;
aileron = lat_scale * Lat_control;
rudder = yaw_scale * Rudder_pedal;
- if(Aft_trim) long_trim = long_trim - trim_inc;
- if(Fwd_trim) long_trim = long_trim + trim_inc;
+ /* if(Aft_trim) long_trim = long_trim - trim_inc; */
+ /* if(Fwd_trim) long_trim = long_trim + trim_inc; */
scale = V_rel_wind*V_rel_wind/(U_0*U_0);
if (scale > 1.0) scale = 1.0; /* ebj */
M_l_aero = scale*(I_xx*(L_beta*Beta + L_p*P_body + L_r*R_body
+ L_da*aileron + L_dr*rudder));
- M_m_aero = scale*(M_0 + I_yy*(M_w*w + M_q*Q_body + M_de*(elevator + long_trim)));
+ M_m_aero = scale*(M_0 + I_yy*(M_w*w + M_q*Q_body + M_de*(elevator + Long_trim)));
M_n_aero = scale*(I_zz*(N_beta*Beta + N_p*P_body + N_r*R_body
+ N_da*aileron + N_dr*rudder));
Dx_pilot = 0; Dy_pilot = 0; Dz_pilot = 0;
- Runway_altitude = 0;
- Runway_latitude = 0;
- Runway_longitude = 0;
- Runway_heading = 0;
-
}
switch (k) {
case 50: /* numeric keypad 2 */
- c->elev += 0.01;
+ fgElevMove(-0.01);
return;
case 56: /* numeric keypad 8 */
- c->elev -= 0.01;
+ fgElevMove(0.01);
+ return;
+ case 49: /* numeric keypad 1 */
+ fgElevTrimMove(-0.001);
+ return;
+ case 55: /* numeric keypad 7 */
+ fgElevTrimMove(0.001);
return;
case 52: /* numeric keypad 4 */
- c->aileron += 0.01;
+ fgAileronMove(-0.01);
return;
case 54: /* numeric keypad 6 */
- c->aileron -= 0.01;
+ fgAileronMove(0.01);
return;
case 48: /* numeric keypad Ins */
- c->rudder -= 0.01;
+ fgRudderMove(-0.01);
return;
case 13: /* numeric keypad Enter */
- c->rudder += 0.01;
+ fgRudderMove(0.01);
return;
case 53: /* numeric keypad 5 */
- c->aileron = 0.0;
- c->elev = 0.0;
- c->rudder = 0.0;
+ fgAileronSet(0.0);
+ fgElevSet(0.0);
+ fgRudderSet(0.0);
+ return;
case 57: /* numeric keypad 9 (Pg Up) */
- c->throttle[0] += 0.05;
+ fgThrottleMove(0, 0.01);
return;
case 51: /* numeric keypad 3 (Pg Dn) */
- c->throttle[0] -= 0.05;
+ fgThrottleMove(0, -0.01);
return;
case 122:
fogDensity *= 1.10;
switch (k) {
case GLUT_KEY_UP:
- c->elev -= 0.01;
+ fgElevMove(0.01);
return;
case GLUT_KEY_DOWN:
- c->elev += 0.01;
+ fgElevMove(-0.01);
return;
case GLUT_KEY_LEFT:
- c->aileron += 0.01;
+ fgAileronMove(-0.01);
return;
case GLUT_KEY_RIGHT:
- c->aileron -= 0.01;
+ fgAileronMove(0.01);
return;
}
/* $Log$
-/* Revision 1.6 1997/05/31 04:13:52 curt
-/* WE CAN NOW FLY!!!
-/*
-/* Continuing work on the LaRCsim flight model integration.
-/* Added some MSFS-like keyboard input handling.
+/* Revision 1.7 1997/05/31 19:16:25 curt
+/* Elevator trim added.
/*
+ * Revision 1.6 1997/05/31 04:13:52 curt
+ * WE CAN NOW FLY!!!
+ *
+ * Continuing work on the LaRCsim flight model integration.
+ * Added some MSFS-like keyboard input handling.
+ *
* Revision 1.5 1997/05/30 23:26:19 curt
* Added elevator/aileron controls.
*
#include "../mat3/mat3.h"
-#define FG_RAD_2_DEG(RAD) ((RAD) * 180.0 / M_PI)
-#define FG_DEG_2_RAD(DEG) ((DEG) * M_PI / 180.0)
+#define DEG_TO_RAD 0.017453292
+#define RAD_TO_DEG 57.29577951
/* This is a record containing all the info for the aircraft currently
being operated */
struct flight_params *f;
MAT3mat R, tmp;
MAT3vec vec, forward, up;
- MAT3hvec sun;
f = ¤t_aircraft.flight;
glLoadIdentity();
/* calculate position in arc seconds */
- pos_x = FG_RAD_2_DEG(FG_Longitude) * 3600.0;
- pos_y = FG_RAD_2_DEG(FG_Latitude) * 3600.0;
+ pos_x = (FG_Longitude * RAD_TO_DEG) * 3600.0;
+ pos_y = (FG_Latitude * RAD_TO_DEG) * 3600.0;
pos_z = FG_Altitude * 0.01; /* (Convert feet to aproximate arcsecs) */
/* build current rotation matrix */
/* setup view parameters, only makes GL calls */
fgInitVisuals();
- /* fgSlewInit(-398673.28,120625.64, 53, 4.38); */
+ /* Globe Aiport, AZ */
+ FG_Runway_altitude = 3234.5;
+ FG_Runway_latitude = 120070.41;
+ FG_Runway_longitude = -398391.28;
+ FG_Runway_heading = 102.0 * DEG_TO_RAD;
/* Initial Position */
- FG_Latitude = FG_DEG_2_RAD( 120625.64 / 3600.0 );
- FG_Longitude = FG_DEG_2_RAD( -398673.28 / 3600.0 );
- FG_Altitude = 3.758099E+00;
+ FG_Latitude = ( 120070.41 / 3600.0 ) * DEG_TO_RAD;
+ FG_Longitude = ( -398391.28 / 3600.0 ) * DEG_TO_RAD;
+ FG_Altitude = FG_Runway_altitude + 3.758099;
printf("Initial position is: (%.4f, %.4f, %.2f)\n", FG_Latitude,
FG_Longitude, FG_Altitude);
+
/* Initial Velocity */
FG_V_north = 0.0 /* 7.287719E+00 */;
FG_V_east = 0.0 /* 1.521770E+03 */;
/* Initial Orientation */
FG_Phi = -2.658474E-06;
FG_Theta = 7.401790E-03;
- FG_Psi = 2.14 /* 4.38 */;
+ FG_Psi = 102.0 * DEG_TO_RAD;
/* Initial Angular B rates */
FG_P_body = 7.206685E-05;
FG_Dz_cg = 0.000000E+00;
/* Set initial position and slew parameters */
- /* fgSlewInit(-398391.3, 120070.4, 244, 3.1415); */ /* GLOBE Airport */
+ /* fgSlewInit(-398391.3, 120070.41, 244, 3.1415); */ /* GLOBE Airport */
/* fgSlewInit(-335340,162540, 15, 4.38); */
/* fgSlewInit(-398673.28,120625.64, 53, 4.38); */
/* $Log$
-/* Revision 1.10 1997/05/31 04:13:52 curt
-/* WE CAN NOW FLY!!!
-/*
-/* Continuing work on the LaRCsim flight model integration.
-/* Added some MSFS-like keyboard input handling.
+/* Revision 1.11 1997/05/31 19:16:25 curt
+/* Elevator trim added.
/*
+ * Revision 1.10 1997/05/31 04:13:52 curt
+ * WE CAN NOW FLY!!!
+ *
+ * Continuing work on the LaRCsim flight model integration.
+ * Added some MSFS-like keyboard input handling.
+ *
* Revision 1.9 1997/05/30 19:27:01 curt
* The LaRCsim flight model is starting to look like it is working.
*
CFILES = GLmain.c $(INTERFACE_FILES) mesh2GL.c
OFILES = $(CFILES:.c=.o)
-AFILES = ../aircraft/libaircraft.a ../flight/libflight.a \
- ../flight/LaRCsim/libLaRCsim.a ../flight/slew/libslew.a \
- ../mat3/libmat3.a ../scenery/libscenery.a
+AFILES = ../aircraft/libaircraft.a ../controls/libcontrols.a \
+ ../flight/libflight.a ../flight/LaRCsim/libLaRCsim.a \
+ ../flight/slew/libslew.a ../mat3/libmat3.a ../scenery/libscenery.a
#---------------------------------------------------------------------------
#---------------------------------------------------------------------------
# $Log$
+# Revision 1.11 1997/05/31 19:16:25 curt
+# Elevator trim added.
+#
# Revision 1.10 1997/05/31 04:13:53 curt
# WE CAN NOW FLY!!!
#
int i, j, istep, jstep, iend, jend;
float temp;
- istep = jstep = 12; /* Detail level 1 -- 1200 ... */
+ istep = jstep = 50; /* Detail level 1 -- 1200 ... */
mesh = glGenLists(1);
glNewList(mesh, GL_COMPILE);
if ( j == 0 ) {
/* first time through */
- glVertex3f(x1, y1, z11-45);
- glVertex3f(x1, y2, z12-45);
+ glVertex3f(x1, y1, z11);
+ glVertex3f(x1, y2, z12);
}
- glVertex3f(x2, y1, z21-45);
+ glVertex3f(x2, y1, z21);
v1[0] = x2 - x1; v1[1] = y1 - y2; v1[2] = z21 - z12;
v2[0] = x2 - x1; v2[1] = 0; v2[2] = z22 - z12;
MAT3cross_product(normal, v1, v2);
MAT3_NORMALIZE_VEC(normal,temp);
glNormal3d(normal[0], normal[1], normal[2]);
- glVertex3f(x2, y2, z22-45);
+ glVertex3f(x2, y2, z22);
x1 = x2;
x2 = x1 + (m->row_step * jstep);
/* $Log$
-/* Revision 1.13 1997/05/31 04:13:53 curt
-/* WE CAN NOW FLY!!!
-/*
-/* Continuing work on the LaRCsim flight model integration.
-/* Added some MSFS-like keyboard input handling.
+/* Revision 1.14 1997/05/31 19:16:26 curt
+/* Elevator trim added.
/*
+ * Revision 1.13 1997/05/31 04:13:53 curt
+ * WE CAN NOW FLY!!!
+ *
+ * Continuing work on the LaRCsim flight model integration.
+ * Added some MSFS-like keyboard input handling.
+ *
* Revision 1.12 1997/05/30 23:26:20 curt
* Added elevator/aileron controls.
*
CFLAGS = -g -Wall
# CFLAGS = -O2 -Wall
-FLEX = flex -f
-BISON = bison -v
+FLEX = flex -f -L
+BISON = bison -v --no-lines
AR = ar
INCLUDES =
clean:
rm -f *.o $(TARGET) parser.output *~ core
+realclean: clean
+ rm -f scanner.c parser.c
+
#---------------------------------------------------------------------------
# Secondary Targets
#---------------------------------------------------------------------------
# $Log$
+# Revision 1.5 1997/05/31 19:16:29 curt
+# Elevator trim added.
+#
# Revision 1.4 1997/05/27 17:48:50 curt
# Added -f flag to flex to generate a "fast" scanner.
#
/* Maximum number of engines for a single aircraft */
-#define MAX_ENGINES 10
+#define FG_MAX_ENGINES 10
#endif LIMITS_H
/* $Log$
-/* Revision 1.2 1997/05/27 17:48:10 curt
-/* Added GNU copyright.
+/* Revision 1.3 1997/05/31 19:16:24 curt
+/* Elevator trim added.
/*
+ * Revision 1.2 1997/05/27 17:48:10 curt
+ * Added GNU copyright.
+ *
* Revision 1.1 1997/05/16 16:08:00 curt
* Initial revision.
*