Thursday, May 25, 2006

Concorde at 1000mph, FlightGear, DTK - FUN, fun, fun

After a couple of days working at it, I finally got one of the software components of the project working. The people who made Flight Gear are really smart and gave users a way to read and write values into the game simulation. This is smart because it means reading the accelerations from the game can be done, which then can be mapped into translations for the Moog Motion Base (the actual Flight Simulator) and together this gives the user the 'flying experience'. With a little motion and watching the screen, the brain can be tricked and the person is immersed in a virtual flying experience - this is also known as motion queuing. The same can be applied to race car simulators, boat simulators, etc. etc.

Now some fun stuff! On the FlightGear website you can download more scenery and planes. I chose to download a Souther Ontario map, a U.A.E. map and a Concorde plane. Installing them was easy - just unpack into the correct directories and you are ready to fly. The Hamilton, Abu Dhabi and Dubai maps were really boring. Dubai was not as bad as Abu Dhabi which was all desert and a one runway airport - but still boring. So I ran the simulator with the Concorde model and took some screenshots. The one below was the best - flying at 100mph! (woops..I turned off the speedometer without realizing it so you cannot see that - tough luck)


For those who are interested in knowing the details...
FlightGear
So for those who are interested in knowing how this works - continue reading. Like I said FlightGear gives the user a lot of control in the simulation. You can read the simulation parameters from a browser, write to serial ports, send TCP or UDP packets and whole suite of other protocols. UDP packets are easy to deal with, just reading and writing to the UDP port - just like a file. Using an XML document you can tell FlightGear which values you are interested in. In my case these were the accelerations in all six dimensions - x,y,z, roll, pitch and yaw (look those up to know what axis they are). Now what is left is to write a little UDP listener that will listen to the port you specify and read the packets as they arrive. Because it will arrive as a string of numbers, the easiest way to read each parameter is through defining the format yourself in the XML file. I used a '*' to separate them and broke the string that way when it arrived.

DIVERSE - Device Independent Virtual Environments - Reconfigurable, Scalable, Extendable (DTK)
The next step involves this library which can be found here. DTK is the 'glue' that 'glues' everything together. A whole collection of C++ client, server and utility programs that manage the shared memory and allow other applications on other computers on the network to read and write from it. Since the graphics will be running on its own on one machine and another machine will run the physics engine for FlightGear this makes communication easy. After reading the UDP packet it can be written to the shared memory using DTK and then these values can be read by any remote computer that is connected to this shared memory. All you have to learn is how to read and write from it, and that is covered by the beginner's tutorial on the website. You might be asking yourself why can't we just run everything on one computer like any other game? The answer is simply quality. One machine might start lagging if it has to take care of user input from the joystick, filtering it and then passing it to the FlightGear engine and produce graphics on the screen. Having one high-end computer do the graphics can make the simulation much smoother and more realistic which is really the whole point of having a simulator.

No comments:

Post a Comment