clocksteering.cpp
Go to the documentation of this file.
1 // *****************************************************************************
2 //
3 // Copyright (c) 2017, Southwest Research Institute® (SwRI®)
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 // * Redistributions of source code must retain the above copyright
9 // notice, this list of conditions and the following disclaimer.
10 // * 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 // * Neither the name of Southwest Research Institute® (SwRI®) nor the
14 // names of its contributors may be used to endorse or promote products
15 // derived 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 SOUTHWEST RESEARCH INSTITUTE BE LIABLE FOR ANY
21 // DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
22 // (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
23 // LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
24 // ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
26 // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 //
28 // *****************************************************************************
29 
31 #include <boost/make_shared.hpp>
32 
33 const std::string novatel_gps_driver::ClockSteeringParser::MESSAGE_NAME = "CLOCKSTEERING";
34 
36 {
37  return 0;
38 }
39 
41 {
42  return MESSAGE_NAME;
43 }
44 
45 novatel_gps_msgs::ClockSteeringPtr novatel_gps_driver::ClockSteeringParser::ParseAscii(const novatel_gps_driver::NovatelSentence& sentence) noexcept(false)
46 {
47  const size_t MIN_LENGTH = 8;
48  // Check that the message is at least as long as a a ClockSteering with no satellites
49  if (sentence.body.size() != MIN_LENGTH)
50  {
51  std::stringstream error;
52  error << "Expected ClockSteering length >= " << MIN_LENGTH
53  << ", actual length = " << sentence.body.size();
54  throw ParseException(error.str());
55  }
56  novatel_gps_msgs::ClockSteeringPtr msg = boost::make_shared<novatel_gps_msgs::ClockSteering>();
57 
58  msg->source = sentence.body[0];
59  msg->steering_state = sentence.body[1];
60 
61  if (!ParseUInt32(sentence.body[2], msg->period))
62  {
63  throw ParseException("Error parsing period in ClockSteering.");
64  }
65 
66  if (!ParseDouble(sentence.body[3], msg->pulse_width))
67  {
68  throw ParseException("Error parsing pulse_width in ClockSteering.");
69  }
70 
71  if (!ParseDouble(sentence.body[4], msg->bandwidth))
72  {
73  throw ParseException("Error parsing bandwidth in ClockSteering.");
74  }
75 
76  if (!ParseFloat(sentence.body[5], msg->slope))
77  {
78  throw ParseException("Error parsing slope in ClockSteering.");
79  }
80 
81  if (!ParseDouble(sentence.body[6], msg->offset))
82  {
83  throw ParseException("Error parsing offset in ClockSteering.");
84  }
85 
86  if (!ParseDouble(sentence.body[7], msg->drift_rate))
87  {
88  throw ParseException("Error parsing drift_rate in ClockSteering.");
89  }
90 
91  return msg;
92 }
msg
const std::string GetMessageName() const override
uint32_t GetMessageId() const override
double ParseDouble(const uint8_t *buffer)
Converts a buffer containing 8 bytes into a double.
uint32_t ParseUInt32(const uint8_t *buffer)
Converts a buffer containing 4 bytes into an unsigned 32-bit int.
float ParseFloat(const uint8_t *buffer)
Converts a buffer containing 4 bytes into a float.
static const std::string MESSAGE_NAME
Definition: clocksteering.h:47
novatel_gps_msgs::ClockSteeringPtr ParseAscii(const NovatelSentence &sentence) noexcept(false) override
Converts sentence into a ROS message pointer and returns it.


novatel_gps_driver
Author(s):
autogenerated on Thu Jul 16 2020 03:17:30