RcSim - A Model Flight Simulator

History

Usage

$ pil /usr/share/picolisp/misc/rcsim.l -main -go +

rcSim.ogv

The arrow keys UP and DOWN control the elevator

The LEFT and RIGHT arrow keys control the combined rudder/ailerons

The HOME key sets full throttle

PAGE UP/DOWN increase/decrease the throttle

The END key turns the engine off

INS/DEL zoom in/out

Structure

One of the oldest - but still largely unknown - pieces in the PicoLisp distribution is a little flight simulator. It simulates a radio-controlled airplane, where the pilot is standing on the ground, watching the plane flying around him.The first version was on an 8 MHz Mac II around 1991 (awfully slow!), well before 3D-libraries like OpenGL were available. Since then it was rewritten several times, including a DOS version with VGA graphics, some X11 versions, and one version using the (now deprecated) Java applet GUI.The current version runs only on the 64-bit version of PicoLisp, using native calls to a 3D rendering library in "@lib/z3d.l" and to plain X11. It is in the download-TGZ and in the Linux releases. The old 32-bit version can still be downloaded from http://software-lab.de/rcsim32.tgz The plane is similar to the German World War I fighter biplane Fokker D-VII (and a bit to the British Sopwith Camel ). Though the user's position is that of aplane's pilot (i.e. viewing the plane from a fixed position), all physical parameters like dimensions, mass, engine power and flight data are intended to be as close as possible to a "real" Fokker D-VII. Unfortunately, some of these parameters are not known exactly to me. But it is a fun project anyway, and I hope they come close.It can be started in a terminal as e.g.This should open a new XWindow. Put it on your desktop into a position where you cansee the terminal where you started it from. The plane is controlled from that terminal (the REPL) and thus needs the keyboard focus. So - depending on your window manager - click into the REPL terminal to ensure the focus.A sample flight might look like this:The plane is controlled solely with keyboard commands, using these keys:In the initial position, when the plane sits waiting on the runway, you can press PAGE UP to start the engine and then increase the throttle gradually, or press HOME for immediate full power. When the plane gets sufficient speed, play with the UP and DOWN arrows to adjust the elevator.Perhaps you need to practice a little, to master the arrow keys for the elevator and rudder/ailerons. These control plates have a well-defined behavior. Their deflection depends on how long the keys are pressed, and they automatically (but not too fast) return to their neutral position when the keys are released. Hitting those keys with varying length and frequency allows for quite exact maneuvers.All graphics are handled by the 3D library in "@lib/z3d.l". This builds a shared library with inline-C compilation, using the 'gcc' function in "@lib/native.l". This library links with the low-level X11 libraries to draw individual pixels into a Z-Buffer, which is then copied as a complete image into the X-Window.The Z3d graphics library is not specialized for writing flight simulators, and was used in the past for other 3D applications.The flight simulation is handled completely by "misc/rcsim.l". It defines the model and scene structures, and the physical simulation.The "scene" consists of a green ground and a blue sky, with a runway. The pilot's position (the "tower") is 12 meters above the ground.The camera looks at a spot slightly in front of the airplane, depending on flight direction and velocity vector. The info text on the bottom shows the throttle (possible values are 0, 25, 50, 75 and 100 percent), speed (in km/h) and altitude (in meters). The zoom indicator shows (-), (--), (+) or (++).The simulation time slice is 20 milliseconds, handled by a background task . It calculates the plane's position, orientation, acceleration and velocity, and takes into account the current control values, engine thrust, air and ground friction etc.The sun is at a fixed position in the south at 45 degrees.

http://picolisp.com/wiki/?rcsim