ROSaic
parsing_utilities.hpp
Go to the documentation of this file.
1 // *****************************************************************************
2 //
3 // © Copyright 2020, Septentrio NV/SA.
4 // All rights reserved.
5 //
6 // Redistribution and use in source and binary forms, with or without
7 // modification, are permitted provided that the following conditions are met:
8 // 1. Redistributions of source code must retain the above copyright
9 // notice, this list of conditions and the following disclaimer.
10 // 2. Redistributions in binary form must reproduce the above copyright
11 // notice, this list of conditions and the following disclaimer in the
12 // documentation and/or other materials provided with the distribution.
13 // 3. Neither the name of the copyright holder nor the names of its
14 // contributors may be used to endorse or promote products derived
15 // from this software without specific prior written permission.
16 //
17 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
18 // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20 // ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
21 // LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
22 // CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
23 // SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
24 // INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
25 // CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
26 // ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
27 // POSSIBILITY OF SUCH DAMAGE.
28 //
29 // *****************************************************************************
30 
31 #ifndef PARSING_UTILITIES_HPP
32 #define PARSING_UTILITIES_HPP
33 
34 // C++ library includes
35 #include <cstdint> // C++ header, corresponds to <stdint.h> in C
36 #include <string> // C++ header, corresponds to <string.h> in C
37 #include <ctime> // C++ header, corresponds to <time.h> in C
38 #include <cmath> // C++ header, corresponds to <math.h> in C
39 // ROS includes
40 #include <ros/ros.h>
41 #include <geometry_msgs/Quaternion.h>
42 
49 namespace parsing_utilities
50 {
51 
57  double parseDouble(const uint8_t* buffer);
58 
67  bool parseDouble(const std::string& string, double& value);
68 
74  float parseFloat(const uint8_t* buffer);
75 
84  bool parseFloat(const std::string& string, float& value);
85 
91  int16_t parseInt16(const uint8_t* buffer);
92 
102  bool parseInt16(const std::string& string, int16_t& value, int32_t base = 10);
103 
109  int32_t parseInt32(const uint8_t* buffer);
110 
120  bool parseInt32(const std::string& string, int32_t& value, int32_t base = 10);
121 
131  bool parseUInt8(const std::string& string, uint8_t& value, int32_t base = 10);
132 
138  uint16_t parseUInt16(const uint8_t* buffer);
139 
149  bool parseUInt16(const std::string& string, uint16_t& value, int32_t base = 10);
150 
156  uint32_t parseUInt32(const uint8_t* buffer);
157 
167  bool parseUInt32(const std::string& string, uint32_t& value, int32_t base = 10);
168 
174  double convertUTCDoubleToSeconds(double utc_double);
175 
183  std::time_t convertUTCtoUnix(double utc_double);
184 
192  double convertDMSToDegrees(double dms);
193 
201  geometry_msgs::Quaternion convertEulerToQuaternion(double yaw, double pitch, double roll);
202 
208  uint32_t convertUserPeriodToRxCommand(uint32_t period_user);
209 }
210 
211 #endif //PARSING_UTILITIES_HPP
212 
213 
214 
float parseFloat(const uint8_t *buffer)
Converts a 4-byte-buffer into a float.
double convertUTCDoubleToSeconds(double utc_double)
Converts UTC time from the without-colon-delimiter format to the number-of-seconds-since-midnight for...
uint16_t parseUInt16(const uint8_t *buffer)
Converts a 2-byte-buffer into an unsigned 16-bit integer.
uint32_t parseUInt32(const uint8_t *buffer)
Converts a 4-byte-buffer into an unsigned 32-bit integer.
double convertDMSToDegrees(double dms)
Converts latitude or longitude from the DMS notation (in the without-colon-delimiter format)...
uint32_t convertUserPeriodToRxCommand(uint32_t period_user)
Transforms the input polling period [milliseconds] into a uint32_t number that can be appended to eit...
time_t convertUTCtoUnix(double utc_double)
Converts UTC time from the without-colon-delimiter format to Unix Epoch time (a number-of-seconds-sin...
double parseDouble(const uint8_t *buffer)
Converts an 8-byte-buffer into a double.
int16_t parseInt16(const uint8_t *buffer)
Converts a 2-byte-buffer into a signed 16-bit integer.
int32_t parseInt32(const uint8_t *buffer)
Converts a 4-byte-buffer into a signed 32-bit integer.
bool parseUInt8(const std::string &string, uint8_t &value, int32_t base)
Interprets the contents of "string" as a unsigned integer number of type uint8_t. ...
geometry_msgs::Quaternion convertEulerToQuaternion(double yaw, double pitch, double roll)
Transforms Euler angles to a quaternion.