00001 //============================================================================== 00002 // Copyright (c) 2019, Peter Weissig, TU Chemnitz 00003 // All rights reserved. 00004 // 00005 // Redistribution and use in source and binary forms, with or without 00006 // modification, are permitted provided that the following conditions are met: 00007 // * Redistributions of source code must retain the above copyright 00008 // notice, this list of conditions and the following disclaimer. 00009 // * Redistributions in binary form must reproduce the above copyright 00010 // notice, this list of conditions and the following disclaimer in the 00011 // documentation and/or other materials provided with the distribution. 00012 // * Neither the name of the Flight Systems and Automatic Control group, 00013 // TU Darmstadt, nor the names of its contributors may be used to 00014 // endorse or promote products derived from this software without 00015 // specific prior written permission. 00016 // 00017 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 00018 // AND 00019 // ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 00020 // WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 00021 // DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY 00022 // DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 00023 // (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 00024 // LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 00025 // ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 00026 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 00027 // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 00028 //============================================================================== 00029 00030 // This file is an addon from TUC-ProAut (https://github.com/TUC-ProAut/). 00031 // It was created to log all data from the ublox to a logfile and to publish 00032 // the data as ros messages. This is used by our group to also evaluate the 00033 // measured data with the rtklib. 00034 00035 00036 #ifndef UBLOX_RAW_DATA_PA_H 00037 #define UBLOX_RAW_DATA_PA_H 00038 00039 // STL 00040 #include <vector> 00041 #include <set> 00042 #include <fstream> 00043 00044 // ROS includes 00045 #include <ros/ros.h> 00046 00047 // ROS messages 00048 #include <std_msgs/UInt8MultiArray.h> 00049 00055 namespace ublox_node { 00056 00060 class RawDataStreamPa { 00061 public: 00062 00063 00068 RawDataStreamPa(bool is_ros_subscriber = false); 00069 00073 void getRosParams(void); 00074 00078 bool isEnabled(void); 00079 00087 void initialize(void); 00088 00094 void ubloxCallback(const unsigned char* data, 00095 const std::size_t size); 00096 00101 void msgCallback(const std_msgs::UInt8MultiArray::ConstPtr& msg); 00102 00103 private: 00107 std_msgs::UInt8MultiArray str2uint8(const std::string str); 00108 00113 void publishMsg(const std::string str); 00114 00119 void saveToFile(const std::string str); 00120 00122 std::string file_dir_; 00124 std::string file_name_; 00126 std::ofstream file_handle_; 00127 00129 bool flag_publish_; 00130 00134 bool is_ros_subscriber_; 00135 00137 ros::NodeHandle pnh_; 00139 ros::NodeHandle nh_; 00140 }; 00141 00142 } 00143 00144 #endif