Out of Range - Takeoff

/* Title: Out of Range - Takeoff
 * Description:The Maglev can only take off if the flotor is in a position which can be detected by the devices sensors.
 * Usually, the monitor program is being used to check the sensors' status and to manually align the flotor so that it can
 * take off. This is rather inconvinient since it requires to start the monitor program everytime the flotor is out of range.
 * The following code snippet shows an alternative method: It repeatedly checks the status of the Maglev sensors until
 * the flotor is in range of the sensors, then it will take off. If the flotor is out of range, a message will tell the user to
 * slowly move and rotate the flotor. As soon as the flotor gets in the range of the sensors, the code will initiate
 * a take off.

  //connect to the device
   if (ml_Connect(&device_hdl, HOST_NAME) != ML_STATUS_OK) {
        cout << "Unable to connect to MLHI device! Check name or IP address!" << endl;

    //Variable used to store the maglevs fault status
    ml_fault_t fault; fault.value = 1;

    //Loop until the device is ready (no faults, all sensors see the flotor)
    while (fault.value != 0) {       
        ml_GetFault(device_hdl, &fault);    //Get the devices fault status
        ml_ResetFault(device_hdl);            //Try to clear the fault status
        usleep(500000);                           //Wait for some time, such as 0.5sec
        cout << "Sensors out of range. Move the flotor until it takes off..." << endl;

    //we are clear to take off, so let's do it