insstdev.cpp
Go to the documentation of this file.
00001 // *****************************************************************************
00002 //
00003 // Copyright (c) 2017, Southwest Research Institute® (SwRI®)
00004 // All rights reserved.
00005 //
00006 // Redistribution and use in source and binary forms, with or without
00007 // modification, are permitted provided that the following conditions are met:
00008 //     * Redistributions of source code must retain the above copyright
00009 //       notice, this list of conditions and the following disclaimer.
00010 //     * Redistributions in binary form must reproduce the above copyright
00011 //       notice, this list of conditions and the following disclaimer in the
00012 //       documentation and/or other materials provided with the distribution.
00013 //     * Neither the name of Southwest Research Institute® (SwRI®) nor the
00014 //       names of its contributors may be used to endorse or promote products
00015 //       derived from this software without specific prior written permission.
00016 //
00017 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
00018 // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
00019 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
00020 // ARE DISCLAIMED. IN NO EVENT SHALL SOUTHWEST RESEARCH INSTITUTE BE LIABLE FOR ANY
00021 // DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
00022 // (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
00023 // LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
00024 // ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
00025 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
00026 // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00027 //
00028 // *****************************************************************************
00029 
00030 #include <novatel_gps_driver/parsers/insstdev.h>
00031 #include <novatel_gps_driver/parsers/header.h>
00032 #include <boost/make_shared.hpp>
00033 
00034 const std::string novatel_gps_driver::InsstdevParser::MESSAGE_NAME = "INSSTDEV";
00035 
00036 uint32_t novatel_gps_driver::InsstdevParser::GetMessageId() const
00037 {
00038   return MESSAGE_ID;
00039 }
00040 
00041 const std::string novatel_gps_driver::InsstdevParser::GetMessageName() const
00042 {
00043   return MESSAGE_NAME;
00044 }
00045 
00046 novatel_gps_msgs::InsstdevPtr
00047 novatel_gps_driver::InsstdevParser::ParseBinary(const novatel_gps_driver::BinaryMessage& bin_msg) throw(ParseException)
00048 {
00049   if (bin_msg.data_.size() != BINARY_LENGTH)
00050   {
00051     std::stringstream error;
00052     error << "Unexpected INSSTDEV message size: " << bin_msg.data_.size();
00053     throw ParseException(error.str());
00054   }
00055   novatel_gps_msgs::InsstdevPtr ros_msg = boost::make_shared<novatel_gps_msgs::Insstdev>();
00056   HeaderParser h_parser;
00057   ros_msg->novatel_msg_header = h_parser.ParseBinary(bin_msg);
00058   ros_msg->novatel_msg_header.message_name = GetMessageName();
00059   ros_msg->latitude_dev = ParseFloat(&bin_msg.data_[0]);
00060   ros_msg->latitude_dev = ParseFloat(&bin_msg.data_[4]);
00061   ros_msg->height_dev = ParseFloat(&bin_msg.data_[8]);
00062   ros_msg->north_velocity_dev = ParseFloat(&bin_msg.data_[12]);
00063   ros_msg->east_velocity_dev = ParseFloat(&bin_msg.data_[16]);
00064   ros_msg->up_velocity_dev = ParseFloat(&bin_msg.data_[20]);
00065   ros_msg->roll_dev = ParseFloat(&bin_msg.data_[24]);
00066   ros_msg->pitch_dev = ParseFloat(&bin_msg.data_[28]);
00067   ros_msg->azimuth_dev = ParseFloat(&bin_msg.data_[32]);
00068   uint32_t status = ParseUInt32(&bin_msg.data_[36]);
00069   GetExtendedSolutionStatusMessage(status, ros_msg->extended_solution_status);
00070   ros_msg->time_since_update = ParseUInt16(&bin_msg.data_[40]);
00071 
00072   return ros_msg;
00073 }
00074 
00075 novatel_gps_msgs::InsstdevPtr
00076 novatel_gps_driver::InsstdevParser::ParseAscii(const novatel_gps_driver::NovatelSentence& sentence) throw(ParseException)
00077 {
00078   if (sentence.body.size() != ASCII_FIELDS)
00079   {
00080     std::stringstream error;
00081     error << "Unexpected number of fields in INSSTDEV log: " << sentence.body.size();
00082     throw ParseException(error.str());
00083   }
00084   novatel_gps_msgs::InsstdevPtr msg = boost::make_shared<novatel_gps_msgs::Insstdev>();
00085   HeaderParser h_parser;
00086   msg->novatel_msg_header = h_parser.ParseAscii(sentence);
00087 
00088   bool valid = true;
00089 
00090   valid &= ParseFloat(sentence.body[0], msg->latitude_dev);
00091   valid &= ParseFloat(sentence.body[1], msg->longitude_dev);
00092   valid &= ParseFloat(sentence.body[2], msg->height_dev);
00093   valid &= ParseFloat(sentence.body[3], msg->north_velocity_dev);
00094   valid &= ParseFloat(sentence.body[4], msg->east_velocity_dev);
00095   valid &= ParseFloat(sentence.body[5], msg->up_velocity_dev);
00096   valid &= ParseFloat(sentence.body[6], msg->roll_dev);
00097   valid &= ParseFloat(sentence.body[7], msg->pitch_dev);
00098   valid &= ParseFloat(sentence.body[8], msg->azimuth_dev);
00099   uint32_t status;
00100   valid &= ParseUInt32(sentence.body[9], status);
00101   GetExtendedSolutionStatusMessage(status, msg->extended_solution_status);
00102 
00103   if (!valid)
00104   {
00105     throw ParseException("Error parsing INSSTDEV log.");
00106   }
00107 
00108   return msg;
00109 }


novatel_gps_driver
Author(s):
autogenerated on Wed Jul 3 2019 19:40:37