Goby3 3.2.3
2025.05.13
Loading...
Searching...
No Matches
iver_driver.h
Go to the documentation of this file.
1// Copyright 2013-2021:
2// GobySoft, LLC (2013-)
3// Massachusetts Institute of Technology (2007-2014)
4// Community contributors (see AUTHORS file)
5// File authors:
6// Toby Schneider <toby@gobysoft.org>
7//
8//
9// This file is part of the Goby Underwater Autonomy Project Libraries
10// ("The Goby Libraries").
11//
12// The Goby Libraries are free software: you can redistribute them and/or modify
13// them under the terms of the GNU Lesser General Public License as published by
14// the Free Software Foundation, either version 2.1 of the License, or
15// (at your option) any later version.
16//
17// The Goby Libraries are distributed in the hope that they will be useful,
18// but WITHOUT ANY WARRANTY; without even the implied warranty of
19// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20// GNU Lesser General Public License for more details.
21//
22// You should have received a copy of the GNU Lesser General Public License
23// along with Goby. If not, see <http://www.gnu.org/licenses/>.
24
25#ifndef GOBY_MIDDLEWARE_FRONTSEAT_IVER_IVER_DRIVER_H
26#define GOBY_MIDDLEWARE_FRONTSEAT_IVER_IVER_DRIVER_H
27
28#include <iomanip>
29#include <memory>
30#include <ostream>
31#include <string>
32
33#include <boost/units/quantity.hpp>
34#include <boost/units/systems/angle/degrees.hpp>
35#include <boost/units/systems/si/time.hpp> // for time
36#include <dccl/common.h> // for round
37
45
46namespace goby
47{
48namespace middleware
49{
50namespace frontseat
51{
52namespace protobuf
53{
54class Config;
55} // namespace protobuf
56
57class Iver : public InterfaceBase
58{
59 public:
61
62 private: // virtual methods from InterfaceBase
63 void loop() override;
64
65 void send_command_to_frontseat(const protobuf::CommandRequest& command) override;
66 void send_data_to_frontseat(const protobuf::InterfaceData& data) override;
67 void send_raw_to_frontseat(const protobuf::Raw& data) override;
68 protobuf::FrontSeatState frontseat_state() const override;
69 bool frontseat_providing_data() const override;
70
71 private: // internal non-virtual methods
72 void check_connection_state();
73 void try_receive();
74 void process_receive(const std::string& s);
75 void write(const std::string& s);
76
77 // given a time and date in "NMEA form", returns the value as seconds since the start of the epoch (1970-01-01 00:00:00Z)
78 // NMEA form for time is HHMMSS where "H" is hours, "M" is minutes, "S" is seconds or fractional seconds
79 // NMEA form for date is DDMMYY where "D" is day, "M" is month, "Y" is year
80 boost::units::quantity<boost::units::si::time> nmea_time_to_seconds(double nmea_time,
81 int nmea_date);
82
83 // given a latitude or longitude in "NMEA form" and the hemisphere character ('N', 'S', 'E' or 'W'), returns the value as decimal degrees
84 // NMEA form is DDDMM.MMMM or DDMM.MMMM where "D" is degrees, and "M" is minutes
85 boost::units::quantity<boost::units::degree::plane_angle> nmea_geo_to_degrees(double nmea_geo,
86 char hemi);
87
88 // remote helm manual shows input as tenths precision, so we will force that here
89 std::string tenths_precision_str(double d)
90 {
91 std::stringstream ss;
92 ss << std::fixed << std::setprecision(1) << dccl::round(d, 1);
93 return ss.str();
94 }
95
96 private:
97 const protobuf::IverConfig iver_config_;
99
100 std::shared_ptr<goby::util::SerialClient> ntp_serial_;
101
102 bool frontseat_providing_data_;
103 goby::time::SystemClock::time_point last_frontseat_data_time_;
104
105 protobuf::FrontSeatState frontseat_state_;
106 protobuf::IverState::IverMissionMode reported_mission_mode_;
107
108 protobuf::CommandRequest last_request_;
109
110 protobuf::NodeStatus status_;
111};
112} // namespace frontseat
113} // namespace middleware
114} // namespace goby
115
116#endif
const protobuf::Config & cfg() const
Definition interface.h:104
Iver(const protobuf::Config &cfg)
provides a basic client for line by line text based communications over a 8N1 tty (such as an RS-232 ...
The global namespace for the Goby project.
std::chrono::time_point< SystemClock > time_point