diff --git a/Aircraft/aircraft.c b/Aircraft/aircraft.c index aac202dd6..6144df356 100644 --- a/Aircraft/aircraft.c +++ b/Aircraft/aircraft.c @@ -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. * diff --git a/Controls/Makefile b/Controls/Makefile index 3aae60283..1c1e1e4f0 100644 --- a/Controls/Makefile +++ b/Controls/Makefile @@ -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. # diff --git a/Controls/controls.h b/Controls/controls.h index dca5d32aa..d43751e76 100644 --- a/Controls/controls.h +++ b/Controls/controls.h @@ -35,19 +35,58 @@ 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. * diff --git a/LaRCsim/ls_cockpit.h b/LaRCsim/ls_cockpit.h index 7543ba941..4680881d8 100644 --- a/LaRCsim/ls_cockpit.h +++ b/LaRCsim/ls_cockpit.h @@ -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 diff --git a/LaRCsim/ls_interface.c b/LaRCsim/ls_interface.c index 82017e5be..31ae1479a 100644 --- a/LaRCsim/ls_interface.c +++ b/LaRCsim/ls_interface.c @@ -501,10 +501,11 @@ int ls_cockpit() { 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); @@ -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!!! * diff --git a/LaRCsim/navion_aero.c b/LaRCsim/navion_aero.c index 527af07a5..18e1f3393 100644 --- a/LaRCsim/navion_aero.c +++ b/LaRCsim/navion_aero.c @@ -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)); diff --git a/LaRCsim/navion_init.c b/LaRCsim/navion_init.c index 6e2aa7fb8..37aa1af96 100644 --- a/LaRCsim/navion_init.c +++ b/LaRCsim/navion_init.c @@ -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; - } diff --git a/Main/GLUTkey.c b/Main/GLUTkey.c index 2258253e5..6c4b5fed7 100644 --- a/Main/GLUTkey.c +++ b/Main/GLUTkey.c @@ -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. * diff --git a/Main/GLmain.c b/Main/GLmain.c index 68c19c6d4..5c570b9ce 100644 --- a/Main/GLmain.c +++ b/Main/GLmain.c @@ -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 = ¤t_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. * diff --git a/Main/Makefile b/Main/Makefile index dba906493..e5e54484e 100644 --- a/Main/Makefile +++ b/Main/Makefile @@ -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!!! # diff --git a/Main/mesh2GL.c b/Main/mesh2GL.c index e00b5425c..5c7ac74f1 100644 --- a/Main/mesh2GL.c +++ b/Main/mesh2GL.c @@ -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. * diff --git a/Scenery/Makefile b/Scenery/Makefile index 25b1ed289..4b7b67b07 100644 --- a/Scenery/Makefile +++ b/Scenery/Makefile @@ -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. # diff --git a/Simulator/limits.h b/Simulator/limits.h index bfccc4641..06b401513 100644 --- a/Simulator/limits.h +++ b/Simulator/limits.h @@ -29,16 +29,19 @@ /* 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. *