SCANsat#

Provides functionality to interact with the SCANsat mod. Tested with SCANsat 22.1.

Example#

The following example switches on the scanners of the active vessel, then prints the altimetry coverage of the body it orbits and the height of the terrain below it:

#include <iomanip>
#include <iostream>
#include <krpc.hpp>
#include <krpc/services/scan_sat.hpp>
#include <krpc/services/space_center.hpp>

int main() {
  krpc::Connection conn = krpc::connect("SCANsat Example");
  krpc::services::SpaceCenter sc(conn);
  krpc::services::ScanSat scansat(conn);
  auto vessel = sc.active_vessel().value();

  for (auto scanner : scansat.scanners(vessel)) scanner.set_active(true);

  auto body = vessel.orbit().body();
  auto coverage =
      scansat.coverage(body, krpc::services::ScanSat::ScanType::altimetry);
  std::cout << std::fixed << std::setprecision(1)
            << "Altimetry coverage of " << body.name() << ": "
            << coverage * 100 << "%" << std::endl;

  auto flight = vessel.flight();
  auto elevation =
      scansat.elevation(body, flight.latitude(), flight.longitude());
  if (!elevation)
    std::cout << "The terrain below the vessel is not scanned" << std::endl;
  else
    std::cout << std::setprecision(0)
              << "The terrain below the vessel is at " << *elevation << " m"
              << std::endl;
}