Goby3 3.2.3
2025.05.13
Loading...
Searching...
No Matches
interface.h
Go to the documentation of this file.
1// Copyright 2013-2025:
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// Henrik Schmidt <henrik@mit.edu>
8//
9//
10// This file is part of the Goby Underwater Autonomy Project Libraries
11// ("The Goby Libraries").
12//
13// The Goby Libraries are free software: you can redistribute them and/or modify
14// them under the terms of the GNU Lesser General Public License as published by
15// the Free Software Foundation, either version 2.1 of the License, or
16// (at your option) any later version.
17//
18// The Goby Libraries are distributed in the hope that they will be useful,
19// but WITHOUT ANY WARRANTY; without even the implied warranty of
20// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21// GNU Lesser General Public License for more details.
22//
23// You should have received a copy of the GNU Lesser General Public License
24// along with Goby. If not, see <http://www.gnu.org/licenses/>.
25
26#ifndef GOBY_MIDDLEWARE_FRONTSEAT_INTERFACE_H
27#define GOBY_MIDDLEWARE_FRONTSEAT_INTERFACE_H
28
29#include <memory> // for unique_ptr
30#include <string> // for string
31
32#include <boost/signals2/signal.hpp> // for signal
33#include <boost/smart_ptr/shared_ptr.hpp> // for shared_ptr
34
35#include "goby/middleware/protobuf/frontseat.pb.h" // for InterfaceS...
37#include "goby/time/types.h" // for MicroTime
38#include "goby/util/geodesy.h" // for UTMGeodesy
39
40namespace goby
41{
42namespace apps
43{
44namespace moos
45{
46class FrontSeatLegacyTranslator;
47}
48} // namespace apps
49namespace middleware
50{
51namespace frontseat
52{
53namespace protobuf
54{
55class CTDSample;
56class NodeStatus;
57} // namespace protobuf
58
60{
61 public:
63
64 virtual ~InterfaceBase() = default;
65
66 virtual void send_command_to_frontseat(const protobuf::CommandRequest& command) = 0;
67 virtual void send_data_to_frontseat(const protobuf::InterfaceData& data) = 0;
68 virtual void send_raw_to_frontseat(const protobuf::Raw& data) = 0;
69
71 virtual bool frontseat_providing_data() const = 0;
72
74 protobuf::HelmState helm_state() const { return helm_state_; }
75 protobuf::InterfaceState state() const { return state_; }
76
77 void do_work();
78
80 {
82 s.set_state(state_);
84 s.set_helm_state(helm_state_);
85 if (last_helm_error_ != protobuf::ERROR_HELM_NONE)
86 s.set_helm_error(last_helm_error_);
87 if (last_frontseat_error_ != protobuf::ERROR_FRONTSEAT_NONE)
88 s.set_frontseat_error(last_frontseat_error_);
90 return s;
91 }
92
93 // Called at the AppTick frequency of iFrontSeat
94 // Here is where you can process incoming data
95 virtual void loop() = 0;
96
97 // Signals that iFrontseat connects to
98 // call this with data from the Frontseat
99 boost::signals2::signal<void(const protobuf::CommandResponse& data)> signal_command_response;
100 boost::signals2::signal<void(const protobuf::InterfaceData& data)> signal_data_from_frontseat;
101 boost::signals2::signal<void(const protobuf::Raw& data)> signal_raw_from_frontseat;
102 boost::signals2::signal<void(const protobuf::Raw& data)> signal_raw_to_frontseat;
103
104 const protobuf::Config& cfg() const { return cfg_; }
105
108
109 // Dynamic UTM update
111
112 friend class goby::apps::moos::FrontSeatLegacyTranslator; // to access the signal_state_change
113 private:
114 void check_error_states();
115 void check_change_state();
116
117 // Signals called by InterfaceBase directly. No need to call these
118 // from the Frontseat driver implementation
119 boost::signals2::signal<void(protobuf::InterfaceState state)> signal_state_change;
120
121 enum Direction
122 {
123 DIRECTION_TO_FRONTSEAT,
124 DIRECTION_FROM_FRONTSEAT
125 };
126
127 void glog_raw(const protobuf::Raw& data, Direction direction);
128
129 private:
130 protobuf::Config cfg_;
131 protobuf::HelmState helm_state_;
133 goby::time::MicroTime start_time_;
134 protobuf::FrontSeatError last_frontseat_error_;
135 protobuf::HelmError last_helm_error_;
136
137 std::unique_ptr<goby::util::UTMGeodesy> geodesy_;
138
139
140 std::string glog_out_group_, glog_in_group_;
141};
142} // namespace frontseat
143} // namespace middleware
144} // namespace goby
145
146#endif
protobuf::InterfaceState state() const
Definition interface.h:75
boost::signals2::signal< void(const protobuf::Raw &data)> signal_raw_to_frontseat
Definition interface.h:102
boost::signals2::signal< void(const protobuf::InterfaceData &data)> signal_data_from_frontseat
Definition interface.h:100
protobuf::HelmState helm_state() const
Definition interface.h:74
friend class goby::apps::moos::FrontSeatLegacyTranslator
Definition interface.h:112
void compute_missing(protobuf::CTDSample *ctd_sample)
virtual void send_data_to_frontseat(const protobuf::InterfaceData &data)=0
boost::signals2::signal< void(const protobuf::CommandResponse &data)> signal_command_response
Definition interface.h:99
virtual void send_raw_to_frontseat(const protobuf::Raw &data)=0
protobuf::InterfaceStatus status()
Definition interface.h:79
boost::signals2::signal< void(const protobuf::Raw &data)> signal_raw_from_frontseat
Definition interface.h:101
virtual bool frontseat_providing_data() const =0
virtual void send_command_to_frontseat(const protobuf::CommandRequest &command)=0
const protobuf::Config & cfg() const
Definition interface.h:104
void set_helm_state(protobuf::HelmState state)
Definition interface.h:73
void compute_missing(protobuf::NodeStatus *status)
void update_utm_datum(goby::util::UTMGeodesy::LatLonPoint datum)
virtual protobuf::FrontSeatState frontseat_state() const =0
void set_helm_state(::goby::middleware::frontseat::protobuf::HelmState value)
void set_state(::goby::middleware::frontseat::protobuf::InterfaceState value)
void set_frontseat_state(::goby::middleware::frontseat::protobuf::FrontSeatState value)
void set_frontseat_error(::goby::middleware::frontseat::protobuf::FrontSeatError value)
void set_helm_error(::goby::middleware::frontseat::protobuf::HelmError value)
boost::units::quantity< MicroTimeUnit, std::int64_t > MicroTime
quantity of microseconds (using int64)
Definition types.h:39
The global namespace for the Goby project.