27#ifndef GOBY_MOOS_GOBY_MOOS_APP_H
28#define GOBY_MOOS_GOBY_MOOS_APP_H
44#include <MOOS/libMOOS/App/MOOSApp.h>
45#include <MOOS/libMOOS/Comms/CommsTypes.h>
46#include <MOOS/libMOOS/Comms/MOOSMsg.h>
47#include <MOOS/libMOOS/Utils/MOOSFileReader.h>
48#include <MOOS/libMOOS/Utils/MOOSUtilityFunctions.h>
49#include <boost/algorithm/string/erase.hpp>
50#include <boost/algorithm/string/find.hpp>
51#include <boost/algorithm/string/predicate.hpp>
52#include <boost/algorithm/string/replace.hpp>
53#include <boost/algorithm/string/trim.hpp>
54#include <boost/bind/bind.hpp>
55#include <boost/date_time/posix_time/posix_time_config.hpp>
56#include <boost/date_time/posix_time/posix_time_types.hpp>
57#include <boost/date_time/posix_time/time_formatters.hpp>
58#include <boost/filesystem.hpp>
59#include <boost/function.hpp>
60#include <boost/lexical_cast/bad_lexical_cast.hpp>
61#include <boost/program_options/options_description.hpp>
62#include <boost/program_options/parsers.hpp>
63#include <boost/program_options/positional_options.hpp>
64#include <boost/program_options/value_semantic.hpp>
65#include <boost/program_options/variables_map.hpp>
66#include <boost/range/iterator_range_core.hpp>
67#include <boost/signals2/signal.hpp>
68#include <boost/units/quantity.hpp>
70#include <google/protobuf/descriptor.h>
71#include <google/protobuf/descriptor.pb.h>
73#include <google/protobuf/text_format.h>
99template <
typename App>
int run(
int argc,
char* argv[]);
101template <
typename ProtobufMessage>
103 boost::function<
void(
const ProtobufMessage&
msg)> handler)
105 ProtobufMessage pb_msg;
118 bool OnNewMail(MOOSMSG_LIST& )
override {
return true; }
128 template <
typename ProtobufConfig>
130 : start_time_(MOOSTime()),
131 configuration_read_(false),
132 cout_cleared_(false),
136 dynamic_moos_vars_enabled_(true)
140 read_configuration(cfg);
143 common_cfg_ = cfg->common();
144 configuration_read_ =
true;
146 process_configuration();
153 template <
typename ProtobufMessage>
156 std::string serialized;
160 msg.GetDescriptor()->full_name());
166 if (connected_ && started_up_)
167 MOOSAppType::m_Comms.Post(
msg);
169 msg_buffer_.push_back(
msg);
172 void publish(
const std::string& key,
const std::string& value)
174 CMOOSMsg
msg(MOOS_NOTIFY, key, value);
178 void publish(
const std::string& key,
double value)
180 CMOOSMsg
msg(MOOS_NOTIFY, key, value);
188 double blackout = 0);
190 template <
typename V,
typename A1>
191 void subscribe(
const std::string& var,
void (V::*mem_func)(A1), V* obj, double blackout = 0)
193 subscribe(var, boost::bind(mem_func, obj, boost::placeholders::_1), blackout);
197 void subscribe(
const std::string& var_pattern,
const std::string& app_pattern,
200 template <
typename V,
typename A1>
201 void subscribe(
const std::string& var_pattern,
const std::string& app_pattern,
202 void (V::*mem_func)(A1), V* obj, double blackout = 0)
204 subscribe(var_pattern, app_pattern, boost::bind(mem_func, obj, boost::placeholders::_1),
208 template <
typename V,
typename ProtobufMessage>
209 void subscribe_pb(
const std::string& var,
void (V::*mem_func)(const ProtobufMessage&), V* obj,
212 subscribe_pb<ProtobufMessage>(var, boost::bind(mem_func, obj, boost::placeholders::_1),
216 template <
typename ProtobufMessage>
218 boost::function<
void(
const ProtobufMessage&
msg)> handler,
222 boost::bind(&goby::moos::protobuf_inbox<ProtobufMessage>, boost::placeholders::_1,
229 int now = (goby::time::SystemClock::now<goby::time::SITime>() / boost::units::si::seconds) /
231 now *= period_seconds;
233 SynchronousLoop new_loop;
234 new_loop.unix_next = now + period_seconds;
235 new_loop.period_seconds = period_seconds;
236 new_loop.handler = handler;
237 synchronous_loops_.push_back(new_loop);
240 template <
typename V>
void register_timer(
int period_seconds,
void (V::*mem_func)(), V* obj)
245 template <
typename App>
friend int ::goby::moos::run(
int argc,
char* argv[]);
255 std::pair<std::string, goby::moos::protobuf::TranslatorEntry::ParserSerializerTechnique>
258 std::string protobuf_type;
260 if (!type_and_technique.empty())
262 std::string::size_type colon_pos = type_and_technique.find(
':');
264 if (colon_pos != std::string::npos)
266 protobuf_type = type_and_technique.substr(0, colon_pos);
267 std::string str_technique = type_and_technique.substr(colon_pos + 1);
270 str_technique, &technique))
271 throw(std::runtime_error(
"Invalid technique string"));
275 throw std::runtime_error(
"Missing colon (:)");
277 return std::make_pair(protobuf_type, technique);
281 throw std::runtime_error(
"Empty technique string");
287 bool Iterate()
override;
288 bool OnStartUp()
override;
289 bool OnConnectToServer()
override;
290 bool OnDisconnectFromServer()
override;
291 bool OnNewMail(MOOSMSG_LIST& NewMail)
override;
292 void try_subscribing();
293 void do_subscriptions();
298 void process_configuration();
305 bool configuration_read_;
313 std::map<std::string, std::shared_ptr<boost::signals2::signal<void(
const CMOOSMsg&
msg)>>>
316 std::map<std::pair<std::string, std::string>,
317 std::shared_ptr<boost::signals2::signal<void(
const CMOOSMsg&
msg)>>>
318 wildcard_mail_handlers_;
325 std::deque<CMOOSMsg> msg_buffer_;
328 std::deque<std::pair<std::string, double>> pending_subscriptions_;
329 std::deque<std::pair<std::string, double>> existing_subscriptions_;
332 std::deque<std::pair<std::pair<std::string, std::string>,
double>>
333 wildcard_pending_subscriptions_;
334 std::deque<std::pair<std::pair<std::string, std::string>,
double>>
335 wildcard_existing_subscriptions_;
337 struct SynchronousLoop
341 boost::function<void()> handler;
344 std::vector<SynchronousLoop> synchronous_loops_;
346 protobuf::GobyMOOSAppConfig common_cfg_;
350 bool dynamic_moos_vars_enabled_;
354 static std::string mission_file_;
355 static std::string application_name_;
361 template <
typename ProtobufConfig>
369template <
class MOOSAppType>
372template <
class MOOSAppType>
380 MOOSAppType::Iterate();
382 if (!configuration_read_)
390 cout_cleared_ =
true;
393 while (!msg_buffer_.empty() && (connected_ && started_up_))
396 goby::glog <<
"writing from buffer: " << msg_buffer_.front().GetKey() <<
": "
397 << msg_buffer_.front().GetAsString() << std::endl;
399 MOOSAppType::m_Comms.Post(msg_buffer_.front());
400 msg_buffer_.pop_front();
405 if (synchronous_loops_.size())
407 double now = goby::time::SystemClock::now<goby::time::SITime>() / boost::units::si::seconds;
408 for (
typename std::vector<SynchronousLoop>::iterator it = synchronous_loops_.begin(),
409 end = synchronous_loops_.end();
412 SynchronousLoop& loop = *it;
413 if (loop.unix_next <= now)
416 loop.unix_next += loop.period_seconds;
419 if (loop.unix_next < now)
420 loop.unix_next = now + loop.period_seconds;
424 if (loop.unix_next > (now + 2 * loop.period_seconds))
425 loop.unix_next = now + loop.period_seconds;
432template <
class MOOSAppType>
436 MOOSAppType::OnNewMail(NewMail);
438 for (
const auto& msg : NewMail)
441 goby::glog <<
"Received mail: " <<
msg.GetKey() <<
", time: " << std::setprecision(15)
442 <<
msg.GetTime() << std::endl;
446 if (dynamic_moos_vars_enabled_)
447 dynamic_vars().update_moos_vars(msg);
449 if (
msg.GetTime() < start_time_ && ignore_stale_)
453 <<
" from before we started (dynamics still updated)" << std::endl;
455 else if (mail_handlers_.count(
msg.GetKey()))
456 (*mail_handlers_[
msg.GetKey()])(msg);
458 for (
auto& wildcard_mail_handler : wildcard_mail_handlers_)
460 if (MOOSWildCmp(wildcard_mail_handler.first.first,
msg.GetKey()) &&
461 MOOSWildCmp(wildcard_mail_handler.first.second,
msg.GetSource()))
462 (*(wildcard_mail_handler.second))(
msg);
469template <
class MOOSAppType>
472 std::cout << MOOSAppType::m_MissionReader.GetAppName() <<
", disconnected from server."
475 pending_subscriptions_.insert(pending_subscriptions_.end(), existing_subscriptions_.begin(),
476 existing_subscriptions_.end());
477 existing_subscriptions_.clear();
478 wildcard_pending_subscriptions_.insert(wildcard_pending_subscriptions_.end(),
479 wildcard_existing_subscriptions_.begin(),
480 wildcard_existing_subscriptions_.end());
481 wildcard_existing_subscriptions_.clear();
487 std::cout << MOOSAppType::m_MissionReader.GetAppName() <<
", connected to server." << std::endl;
491 for (
const auto& ini : common_cfg_.initializer())
493 if (ini.has_global_cfg_var())
496 if (MOOSAppType::m_MissionReader.GetValue(ini.global_cfg_var(), result))
498 if (ini.type() == protobuf::GobyMOOSAppConfig::Initializer::INI_DOUBLE)
499 publish(ini.moos_var(), goby::util::as<double>(result));
500 else if (ini.type() == protobuf::GobyMOOSAppConfig::Initializer::INI_STRING)
501 publish(ini.moos_var(), ini.trim() ? boost::trim_copy(result) : result);
506 if (ini.type() == protobuf::GobyMOOSAppConfig::Initializer::INI_DOUBLE)
507 publish(ini.moos_var(), ini.dval());
508 else if (ini.type() == protobuf::GobyMOOSAppConfig::Initializer::INI_STRING)
509 publish(ini.moos_var(), ini.trim() ? boost::trim_copy(ini.sval()) : ini.sval());
518 MOOSAppType::OnStartUp();
520 std::cout << MOOSAppType::m_MissionReader.GetAppName() <<
", starting ..." << std::endl;
521 CMOOSApp::SetCommsFreq(common_cfg_.comm_tick());
522 CMOOSApp::SetAppFreq(common_cfg_.app_tick());
528template <
class MOOSAppType>
534 goby::glog <<
"subscribing for MOOS variable: " << var <<
" @ " << blackout << std::endl;
536 pending_subscriptions_.emplace_back(var, blackout);
539 if (!mail_handlers_[var])
540 mail_handlers_[var].reset(
new boost::signals2::signal<
void(
const CMOOSMsg&
msg)>);
543 mail_handlers_[var]->connect(handler);
546template <
class MOOSAppType>
548 const std::string& app_pattern,
553 goby::glog <<
"wildcard subscribing for MOOS variable pattern: " << var_pattern
554 <<
", app pattern: " << app_pattern <<
" @ " << blackout << std::endl;
556 std::pair<std::string, std::string> key = std::make_pair(var_pattern, app_pattern);
557 wildcard_pending_subscriptions_.emplace_back(key, blackout);
560 if (!wildcard_mail_handlers_.count(key))
561 wildcard_mail_handlers_.insert(std::make_pair(
562 key, std::make_shared<boost::signals2::signal<
void(
const CMOOSMsg&
msg)>>()));
565 wildcard_mail_handlers_[key]->connect(handler);
570 if (connected_ && started_up_)
576 MOOSAppType::RegisterVariables();
578 while (!pending_subscriptions_.empty())
581 if (MOOSAppType::m_Comms.Register(pending_subscriptions_.front().first,
582 pending_subscriptions_.front().second))
585 goby::glog <<
"subscribed for: " << pending_subscriptions_.front().first
591 goby::glog <<
"failed to subscribe for: " << pending_subscriptions_.front().first
594 existing_subscriptions_.push_back(pending_subscriptions_.front());
595 pending_subscriptions_.pop_front();
598 while (!wildcard_pending_subscriptions_.empty())
601 if (MOOSAppType::m_Comms.Register(wildcard_pending_subscriptions_.front().first.first,
602 wildcard_pending_subscriptions_.front().first.second,
603 wildcard_pending_subscriptions_.front().second))
607 << wildcard_pending_subscriptions_.front().first.first <<
":"
608 << wildcard_pending_subscriptions_.front().first.second << std::endl;
614 << wildcard_pending_subscriptions_.front().first.first <<
":"
615 << wildcard_pending_subscriptions_.front().first.second << std::endl;
618 wildcard_existing_subscriptions_.push_back(wildcard_pending_subscriptions_.front());
619 wildcard_pending_subscriptions_.pop_front();
623template <
class MOOSAppType>
628 const google::protobuf::Descriptor* desc =
msg->GetDescriptor();
631 for (
int i = 0, n = desc->field_count(); i < n; ++i)
633 const google::protobuf::FieldDescriptor* field_desc = desc->field(i);
636 if (field_desc->is_repeated() || field_desc->containing_oneof())
639 std::string moos_global = field_desc->options().GetExtension(
goby::field).moos_global();
641 switch (field_desc->cpp_type())
643 case google::protobuf::FieldDescriptor::CPPTYPE_MESSAGE:
645 bool message_was_empty = !refl->
HasField(*msg, field_desc);
647 fetch_moos_globals(refl->
MutableMessage(msg, field_desc), moos_file_reader);
648 if (set_globals == 0 && message_was_empty)
654 case google::protobuf::FieldDescriptor::CPPTYPE_INT32:
657 if (moos_file_reader.GetValue(moos_global, result))
659 refl->
SetInt32(msg, field_desc, result);
666 case google::protobuf::FieldDescriptor::CPPTYPE_INT64:
669 if (moos_file_reader.GetValue(moos_global, result))
671 refl->
SetInt64(msg, field_desc, result);
677 case google::protobuf::FieldDescriptor::CPPTYPE_UINT32:
680 if (moos_file_reader.GetValue(moos_global, result))
682 refl->
SetUInt32(msg, field_desc, result);
689 case google::protobuf::FieldDescriptor::CPPTYPE_UINT64:
692 if (moos_file_reader.GetValue(moos_global, result))
694 refl->
SetUInt64(msg, field_desc, result);
700 case google::protobuf::FieldDescriptor::CPPTYPE_BOOL:
706 RESULT_UNSPECIFIED = -1
709 Result result = RESULT_UNSPECIFIED;
712 if (moos_file_reader.GetValue(moos_global, svalue))
714 if (MOOSStrCmp(svalue,
"TRUE"))
715 result = RESULT_TRUE;
716 else if (MOOSStrCmp(svalue,
"FALSE"))
717 result = RESULT_FALSE;
718 else if (MOOSIsNumeric(svalue))
719 result = atof(svalue.c_str()) > 0 ? RESULT_TRUE : RESULT_FALSE;
721 if (result != RESULT_UNSPECIFIED)
723 refl->
SetBool(msg, field_desc, result);
729 case google::protobuf::FieldDescriptor::CPPTYPE_STRING:
732 if (moos_file_reader.GetValue(moos_global, result))
734 refl->
SetString(msg, field_desc, result);
741 case google::protobuf::FieldDescriptor::CPPTYPE_FLOAT:
744 if (moos_file_reader.GetValue(moos_global, result))
746 refl->
SetFloat(msg, field_desc, result);
753 case google::protobuf::FieldDescriptor::CPPTYPE_DOUBLE:
756 if (moos_file_reader.GetValue(moos_global, result))
758 refl->
SetDouble(msg, field_desc, result);
764 case google::protobuf::FieldDescriptor::CPPTYPE_ENUM:
767 if (moos_file_reader.GetValue(moos_global, result))
769 const google::protobuf::EnumValueDescriptor* enum_desc =
770 refl->
GetEnum(*msg, field_desc)->type()->FindValueByName(result);
772 throw(std::runtime_error(std::string(
"invalid enumeration " + result +
773 " for field " + field_desc->name())));
775 refl->
SetEnum(msg, field_desc, enum_desc);
785template <
class MOOSAppType>
789 boost::filesystem::path launch_path(argv_[0]);
791#if BOOST_FILESYSTEM_VERSION == 3
792 std::string binary_name = launch_path.filename().string();
794 std::string binary_name = launch_path.filename();
796 application_name_ = binary_name;
802 boost::program_options::options_description od_all;
803 boost::program_options::variables_map var_map, po_env_var_map;
806 boost::program_options::options_description od_cli_only(
807 "Options given on command line only");
808 od_cli_only.add_options()(
"help,h",
"writes this help message")(
809 "moos_file,c", boost::program_options::value<std::string>(&mission_file_),
810 "path to .moos file")(
"moos_name,a",
811 boost::program_options::value<std::string>(&application_name_),
812 "name to register with MOOS")(
813 "example_config,e",
"writes an example .moos ProcessConfig block")(
814 "version,V",
"writes the current version");
817 boost::program_options::options_description>
820 std::string od_pb_always_desc =
821 "Options typically given in the .moos file, but may be specified on the command line";
822 std::string od_pb_never_desc =
"Hidden options";
823 std::string od_pb_advanced_desc =
"Advanced options";
824 std::string od_pb_developer_desc =
"Developer options";
827 boost::program_options::options_description(od_pb_always_desc.c_str())));
828 od_map.insert(std::make_pair(
830 boost::program_options::options_description(od_pb_advanced_desc.c_str())));
831 od_map.insert(std::make_pair(
833 boost::program_options::options_description(od_pb_developer_desc.c_str())));
836 boost::program_options::options_description(od_pb_never_desc.c_str())));
838 std::map<std::string, std::string> environmental_var_map;
840 environmental_var_map);
841 std::vector<goby::middleware::ConfigReader::PositionalOption> positional_options;
845 for (
const auto& od_p : od_map) od_all.add(od_p.second);
846 od_all.add(od_cli_only);
848 boost::program_options::positional_options_description p;
849 p.add(
"moos_file", 1);
850 p.add(
"moos_name", 1);
851 for (
const auto& po : positional_options) { p.add(po.name.c_str(), po.position_max_count); }
853 boost::program_options::store(boost::program_options::command_line_parser(argc_, argv_)
859 if (!environmental_var_map.empty())
861 boost::program_options::store(
862 boost::program_options::parse_environment(
864 [&environmental_var_map](
const std::string& i_env_var) -> std::string {
865 return environmental_var_map.count(i_env_var)
866 ? environmental_var_map.at(i_env_var)
872 boost::program_options::notify(var_map);
873 boost::program_options::notify(po_env_var_map);
875 if (var_map.count(
"help"))
877 std::cerr <<
"Usage: " << binary_name <<
" [options] moos_file [moos_name]"
881 std::cerr << od_cli_only <<
"\n";
884 else if (var_map.count(
"example_config"))
886 std::cout <<
"ProcessConfig = " << application_name_ <<
"\n{";
888 std::cout <<
"}" << std::endl;
891 else if (var_map.count(
"version"))
900 std::string protobuf_text;
902 fin.open(mission_file_.c_str());
906 bool in_process_config =
false;
907 while (getline(fin, line))
909 std::string no_blanks_line = boost::algorithm::erase_all_copy(line,
" ");
910 if (boost::algorithm::iequals(no_blanks_line,
"PROCESSCONFIG=" + application_name_))
912 in_process_config =
true;
914 else if (in_process_config &&
915 !boost::algorithm::ifind_first(line,
"PROCESSCONFIG").empty())
920 if (in_process_config)
921 protobuf_text += line +
"\n";
924 if (!in_process_config)
927 goby::glog <<
"no ProcessConfig block for " << application_name_ << std::endl;
931 protobuf_text.erase(0, protobuf_text.find_first_of(
'{') + 1);
934 protobuf_text.erase(protobuf_text.find_last_of(
'}'));
937 boost::algorithm::replace_all(protobuf_text,
"//",
"#");
939 google::protobuf::TextFormat::Parser parser;
940 goby::util::FlexOStreamErrorCollector error_collector(protobuf_text);
941 parser.RecordErrorsTo(&error_collector);
942 parser.AllowPartialMessage(
true);
943 parser.ParseFromString(protobuf_text, cfg);
945 if (error_collector.has_errors() || error_collector.has_warnings())
948 goby::glog <<
"fatal configuration errors (see above)" << std::endl;
954 << mission_file_ << std::endl;
959 CMOOSFileReader moos_file_reader;
960 moos_file_reader.SetFile(mission_file_);
961 fetch_moos_globals(cfg, moos_file_reader);
964 for (
const auto& p : po_env_var_map)
967 if (!p.second.defaulted())
973 for (
const auto& p : var_map)
975 if (!p.second.defaulted())
983 std::vector<std::string> errors;
986 std::stringstream err_msg;
987 err_msg <<
"Configuration is missing required parameters: \n";
988 for (
const std::string& s : errors)
991 err_msg <<
"Make sure you specified a proper .moos file";
998 std::cerr << od_all <<
"\n";
999 std::cerr <<
"Problem parsing command-line configuration: \n" <<
e.what() <<
"\n";
1005template <
class MOOSAppType>
1012 if (common_cfg_.show_gui())
1017 if (common_cfg_.log())
1019 if (!common_cfg_.has_log_path())
1022 goby::glog <<
"logging all terminal output to default directory ("
1023 << common_cfg_.log_path() <<
")."
1024 <<
"set log_path for another path " << std::endl;
1027 if (!common_cfg_.log_path().empty())
1029 using namespace boost::posix_time;
1030 std::string file_name_base = boost::replace_all_copy(application_name_,
"/",
"_") +
1031 "_" + common_cfg_.community();
1033 std::string file_name =
1035 (common_cfg_.log_omit_file_timestamp()
1037 : std::string(
"_") + to_iso_string(second_clock::universal_time())) +
1041 goby::glog <<
"logging output to file: " << file_name << std::endl;
1043 fout_.open(std::string(common_cfg_.log_path() +
"/" + file_name).c_str());
1045 if (!common_cfg_.log_omit_latest_symlink())
1047 std::string file_symlink = file_name_base +
"_latest.txt";
1049 remove(std::string(common_cfg_.log_path() +
"/" + file_symlink).c_str());
1050 symlink(file_name.c_str(),
1051 std::string(common_cfg_.log_path() +
"/" + file_symlink).c_str());
1055 if (!fout_.is_open())
1057 fout_.open(std::string(
"./" + file_name).c_str());
1060 <<
"logging to current directory because given directory is unwritable!"
1064 if (!fout_.is_open())
1067 goby::glog <<
"cannot write to current directory, so cannot log." << std::endl;
1076 if (common_cfg_.time_warp_multiplier() != 1)
1081 std::chrono::system_clock::time_point(std::chrono::seconds(0));
1082 start_time_ *= common_cfg_.time_warp_multiplier();
1095 App* app = App::get_instance();
1096 app->Run(App::application_name_.c_str(), App::mission_file_.c_str());
1103 catch (std::exception& e)
static constexpr ConfigAction NEVER
static constexpr ConfigAction DEVELOPER
GobyFieldOptions_ConfigurationOptions_ConfigAction ConfigAction
static constexpr ConfigAction ADVANCED
static constexpr ConfigAction ALWAYS
indicates a problem with the runtime command line or .cfg file configuration (or –help was given)
static void get_protobuf_program_options(std::map< goby::GobyFieldOptions::ConfigurationOptions::ConfigAction, boost::program_options::options_description > &od_map, const google::protobuf::Descriptor *desc, std::map< std::string, std::string > &environmental_var_map)
static void get_example_cfg_file(google::protobuf::Message *message, std::ostream *human_desc_ss, const std::string &indent="", goby::GobyFieldOptions::ConfigurationOptions::ConfigAction action=goby::GobyFieldOptions::ConfigurationOptions::ALWAYS)
static void get_positional_options(const google::protobuf::Descriptor *desc, std::vector< PositionalOption > &positional_options)
static void set_protobuf_program_option(const boost::program_options::variables_map &vm, google::protobuf::Message &message, const std::string &full_name, const boost::program_options::variable_value &value, bool overwrite_if_exists)
void publish(const std::string &key, double value)
void subscribe(const std::string &var, void(V::*mem_func)(A1), V *obj, double blackout=0)
boost::function< void(const CMOOSMsg &msg)> InboxFunc
void publish(const std::string &key, const std::string &value)
void subscribe_pb(const std::string &var, boost::function< void(const ProtobufMessage &msg)> handler, double blackout=0)
void register_timer(int period_seconds, void(V::*mem_func)(), V *obj)
GobyMOOSAppSelector(ProtobufConfig *cfg)
void subscribe(const std::string &var_pattern, const std::string &app_pattern, void(V::*mem_func)(A1), V *obj, double blackout=0)
void subscribe_pb(const std::string &var, void(V::*mem_func)(const ProtobufMessage &), V *obj, double blackout=0)
void publish(CMOOSMsg &msg)
void subscribe(const std::string &var, const InboxFunc &handler=InboxFunc(), double blackout=0)
goby::moos::DynamicMOOSVars & dynamic_vars()
void set_dynamic_moos_vars_enabled(bool b)
std::pair< std::string, goby::moos::protobuf::TranslatorEntry::ParserSerializerTechnique > parse_type_technique(const std::string &type_and_technique)
~GobyMOOSAppSelector() override=default
bool dynamic_moos_vars_enabled()
void set_ignore_stale(bool b)
void publish_pb(const std::string &key, const ProtobufMessage &msg)
void register_timer(int period_seconds, const boost::function< void()> &handler)
double start_time() const
GobyMOOSApp(ProtobufConfig *cfg)
bool OnStartUp() override
bool OnNewMail(MOOSMSG_LIST &) override
bool OnConnectToServer() override
static CMOOSMsg make_moos_msg(const std::string &var, const std::string &str, bool is_binary, goby::moos::protobuf::TranslatorEntry::ParserSerializerTechnique technique, const std::string &pb_name)
static bool ParserSerializerTechnique_Parse(::PROTOBUF_NAMESPACE_ID::ConstStringParam name, ParserSerializerTechnique *value)
bool is(goby::util::logger::Verbosity verbosity)
void set_name(const std::string &s)
Set the name of the application that the logger is serving.
void add_stream(logger::Verbosity verbosity=logger::VERBOSE, std::ostream *os=nullptr)
Attach a stream object (e.g. std::cout, std::ofstream, ...) to the logger with desired verbosity.
static constexpr Verbosity VERBOSE
const Descriptor * GetDescriptor() const
void FindInitializationErrors(std::vector< std::string > *errors) const
bool IsInitialized() const override
void SetUInt32(Message *message, const FieldDescriptor *field, uint32_t value) const
void ClearField(Message *message, const FieldDescriptor *field) const
Message * MutableMessage(Message *message, const FieldDescriptor *field, MessageFactory *factory=nullptr) const
void SetInt64(Message *message, const FieldDescriptor *field, int64_t value) const
bool HasField(const Message &message, const FieldDescriptor *field) const
void SetInt32(Message *message, const FieldDescriptor *field, int32_t value) const
void SetDouble(Message *message, const FieldDescriptor *field, double value) const
void SetFloat(Message *message, const FieldDescriptor *field, float value) const
const EnumValueDescriptor * GetEnum(const Message &message, const FieldDescriptor *field) const
void SetString(Message *message, const FieldDescriptor *field, std::string value) const
void SetUInt64(Message *message, const FieldDescriptor *field, uint64_t value) const
void SetEnum(Message *message, const FieldDescriptor *field, const EnumValueDescriptor *value) const
void SetBool(Message *message, const FieldDescriptor *field, bool value) const
Helpers for MOOS applications for serializing and parsed Google Protocol buffers messages.
void parse_for_moos(const std::string &in, google::protobuf::Message *msg)
Parses the string in to Google Protocol Buffers message msg. All errors are written to the goby::util...
bool serialize_for_moos(std::string *out, const google::protobuf::Message &msg)
Converts the Google Protocol Buffers message msg into a suitable (human readable) string out for send...
TranslatorEntry_ParserSerializerTechnique
void write_version_message()
void protobuf_inbox(const CMOOSMsg &msg, boost::function< void(const ProtobufMessage &msg)> handler)
void set_moos_technique(const goby::moos::protobuf::GobyMOOSAppConfig &cfg)
goby::moos::protobuf::TranslatorEntry::ParserSerializerTechnique moos_technique
int run(int argc, char *argv[])
const std::string esc_red
const std::string esc_nocolor
The global namespace for the Goby project.
extern ::PROTOBUF_NAMESPACE_ID::internal::ExtensionIdentifier< ::PROTOBUF_NAMESPACE_ID::FieldOptions, ::PROTOBUF_NAMESPACE_ID::internal::MessageTypeTraits< ::goby::GobyFieldOptions >, 11, false > field
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.
int run(const goby::middleware::ConfiguratorInterface< typename App::ConfigType > &cfgtor)
Run a Goby application using the provided Configurator.
static bool using_sim_time
Enables simulation time if true (if false, none of the remaining parameters are used)
static std::chrono::system_clock::time_point reference_time
Reference time when calculating SystemClock::now(). If this is unset, the default is 1 January of the...
static int warp_factor
Warp factor to speed up (or slow time) the time values returned by SteadyClock::now() and SystemClock...