Namespaces | |
dpyGnss | |
Deepsy Gnss namespace that includes the different enums, structs or method signatures that should be used. | |
Classes | |
class | GnssObserver |
Gnss Observer class. More... | |
class | Gnss |
Main application. More... | |
class | GnssPosition |
Class that defines a position. More... | |
Detailed Description
GNSS API related documentation
A quick overview of basic GNSS capabilities and examples is given.
If you find GNSS API useful and would like to know more details, please check out further sections of the GNSS API documentation or contact the Deepsy platform team.
Examples
-
Asking for the last position obtained
In order to obtain the last position related information GnssPosition must be attended. An example is provided:#include <dpy/gnssApi.h>#include <iostream>#include <stdio.h>#include <map>#include <iomanip>volatile bool waiting = true;void get_last_position_handler(boost::system::error_code error_code,GnssPosition last_pos){if (error_code) {std::cout << "GNSS get position Error = " << error_code.value() << ", " << error_code.message() << std::endl;fflush (stdout);} else {using namespace dpyGnssPosition;std::map<QualityIndicator, std::string> fix_to_string_map;fix_to_string_map[NO_FIX] = "NO FIX";fix_to_string_map[AUTONOMOUS_FIX] = "AUTONOMOUS FIX";fix_to_string_map[DIFFERENTIAL_FIX] = "DIFFERENTIAL FIX";fix_to_string_map[RTK_FIXED] = "RTK FIXED";fix_to_string_map[RTK_FLOAT] = "RTK FLOAT";fix_to_string_map[ESTIMATED_DEAD_RECKONING_FIX] = "ESTIMATED DEAD RECKONING FIX";std::cout << "Last position FIX status is " << fix_to_string_map[last_pos.fix_quality] << std::endl;char buffer[80];std::cout << "\tLast position DATE is: "<< buffer << " [dd/mm/yyyy]" << std::endl;std::cout << "\tLast position UTC TIME is: " << buffer << " [hh:mm:ss]" << std::endl;if (last_pos.fix_quality != dpyGnssPosition::NO_FIX) {std::cout << std::fixed << std::setprecision(6); //To print 6 decimal digits for the floatstd::cout << "\tGeographic position in decimal degrees is: [" << last_pos.lat_deg << "," << last_pos.lon_deg << "]" << std::endl;std::cout << std::fixed << std::setprecision(2); //To print 2 decimal digits for the floatstd::cout << "\tAltitude above/below mean sea level is: " << last_pos.alt_m << " meters" << std::endl;std::cout << "\tHorizontal dilution of precision is: " << last_pos.HDOP << std::endl;std::cout << "\tSpeed over the ground is: " << last_pos.speed_kmh << " kilometres per hour" << std::endl;std::cout << "\tCourse over the ground (track angle) is: " << last_pos.dir_deg << " degrees" << std::endl;}}waiting = false;}int main(){Gnss gnss;gnss.asyncGetLastPosition(get_last_position_handler);while (waiting == true){}} -
Obtaining GNSS next position updates
In order to obtain the position related information GnssPosition must be attended. An example is provided:#include <dpy/gnssApi.h>#include <iostream>#include <stdio.h>#include <map>#include <iomanip>void get_position_updates_handler(boost::system::error_code error_code, GnssPosition current_pos){if (error_code) {std::cout << "GNSS get position Error = " << error_code.value() << ", " << error_code.message() << std::endl;fflush(stdout);} else {using namespace dpyGnssPosition;std::map<QualityIndicator, std::string> fix_to_string_map;fix_to_string_map[NO_FIX] = "NO FIX";fix_to_string_map[AUTONOMOUS_FIX] = "AUTONOMOUS FIX";fix_to_string_map[DIFFERENTIAL_FIX] = "DIFFERENTIAL FIX";fix_to_string_map[RTK_FIXED] = "RTK FIXED";fix_to_string_map[RTK_FLOAT] = "RTK FLOAT";fix_to_string_map[ESTIMATED_DEAD_RECKONING_FIX] = "ESTIMATED DEAD RECKONING FIX";std::cout << "Current position FIX status is " << fix_to_string_map[current_pos.fix_quality] << std::endl;char buffer[80];std::cout << "\tCurrent position DATE is: " << buffer << " [dd/mm/yyyy]" << std::endl;std::cout << "\tCurrent position UTC TIME is: " << buffer << " [hh:mm:ss]" << std::endl;if (current_pos.fix_quality != dpyGnssPosition::NO_FIX) {std::cout << std::fixed << std::setprecision(6); //To print 6 decimal digits for the floatstd::cout << "\tGeographic position in decimal degrees is: [" << current_pos.lat_deg << "," << current_pos.lon_deg << "]" << std::endl;std::cout << std::fixed << std::setprecision(2); //To print 2 decimal digits for the floatstd::cout << "\tAltitude above/below mean sea level is: " << current_pos.alt_m << " meters" << std::endl;std::cout << "\tHorizontal dilution of precision is: " << current_pos.HDOP << std::endl;std::cout << "\tSpeed over the ground is: " << current_pos.speed_kmh << " kilometres per hour" << std::endl;std::cout << "\tCourse over the ground (track angle) is: " << current_pos.dir_deg << " degrees" << std::endl;}}}int main(){Gnss gnss;gnss.getPeriodicPosition_S(get_position_updates_handler);sleep(5);return 0;} -
Using observer pattern
To use observer pattern an class which overrides NewPosition method shall be used. An example is provided:#include <dpy/gnssApi.h>#include <iostream>#include <stdio.h>#include <map>{public:{using namespace dpyGnssPosition;std::map<QualityIndicator, std::string> fix_to_string_map;fix_to_string_map[NO_FIX] = "NO FIX";fix_to_string_map[AUTONOMOUS_FIX] = "AUTONOMOUS FIX";fix_to_string_map[DIFFERENTIAL_FIX] = "DIFFERENTIAL FIX";fix_to_string_map[RTK_FIXED] = "RTK FIXED";fix_to_string_map[RTK_FLOAT] = "RTK FLOAT";fix_to_string_map[ESTIMATED_DEAD_RECKONING_FIX] = "ESTIMATED DEAD RECKONING FIX";std::cout << "\r\tLast position FIX status is: " << fix_to_string_map[current_pos.fix_quality] << std::endl;if (current_pos.fix_quality != NO_FIX) {std::cout << "\tPosition coordinates in decimal degrees is: [" << current_pos.lat_deg << "," << current_pos.lon_deg << "]" << std::endl;std::cout << "\tAltitude above/below mean sea level is: " << current_pos.alt_m << " meters" << std::endl;std::cout << "\tHorizontal dilution of precision is: " << current_pos.HDOP << std::endl;std::cout << "\tSpeed over the ground is: " << current_pos.speed_kmh << " kilometres per hour" << std::endl;std::cout << "\tCourse over the ground (track angle) is: " << current_pos.dir_deg << " degrees" << std::endl;}std::cout << "\n";}};int main(){Gnss gnss;Observer obs;gnss.subscribe(&obs);sleep(5);gnss.unsubscribe(&obs);return 0;} -
Obtaining GNSS position synchronously
In order to obtain the position related information GnssPosition must be attended. An example is provided:#include <dpy/gnssApi.h>int main(){Gnss gnss;GnssPosition position;gnss.getLastPosition(position);return 0;}