Goby3 3.2.3
2025.05.13
Loading...
Searching...
No Matches
frontseat_gateway_plugin.h
Go to the documentation of this file.
1// Copyright 2020-2021:
2// GobySoft, LLC (2013-)
3// Community contributors (see AUTHORS file)
4// File authors:
5// Toby Schneider <toby@gobysoft.org>
6//
7//
8// This file is part of the Goby Underwater Autonomy Project Libraries
9// ("The Goby Libraries").
10//
11// The Goby Libraries are free software: you can redistribute them and/or modify
12// them under the terms of the GNU Lesser General Public License as published by
13// the Free Software Foundation, either version 2.1 of the License, or
14// (at your option) any later version.
15//
16// The Goby Libraries are distributed in the hope that they will be useful,
17// but WITHOUT ANY WARRANTY; without even the implied warranty of
18// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19// GNU Lesser General Public License for more details.
20//
21// You should have received a copy of the GNU Lesser General Public License
22// along with Goby. If not, see <http://www.gnu.org/licenses/>.
23
24#ifndef GOBY_MOOS_MIDDLEWARE_FRONTSEAT_FRONTSEAT_GATEWAY_PLUGIN_H
25#define GOBY_MOOS_MIDDLEWARE_FRONTSEAT_FRONTSEAT_GATEWAY_PLUGIN_H
26
27#include <ostream> // for basic_ostream
28#include <string> // for string, bas...
29#include <vector> // for vector
30
31#include <MOOS/libMOOS/Comms/MOOSMsg.h> // for CMOOSMsg
32#include <boost/algorithm/string/predicate.hpp> // for iequals
33#include <boost/algorithm/string/trim.hpp> // for trim
34
36
37#include "goby/middleware/application/multi_thread.h" // for SimpleThread
38#include "goby/middleware/frontseat/groups.h" // for helm_state
39#include "goby/middleware/marshalling/interface.h" // for Marshalling...
40#include "goby/middleware/protobuf/frontseat.pb.h" // for HelmStateRe...
41#include "goby/middleware/protobuf/frontseat_data.pb.h" // for NodeStatus
42#include "goby/middleware/transport/interprocess.h" // for InterProces...
43#include "goby/moos/frontseat/convert.h" // for convert_and...
44#include "goby/moos/middleware/moos_plugin_translator.h" // for TranslatorB...
45#include "goby/util/debug_logger/flex_ostream.h" // for operator<<
46
47namespace goby
48{
49namespace apps
50{
51namespace moos
52{
53namespace protobuf
54{
55class GobyMOOSGatewayConfig;
56} // namespace protobuf
57} // namespace moos
58} // namespace apps
59
60namespace moos
61{
63{
64 public:
66 : goby::moos::Translator(cfg)
67 {
68 goby()
69 .interprocess()
74 glog.is_debug2() && glog << "Posting to MOOS: NAV: " << status.DebugString()
75 << std::endl;
77 });
78
79 std::vector<std::string> desired_buffer_params(
80 {"SPEED", "HEADING", "DEPTH", "PITCH", "ROLL", "Z_RATE", "ALTITUDE"});
81 for (const auto& var : desired_buffer_params) moos().add_buffer("DESIRED_" + var);
82 moos().add_trigger("DESIRED_SPEED",
83 [this](const CMOOSMsg& /*msg*/) { convert_desired_setpoints(); });
84
85 moos().add_trigger("IVPHELM_STATE", [this](const CMOOSMsg& msg) {
87 std::string sval = msg.GetString();
88 boost::trim(sval);
89 if (boost::iequals(sval, "drive"))
91 else if (boost::iequals(sval, "park"))
93 else
94 helm_state_report.set_state(
97 helm_state_report);
98 });
99 }
100
101 private:
102 void convert_desired_setpoints();
103};
104} // namespace moos
105} // namespace goby
106
107#endif
void set_state(::goby::middleware::frontseat::protobuf::HelmState value)
ThreadType< goby::apps::moos::protobuf::GobyMOOSGatewayConfig > & goby()
FrontSeatTranslation(const goby::apps::moos::protobuf::GobyMOOSGatewayConfig &cfg)
void add_buffer(const std::string &moos_var)
void add_trigger(const std::string &moos_var, const std::function< void(const CMOOSMsg &)> &func)
constexpr goby::middleware::Group helm_state
Definition groups.h:52
constexpr goby::middleware::Group node_status
Definition groups.h:37
void convert_and_publish_node_status(const goby::middleware::frontseat::protobuf::NodeStatus &status, CMOOSCommClient &moos_comms)
The global namespace for the Goby project.
extern ::PROTOBUF_NAMESPACE_ID::internal::ExtensionIdentifier< ::PROTOBUF_NAMESPACE_ID::MessageOptions, ::PROTOBUF_NAMESPACE_ID::internal::MessageTypeTraits< ::goby::GobyMessageOptions >, 11, false > msg
util::FlexOstream glog
Access the Goby logger through this object.