34 #include <boost/regex.hpp> 44 #define ANGLE_MIN -180 48 #define THETA_Y_MAX 90 52 #define THETA_Y_MIN -90 56 #define LEVER_ARM_MAX 100 60 #define LEVER_ARM_MIN -100 64 #define HEADING_MAX 360 68 #define HEADING_MIN -360 79 #ifndef ATTSTD_DEV_MIN 80 #define ATTSTD_DEV_MIN 0 83 #ifndef ATTSTD_DEV_MAX 84 #define ATTSTD_DEV_MAX 5 87 #ifndef POSSTD_DEV_MIN 88 #define POSSTD_DEV_MIN 0 91 #ifndef POSSTD_DEV_MAX 92 #define POSSTD_DEV_MAX 100 124 handlers_(node, settings),
139 if (boost::regex_match(
settings_->
device, match, boost::regex(
"(tcp)://(.+):(\\d+)")))
158 boost::regex(
"(file_name):(/|(?:/[\\w-]+)+.sbf)")))
167 }
else if (boost::regex_match(
169 boost::regex(
"(file_name):(/|(?:/[\\w-]+)+.pcap)")))
178 }
else if (boost::regex_match(
settings_->
device, match, boost::regex(
"(serial):(.+)")))
183 std::string proto(match[2]);
184 std::stringstream ss;
185 ss <<
"Searching for serial port" << proto;
191 std::stringstream ss;
192 ss <<
"Device is unsupported. Perhaps you meant 'tcp://host:port' or 'file_name:xxx.sbf' or 'serial:/path/to/device'?";
202 std::stringstream ss;
203 ss <<
"Setting up everything needed to read from" << file_name;
206 }
catch (std::runtime_error& e)
208 std::stringstream ss;
209 ss <<
"Comm_IO::initializeSBFFileReading() failed for SBF File" << file_name
210 <<
" due to: " << e.what();
219 std::stringstream ss;
220 ss <<
"Setting up everything needed to read from " << file_name;
223 }
catch (std::runtime_error& e)
225 std::stringstream ss;
226 ss <<
"CommIO::initializePCAPFileReading() failed for SBF File " << file_name
227 <<
" due to: " << e.what();
236 "Started timer for calling reconnect() method until connection succeeds");
238 boost::asio::io_service io;
242 boost::asio::deadline_timer
t(io, wait_ms);
257 bool initialize_serial_return =
false;
262 initialize_serial_return =
264 }
catch (std::runtime_error& e)
267 std::stringstream ss;
269 <<
" due to: " << e.what();
273 if (initialize_serial_return)
282 bool initialize_tcp_return =
false;
288 }
catch (std::runtime_error& e)
291 std::stringstream ss;
292 ss <<
"initializeTCP() failed for host " <<
tcp_host_ 293 <<
" on port " <<
tcp_port_ <<
" due to: " << e.what();
297 if (initialize_tcp_return)
329 boost::regex_match(
settings_->
device, match, boost::regex(
"(tcp)://(.+):(\\d+)"));
330 std::string proto(match[1]);
336 boost::mutex::scoped_lock lock_cd(
g_cd_mutex);
339 std::string
cmd(
"\x0DSSSSSSSSSSSSSSSSSSS\x0D\x0D");
340 manager_.get()->send(cmd, cmd.size());
352 send(
"lif, Identification \x0D");
355 std::string pvt_interval;
358 pvt_interval =
"OnChange";
362 uint32_t rx_period_pvt =
364 std::string pvt_sec_or_msec;
367 pvt_sec_or_msec =
"sec";
369 pvt_sec_or_msec =
"msec";
371 pvt_interval = pvt_sec_or_msec + std::to_string(rx_period_pvt);
374 std::string rest_interval;
376 uint32_t rx_period_rest =
378 std::string rest_sec_or_msec;
381 rest_sec_or_msec =
"sec";
383 rest_sec_or_msec =
"msec";
385 rest_interval = rest_sec_or_msec + std::to_string(rx_period_rest);
394 send(
"sso, all, none, none, off \x0D");
395 send(
"sno, all, none, none, off \x0D");
399 send(
"sntp, on \x0D");
405 std::stringstream ss;
412 std::stringstream blocks;
415 blocks <<
" +PVTCartesian";
422 blocks <<
" +PVTGeodetic";
426 blocks <<
" +PosCovCartesian";
433 blocks <<
" +PosCovGeodetic";
438 blocks <<
" +VelCovGeodetic";
444 blocks <<
" +AttEuler";
450 blocks <<
" +AttCovEuler";
455 blocks <<
" +MeasEpoch";
459 blocks <<
" +ChannelStatus +DOP";
467 blocks <<
" +INSNavCart";
477 blocks <<
" +INSNavGeod";
481 blocks <<
" +ExtEventINSNavGeod";
485 blocks <<
" +ExtEventINSNavCart";
490 blocks <<
" +ExtSensorMeas";
493 std::stringstream ss;
494 ss <<
"sso, Stream" << std::to_string(stream) <<
", " << rx_port
495 <<
"," << blocks.str() <<
", " << pvt_interval
502 std::stringstream blocks;
507 blocks <<
" +IMUSetup";
511 blocks <<
" +VelSensorSetup";
516 blocks <<
" +ReceiverStatus +QualityInd +ReceiverSetup";
519 std::stringstream ss;
520 ss <<
"sso, Stream" << std::to_string(stream) <<
", " << rx_port
521 <<
"," << blocks.str() <<
", " << rest_interval
529 std::stringstream ss;
531 ss <<
"snti, GP" <<
"\x0D";
536 std::stringstream ss;
538 ss <<
"sno, Stream" << std::to_string(stream) <<
", " << rx_port <<
", GGA, " 539 << pvt_interval <<
"\x0D";
545 std::stringstream ss;
547 ss <<
"sno, Stream" << std::to_string(stream) <<
", " << rx_port <<
", RMC, " 548 << pvt_interval <<
"\x0D";
554 std::stringstream ss;
556 ss <<
"sno, Stream" << std::to_string(stream) <<
", " << rx_port <<
", GSA, " 557 << pvt_interval <<
"\x0D";
563 std::stringstream ss;
565 ss <<
"sno, Stream" << std::to_string(stream) <<
", " << rx_port <<
", GSV, " 566 << rest_interval <<
"\x0D";
577 std::stringstream ss;
587 std::stringstream ss;
598 std::stringstream ss;
605 std::stringstream ss;
614 std::stringstream ss;
615 ss <<
"snts, NTR1, off \x0D";
625 std::stringstream ss;
635 std::stringstream ss;
636 ss <<
"snts, NTR1, Client-Sapcorda, , , , , , , , \x0D";
651 std::stringstream ss;
658 std::stringstream ss;
659 ss <<
"sno, Stream" << std::to_string(stream) <<
", IPS1, GGA, " 660 << pvt_interval <<
" \x0D";
666 std::stringstream ss;
682 send(
"sga, MultiAntenna \x0D");
686 send(
"sga, none \x0D");
693 std::stringstream ss;
709 std::stringstream ss;
730 std::stringstream ss;
738 node_->
log(
LogLevel::ERROR,
"Please specify a correct value for x, y and z in the config file under ant_lever_arm");
747 std::stringstream ss;
755 node_->
log(
LogLevel::ERROR,
"Please specify a correct value for poi_x, poi_y and poi_z in the config file under poi_lever_arm");
764 std::stringstream ss;
772 node_->
log(
LogLevel::ERROR,
"Please specify a correct value for vsm_x, vsm_y and vsm_z in the config file under vel_sensor_lever_arm");
780 std::stringstream ss;
781 ss <<
"sinc, off, all, MainAnt \x0D";
787 std::stringstream ss;
790 ss <<
"sinc, on, all, " <<
"POI1" <<
" \x0D";
795 ss <<
"sinc, on, all, " <<
"MainAnt" <<
" \x0D";
802 std::stringstream ss;
824 std::stringstream ss;
1021 "PoseWithCovarianceStamped");
1030 "INSPoseWithCovarianceStamped");
1064 manager_.get()->send(cmd, cmd.size());
1077 new boost::asio::io_service);
1078 boost::asio::ip::tcp::resolver::iterator endpoint;
1082 boost::asio::ip::tcp::resolver resolver(*io_service);
1089 endpoint = resolver.resolve(boost::asio::ip::tcp::resolver::query(
1091 }
catch (std::runtime_error& e)
1093 throw std::runtime_error(
"Could not resolve " + host +
" on port " + port +
1099 new boost::asio::ip::tcp::socket(*io_service));
1107 socket->connect(*endpoint);
1108 socket->set_option(boost::asio::ip::tcp::no_delay(
true));
1109 }
catch (std::runtime_error& e)
1111 throw std::runtime_error(
"Could not connect to " + endpoint->host_name() +
1112 ": " + endpoint->service_name() +
": " + e.what());
1117 ":" + endpoint->service_name() +
".");
1122 "You have called the InitializeTCP() method though an AsyncManager object is already available! Start all anew..");
1134 std::size_t buffer_size = 8192;
1135 uint8_t* to_be_parsed;
1136 to_be_parsed =
new uint8_t[buffer_size];
1137 std::ifstream bin_file(file_name, std::ios::binary);
1138 std::vector<uint8_t> vec_buf;
1139 if (bin_file.good())
1143 std::vector<uint8_t> v_buf((std::istreambuf_iterator<char>(bin_file)),
1144 (std::istreambuf_iterator<char>()));
1149 throw std::runtime_error(
"I could not find your file. Or it is corrupted.");
1152 to_be_parsed = vec_buf.data();
1153 std::stringstream ss;
1154 ss <<
"Opened and copied over from " << file_name;
1162 "Calling read_callback_() method, with number of bytes to be parsed being " +
1165 }
catch (std::size_t& parsing_failed_here)
1167 if (to_be_parsed - vec_buf.data() >= vec_buf.size() *
sizeof(uint8_t))
1171 to_be_parsed = to_be_parsed + parsing_failed_here;
1175 if (to_be_parsed - vec_buf.data() >= vec_buf.size() *
sizeof(uint8_t))
1179 to_be_parsed = to_be_parsed + buffer_size;
1190 if (!device.
connect(file_name.c_str()))
1202 uint8_t* to_be_parsed =
new uint8_t[buffer_size];
1203 to_be_parsed = vec_buf.data();
1210 "Calling read_callback_() method, with number of bytes to be parsed being " +
1213 }
catch (std::size_t& parsing_failed_here)
1215 if (to_be_parsed - vec_buf.data() >= vec_buf.size() *
sizeof(uint8_t))
1219 if (!parsing_failed_here)
1220 parsing_failed_here = 1;
1222 to_be_parsed = to_be_parsed + parsing_failed_here;
1226 if (to_be_parsed - vec_buf.data() >= vec_buf.size() *
sizeof(uint8_t))
1230 to_be_parsed = to_be_parsed + buffer_size;
1236 std::string flowcontrol)
1244 new boost::asio::io_service);
1247 new boost::asio::serial_port(*io_service));
1253 }
catch (std::runtime_error& e)
1256 throw std::runtime_error(
"Could not open serial port : " +
serial_port_ +
1263 if (BOOST_VERSION < 106600)
1271 int fd = serial->native_handle();
1275 tcgetattr(fd, &tio);
1278 if (flowcontrol ==
"RTS|CTS")
1280 tio.c_iflag &= ~(IXOFF | IXON);
1281 tio.c_cflag |= CRTSCTS;
1284 tio.c_iflag &= ~(IXOFF | IXON);
1285 tio.c_cflag &= ~CRTSCTS;
1293 tcsetattr(fd, TCSANOW, &tio);
1300 "You have called the initializeSerial() method though an AsyncManager object is already available! Start all anew..");
1309 boost::asio::serial_port_base::baud_rate current_baudrate;
1318 }
catch (boost::system::system_error& e)
1323 boost::diagnostic_information(e));
1339 if (current_baudrate.value() ==
baudrate_)
1351 boost::asio::serial_port_base::baud_rate(
BAUDRATES[i]));
1352 }
catch (boost::system::system_error& e)
1357 boost::diagnostic_information(e));
1366 serial->get_option(current_baudrate);
1367 }
catch (boost::system::system_error& e)
1372 boost::diagnostic_information(e));
1385 ", leaving InitializeSerial() method");
1404 new boost::asio::io_service);
1406 new boost::asio::serial_port(*io_service));
1412 }
catch (std::runtime_error& e)
1414 throw std::runtime_error(
"Could not open serial port :" +
serial_port_ +
1427 serial->set_option(boost::asio::serial_port_base::baud_rate(
baudrate_));
double theta_z
IMU orientation z-angle.
septentrio_gnss_driver::VelCovGeodetic VelCovGeodeticMsg
bool connected_
Whether connecting to Rx was successful.
nmea_msgs::Gpgsa GpgsaMsg
uint32_t polling_period_rest
Polling period for all other SBF blocks and NMEA messages.
ReadResult read()
Attempt to read a packet and store data to buffer.
boost::mutex connection_mutex_
boost::shared_ptr< Manager > manager_
septentrio_gnss_driver::AttCovEuler AttCovEulerMsg
uint32_t baudrate_
Baudrate at the moment, unless InitializeSerial or ResetSerial fail.
bool publish_insnavcart
Whether or not to publish the INSNavCartMsg message.
bool publish_attcoveuler
Whether or not to publish the AttCovEulerMsg message.
float delta_e
Marker-to-ARP offset in the eastward direction.
bool publish_tf
Whether or not to publish the tf of the localization.
bool read_from_sbf_log
Whether or not we are reading from an SBF file.
std::string hw_flow_control
HW flow control.
void readCallback(Timestamp recvTimestamp, const uint8_t *data, std::size_t &size)
Searches for Rx messages that could potentially be decoded/parsed/published.
bool publish_poscovgeodetic
std::vector< uint8_t > buffer_t
Settings * settings_
Settings.
void prepareSBFFileReading(std::string file_name)
Sets up the stage for SBF file reading.
double poi_x
INS POI offset in x-dimension.
uint32_t rx_input_corrections_tcp
std::string ntrip_password
Password for NTRIP service.
std::string rtcm_version
RTCM version for NTRIP service (if Rx does not have internet)
Comm_IO(ROSaicNodeBase *node, Settings *settings)
Constructor of the class Comm_IO.
void defineMessages()
Defines which Rx messages to read and which ROS messages to publish.
bool serial_
Whether yet-to-be-established connection to Rx will be serial or TCP.
static const unsigned int SET_BAUDRATE_SLEEP_
std::string ant_serial_nr
Serial number of your particular Main antenna.
bool g_response_received
Determines whether a command reply was received from the Rx.
septentrio_gnss_driver::PVTGeodetic PVTGeodeticMsg
std::string rx_input_corrections_serial
septentrio_gnss_driver::VelSensorSetup VelSensorSetupMsg
void disconnect()
Close connected file.
bool isConnected() const
Check if file is open and healthy.
septentrio_gnss_driver::INSNavCart INSNavCartMsg
bool initializeSerial(std::string port, uint32_t baudrate=115200, std::string flowcontrol="None")
Initializes the serial port.
void initializeIO()
Initializes the I/O handling.
void initializeSBFFileReading(std::string file_name)
Initializes SBF file reading and reads SBF file by repeatedly calling read_callback_() ...
std::unique_ptr< boost::thread > connectionThread_
Connection or reading thread.
Highest-Level view on communication services.
bool ins_use_poi
INS solution reference point.
void reconnect()
Attempts to (re)connect every reconnect_delay_s_ seconds.
std::string login_user
Username for login.
septentrio_gnss_driver::ExtSensorMeas ExtSensorMeasMsg
double vsm_x
INS velocity sensor lever arm x-offset.
double vsm_y
INS velocity sensor lever arm y-offset.
void log(LogLevel logLevel, const std::string &s)
Log function to provide abstraction of ROS loggers.
bool connect(const char *device)
Try to open a pcap file.
septentrio_gnss_driver::AttEuler AttEulerMsg
geometry_msgs::TransformStamped t
septentrio_gnss_driver::IMUSetup IMUSetupMsg
boost::mutex g_cd_mutex
Mutex to control changes of global variable "g_cd_received".
std::string serial_port_
Saves the port description.
nmea_msgs::Gpgsv GpgsvMsg
std::string rx_serial_port
nmea_msgs::Gprmc GprmcMsg
bool publish_gpst
Whether or not to publish the TimeReferenceMsg message with GPST.
double poi_y
INS POI offset in y-dimension.
ROSaicNodeBase * node_
Pointer to Node.
static const size_t BUFFSIZE
double ant_lever_x
INS antenna lever arm x-offset.
nmea_msgs::Gpgga GpggaMsg
uint32_t polling_period_pvt
Polling period for PVT-related SBF blocks.
std::string port_
Port over which TCP/IP connection is currently established.
bool publish_insnavgeod
Whether or not to publish the INSNavGeodMsg message.
bool publish_gprmc
Whether or not to publish the RMC message.
bool rx_has_internet
Whether Rx has internet or not.
double poi_z
INS POI offset in z-dimension.
void resetSerial(std::string port)
Reset the Serial I/O port, e.g. after a Rx reset.
bool publish_gpgsa
Whether or not to publish the GSA message.
bool initializeTCP(std::string host, std::string port)
Initializes the TCP I/O.
float delta_n
Marker-to-ARP offset in the northward direction.
std::string login_password
Password for login.
bool publish_poscovcartesian
bool publish_measepoch
Whether or not to publish the MeasEpoch message.
std::string trimDecimalPlaces(double num)
Trims decimal places to two.
CallbackMap insert(std::string message_key)
Adds a pair to the multimap "callbackmap_", with the message_key being the key.
bool publish_extsensormeas
Whether or not to publish the ExtSensorMeasMsg message.
double heading_offset
Attitude offset determination in longitudinal direction.
bool publish_gpgga
Whether or not to publish the GGA message.
boost::condition_variable g_response_condition
Condition variable complementing "g_response_mutex".
std::string mountpoint
Mountpoint for NTRIP service.
bool publish_localization
Whether or not to publish the LocalizationMsg message.
septentrio_gnss_driver::INSNavGeod INSNavGeodMsg
std::string ant_aux1_serial_nr
Serial number of your particular Aux1 antenna.
std::string septentrio_receiver_type
Septentrio receiver type, either "gnss" or "ins".
static const uint32_t BAUDRATES[]
Possible baudrates for the Rx.
std::string g_rx_tcp_port
Rx TCP port, e.g. IP10 or IP11, to which ROSaic is connected to.
uint32_t convertUserPeriodToRxCommand(uint32_t period_user)
Transforms the input polling period [milliseconds] into a uint32_t number that can be appended to eit...
Class for handling a pcap file.
bool publish_pvtcartesian
uint32_t baudrate
Baudrate.
bool read_from_pcap
Whether or not we are reading from a PCAP file.
bool publish_velcovgeodetic
double theta_x
IMU orientation x-angle.
bool publish_velsensorsetup
Whether or not to publish the VelSensorSetupMsg message.
void preparePCAPFileReading(std::string file_name)
Sets up the stage for PCAP file reading.
std::string device
Device port.
std::string caster
Hostname or IP address of the NTRIP caster to connect to.
septentrio_gnss_driver::PosCovGeodetic PosCovGeodeticMsg
bool publish_pvtgeodetic
Whether or not to publish the PVTGeodeticMsg message.
std::string ntrip_mode
Type of NTRIP connection.
bool publish_exteventinsnavcart
Whether or not to publish the ExtEventINSNavCartMsg message.
bool publish_gpsfix
Whether or not to publish the GPSFixMsg message.
septentrio_gnss_driver::PosCovCartesian PosCovCartesianMsg
void configureRx()
Configures Rx: Which SBF/NMEA messages it should output and later correction settings.
bool g_cd_received
Determines whether the connection descriptor was received from the Rx.
std::string tcp_port_
TCP port number.
boost::condition_variable connection_condition_
std::string send_gga
Whether (and at which rate) or not to send GGA to the NTRIP caster.
std::atomic< bool > stopping_
Indicator for threads to exit.
bool publish_imu
Whether or not to publish the ImuMsg message.
bool publish_imusetup
Whether or not to publish the IMUSetupMsg message.
double ant_lever_y
INS antenna lever arm y-offset.
boost::condition_variable g_cd_condition
Condition variable complementing "g_cd_mutex".
diagnostic_msgs::DiagnosticArray DiagnosticArrayMsg
Declares a class for handling pcap files.
float att_std_dev
Attitude deviation mask.
void setManager(const boost::shared_ptr< Manager > &manager)
Set the I/O manager.
float pos_std_dev
Position deviation mask.
This is the central interface between ROSaic and the Rx(s), managing I/O operations such as reading m...
std::string ant_aux1_type
bool publish_exteventinsnavgeod
Whether or not to publish the ExtEventINSNavGeodMsg message.
Timestamp getTime()
Gets current timestamp.
nav_msgs::Odometry LocalizationUtmMsg
CallbackHandlers handlers_
Callback handlers for the inwards streaming messages.
void send(std::string cmd)
Hands over to the send() method of manager_.
double vsm_z
INS velocity sensor lever arm z-offset.
double pitch_offset
Attitude offset determination in latitudinal direction.
bool publish_atteuler
Whether or not to publish the AttEulerMsg message.
std::string ntrip_version
NTRIP version for NTRIP service.
std::string datum
Datum to be used.
This class is the base class for abstraction.
double theta_y
IMU orientation y-angle.
void initializePCAPFileReading(std::string file_name)
Initializes PCAP file reading and reads PCAP file by repeatedly calling read_callback_() ...
std::string trimString(std::string str)
Removes trailing zeros from a string representing a float or double except for the first zero after t...
boost::mutex g_response_mutex
Mutex to control changes of global variable "g_response_received".
bool publish_gpgsv
Whether or not to publish the GSV message.
uint32_t caster_port
IP port number of NTRIP caster to connect to.
bool publish_diagnostics
Whether or not to publish the DiagnosticArrayMsg message.
bool publish_pose
Whether or not to publish the PoseWithCovarianceStampedMsg message.
std::string ins_initial_heading
For heading computation when unit is powered-cycled.
septentrio_gnss_driver::PVTCartesian PVTCartesianMsg
void connect()
Calls the reconnect() method.
sensor_msgs::NavSatFix NavSatFixMsg
std::string tcp_host_
Host name of TCP server.
gps_common::GPSFix GPSFixMsg
std::string ntrip_username
Username for NTRIP service.
geometry_msgs::PoseWithCovarianceStamped PoseWithCovarianceStampedMsg
bool multi_antenna
INS multiantenna.
bool publish_navsatfix
Whether or not to publish the NavSatFixMsg message.
std::string host_
Host currently connected to.
float delta_u
Marker-to-ARP offset in the upward direction.
double ant_lever_z
INS antenna lever arm z-offset.