Description: Implementation of the height sensing susbsytem in C and Windows 10, gcc (x86_64-posix-seh-rev0, Built by MinGW-W64 project) 8.1.0, and CMake version 3.18.0-rc2.
Design decisions: I usually work in Ubuntu 16.04 but, my current laptop does not let me have two operating systems. On the other hand, I usually work in C++ or Python, but the program was made in C because I thought that was the programming language for this application. This program does not use any classes, just functions (a simple implementation).
According to the documentation provided, there are two modules:
-
listener: In this module I defined the UDP server interface to read data from the Lunar lander. It was set to port=12777 and host="127.0.0.1". This program initialize winsock (windows module for socket development), start a socket and then, wait for incoming data.
-
publisher: In this module I defined the UDP client interface to send data from the Lunar lander. It was set to port=12777 and host="127.0.0.1". This program initialize winsock (windows module for socket development), start a socket and then, read the simulator file 2bytes-per line, apply a big-endian alignment and then, publish a message to the server.
The height is calculated with the following formula:
height = (raw reading/65535)*1000
Then, I check if the height is close to zero to detect a landing event. For eacg LASER_ALTIMETER data from the simulator file, a message is send to the server with the following format:
standard reading:
HEIGHT val
landing event:
ENGINE_CUTOFF 0.0000
I assumed that the simulator file contain the raw readings from one or all of the sensing heads (since I did not find information about this in the documentation).
Run these commands in the /build folder.
- create cmake files
cmake ../ -G "MinGW Makefiles"
- compile
make
Open two command lines and:
- for listener file.
./listener.exe
- for publisher file.
./publisher.exe <path to simulator file>
e.g.
./publisher.exe ../docs/simulator.txt