]> git.mxchange.org Git - flightgear.git/commitdiff
Elevator trim added.
authorcurt <curt>
Sat, 31 May 1997 19:16:24 +0000 (19:16 +0000)
committercurt <curt>
Sat, 31 May 1997 19:16:24 +0000 (19:16 +0000)
13 files changed:
Aircraft/aircraft.c
Controls/Makefile
Controls/controls.h
LaRCsim/ls_cockpit.h
LaRCsim/ls_interface.c
LaRCsim/navion_aero.c
LaRCsim/navion_init.c
Main/GLUTkey.c
Main/GLmain.c
Main/Makefile
Main/mesh2GL.c
Scenery/Makefile
Simulator/limits.h

index aac202dd62c7103b712ebd423a551ace87475dd2..6144df356dd3be7f32113ce78297456f26cce606 100644 (file)
@@ -43,15 +43,18 @@ void aircraft_debug(int type) {
           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.
  *
index 3aae602832bac6ce4be6bc1f1f4f751b6e5727ed..1c1e1e4f0ff621ae373d281fb52beb29361b6558 100644 (file)
@@ -24,9 +24,9 @@
 #---------------------------------------------------------------------------
 
 
-TARGET = stamp-done
+TARGET = libcontrols.a
 
-CFILES = 
+CFILES = controls.c
 HFILES = controls.h
 OFILES = $(CFILES:.c=.o)
 
@@ -45,8 +45,8 @@ LIBS =
 # Primary Targets
 #---------------------------------------------------------------------------
 
-$(TARGET): $(OFILES) $(HFILES)
-       touch stamp-done
+$(TARGET): $(OFILES)
+       $(AR) rv $(TARGET) $(OFILES)
 
 all: $(TARGET)
 
@@ -61,9 +61,15 @@ clean:
 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.
 #
index dca5d32aaa9e8177c053d9ed219fe7df8d5e77ff..d43751e768ecf0eda882e35cffb2f2ee8bd2d9f5 100644 (file)
 
 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.
  *
index 7543ba94197d023934452a75fd559c0f63df8209..4680881d82a6f02fbd52841df983a3a26b416466 100644 (file)
@@ -35,6 +35,9 @@
 
 $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.
 
@@ -53,6 +56,7 @@ 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;
@@ -70,6 +74,7 @@ extern COCKPIT cockpit_;
 #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
index 82017e5beeeaa62852cb58341c57851e5d2f1574..31ae1479a20070ca69a3e9ffe7d7938e119f078b 100644 (file)
@@ -501,10 +501,11 @@ int ls_cockpit() {
 
     c = &current_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);
@@ -908,6 +909,9 @@ int fgLaRCsim_2_Flight (struct flight_params *f) {
 /* 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!!!
  *
index 527af07a5e14bfc6af091e9d63553d7b992696b7..18e1f3393c2fbfc829d03f2f3408b70932d869a7 100644 (file)
@@ -124,7 +124,7 @@ void aero()
   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;
@@ -183,10 +183,6 @@ void aero()
       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;
@@ -196,8 +192,8 @@ void aero()
   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 */
@@ -209,7 +205,7 @@ void aero()
   
   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));
   
index 6e2aa7fb89fa2fadd99250d873e9f269b9b25ea8..37aa1af96f45ef5b381b6fe62a564ffe2e780858 100644 (file)
@@ -67,9 +67,4 @@ void model_init()
   
   Dx_pilot = 0; Dy_pilot = 0; Dz_pilot = 0;
   
-  Runway_altitude = 0;
-  Runway_latitude = 0;
-  Runway_longitude = 0;
-  Runway_heading = 0;
-  
 }
index 2258253e5f47a27761a4b1c43f7d6bddd1bb425a..6c4b5fed7fdef914fa471cc1de5f8e8ddfd500a9 100644 (file)
@@ -43,32 +43,39 @@ void GLUTkey(unsigned char k, int x, int y) {
 
     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;
@@ -97,16 +104,16 @@ void GLUTspecialkey(unsigned char k, int x, int y) {
 
     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;
     }
 
@@ -114,12 +121,15 @@ void GLUTspecialkey(unsigned char k, int x, int y) {
 
 
 /* $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.
  *
index 68c19c6d4fdd2195c33c4ad0dc9bd814b46dd5a1..5c570b9ce66339b01ff2a8a0546cddee2a381d7c 100644 (file)
@@ -49,8 +49,8 @@
 #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 */
@@ -124,7 +124,6 @@ static void fgUpdateViewParams() {
     struct flight_params *f;
     MAT3mat R, tmp;
     MAT3vec vec, forward, up;
-    MAT3hvec sun;
 
     f = &current_aircraft.flight;
 
@@ -137,8 +136,8 @@ static void fgUpdateViewParams() {
     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 */
@@ -353,16 +352,21 @@ int main( int argc, char *argv[] ) {
     /* 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 */;
@@ -371,7 +375,7 @@ int main( int argc, char *argv[] ) {
     /* 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;
@@ -393,7 +397,7 @@ int main( int argc, char *argv[] ) {
     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); */
 
@@ -446,12 +450,15 @@ int main( int argc, char *argv[] ) {
 
 
 /* $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.
  *
index dba9064935d321fee87eb485c4884b8b1c096c7f..e5e54484e4934470ca00865d031b2d7a8af056b9 100644 (file)
@@ -66,9 +66,9 @@ LIBS =  $(INTERFACE_LIBS) $(GRAPHICS_LIBS) -lm -lfl
 
 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
 
 
 #---------------------------------------------------------------------------
@@ -103,6 +103,9 @@ mesh2GL.o: mesh2GL.c ../scenery/mesh.h
 
 #---------------------------------------------------------------------------
 # $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!!!
 #
index e00b5425cb07a303eb2f9852a335aa0ef953c0bc..5c7ac74f1d383fdb60e0ed12fe18ff8532067e91 100644 (file)
@@ -44,7 +44,7 @@ GLint mesh2GL(struct mesh *m) {
     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);
@@ -75,18 +75,18 @@ GLint mesh2GL(struct mesh *m) {
 
            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);
@@ -104,12 +104,15 @@ GLint mesh2GL(struct mesh *m) {
 
 
 /* $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.
  *
index 25b1ed28952a65a5b301bc4401cf86180a65a2d6..4b7b67b07c25055a2272dbfc23c8f37536947ecb 100644 (file)
@@ -36,8 +36,8 @@ CC = gcc
 CFLAGS = -g -Wall
 # CFLAGS = -O2 -Wall
 
-FLEX = flex -f
-BISON = bison -v
+FLEX = flex -f -L
+BISON = bison -v --no-lines
 AR = ar
 
 INCLUDES = 
@@ -57,6 +57,9 @@ $(TARGET): $(OFILES) $(HFILES)
 clean:
        rm -f *.o $(TARGET) parser.output *~ core
 
+realclean: clean
+       rm -f scanner.c parser.c
+
 
 #---------------------------------------------------------------------------
 # Secondary Targets
@@ -86,6 +89,9 @@ mesh.o: mesh.c mesh.h common.h
 
 #---------------------------------------------------------------------------
 # $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.
 #
index bfccc4641f5bb0ea85d229353a1a4cbac6b37819..06b40151389309e31c314679c88a45ed6839a8b0 100644 (file)
 
 
 /* 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.
  *