diff --git a/include/scrimmage/entity/Entity.h b/include/scrimmage/entity/Entity.h index af4283f1cb..48b19fdf3a 100644 --- a/include/scrimmage/entity/Entity.h +++ b/include/scrimmage/entity/Entity.h @@ -192,13 +192,10 @@ class Entity : public std::enable_shared_from_this { PubSubPtr& pubsub() { return pubsub_; } - PrintPtr& printer() { return printer_; } - const ParameterServerPtr& param_server() { return param_server_; } double radius() { return radius_; } void set_time_ptr(TimePtr t); - void set_printer(PrintPtr printer); void set_gpu_controller(GPUControllerPtr gpu_controller); GPUControllerPtr gpu_controller(); bool using_gpu_motion_model() const; @@ -245,7 +242,6 @@ class Entity : public std::enable_shared_from_this { FileSearchPtr file_search_; GPUControllerPtr gpu_controller_; PubSubPtr pubsub_; - PrintPtr printer_; GPUControllerPtr gpu_; GlobalServicePtr global_services_; ParameterServerPtr param_server_; diff --git a/include/scrimmage/entity/EntityPluginHelper.h b/include/scrimmage/entity/EntityPluginHelper.h index 41ffd13d22..dc5fbcb9c2 100644 --- a/include/scrimmage/entity/EntityPluginHelper.h +++ b/include/scrimmage/entity/EntityPluginHelper.h @@ -45,6 +45,7 @@ #include "scrimmage/autonomy/Autonomy.h" #include "scrimmage/fwd_decl.h" +#include "scrimmage/log/Logger.h" #include "scrimmage/motion/Controller.h" #include "scrimmage/parse/ConfigParse.h" #include "scrimmage/plugin_manager/PluginManager.h" @@ -82,9 +83,9 @@ boost::optional> make_autonomy( overrides, plugin_tags); if (status.status == PluginStatus::cast_failed) { - std::cout << "Failed to open autonomy plugin: " << autonomy_name << std::endl; + LOG_ERROR("Failed to open autonomy plugin: " << autonomy_name); } else if (status.status == PluginStatus::parse_failed) { - std::cout << "Parsing of plugin failed: " << autonomy_name << std::endl; + LOG_ERROR("Failed to parse autonomy plugin config: " << autonomy_name); } else if (status.status == PluginStatus::loaded) { std::shared_ptr autonomy = status.plugin; // Connect the autonomy to the first controller @@ -106,17 +107,30 @@ boost::optional> make_autonomy( param_override_func(config_parse.params()); if (debug_level > 1) { - std::cout << "--------------------------------" << std::endl; - std::cout << "Autonomy plugin params: " << autonomy_name << std::endl; - std::cout << config_parse; + LOG_INFO("--------------------------------"); + LOG_INFO("Autonomy plugin params: " << autonomy_name); + LOG_INFO(config_parse); + } + try { + autonomy->init(config_parse.params()); + } catch (const std::exception& e) { + LOG_ERROR("Autonomy plugin '" << autonomy_name << "' threw exception during init: " << e.what()); + return boost::none; + } catch (...) { + LOG_ERROR("Autonomy plugin '" << autonomy_name << "' threw unknown exception during init"); + return boost::none; } - autonomy->init(config_parse.params()); // get loop rate from plugin's params auto it_loop_rate = config_parse.params().find("loop_rate"); if (it_loop_rate != config_parse.params().end()) { - const double loop_rate = std::stod(it_loop_rate->second); - autonomy->set_loop_rate(loop_rate); + try { + const double loop_rate = std::stod(it_loop_rate->second); + autonomy->set_loop_rate(loop_rate); + } catch (const std::exception& e) { + LOG_ERROR("Autonomy plugin '" << autonomy_name << "': invalid loop_rate '" << it_loop_rate->second << "': " << e.what()); + return boost::none; + } } return boost::optional>{autonomy}; } diff --git a/include/scrimmage/entity/External.h b/include/scrimmage/entity/External.h index 869b6c0952..57f2aa6f8f 100644 --- a/include/scrimmage/entity/External.h +++ b/include/scrimmage/entity/External.h @@ -54,7 +54,6 @@ #include "scrimmage/common/Time.h" #include "scrimmage/entity/Entity.h" #include "scrimmage/log/Log.h" -#include "scrimmage/log/Print.h" #include "scrimmage/math/State.h" #include "scrimmage/motion/Controller.h" #include "scrimmage/proto/ProtoConversions.h" @@ -135,7 +134,6 @@ class External { std::shared_ptr log_; double last_t_; PubSubPtr pubsub_; - PrintPtr printer_; TimePtr time_; ParameterServerPtr param_server_; GlobalServicePtr global_services_; diff --git a/include/scrimmage/fwd_decl.h b/include/scrimmage/fwd_decl.h index 4d49a81579..c1bced7af9 100644 --- a/include/scrimmage/fwd_decl.h +++ b/include/scrimmage/fwd_decl.h @@ -83,9 +83,6 @@ using EntityPtr = std::shared_ptr; class Time; using TimePtr = std::shared_ptr