@@ -51,6 +51,10 @@ using namespace std::literals::string_literals;
5151namespace system_modes
5252{
5353
54+ static const bool MONITOR_DEFAULT_VERBOSITY = false ;
55+ static const bool MONITOR_DEFAULT_DEBUG = false ;
56+ static const unsigned int MONITOR_DEFAULT_RATE_MS = 1000 ;
57+
5458static const unsigned int MONITOR_WIDTH_PART = 25 ;
5559static const unsigned int MONITOR_WIDTH_STATE = 30 ;
5660static const unsigned int MONITOR_WIDTH_MODE = 30 ;
@@ -70,27 +74,29 @@ static const string MONITOR_TEXT_WARN = "\033[21;"s + to_string(MONITOR_TEXT_WAR
7074static const string MONITOR_SEPARATOR = MONITOR_TEXT_PLAIN + " | " ;
7175static const string MONITOR_SEPARATOR_BOLD = MONITOR_TEXT_BOLD + " | " ;
7276
73- ModeMonitor::ModeMonitor (
74- const string & model_path,
75- unsigned int rate = 1000 ,
76- bool verbose = false ,
77- bool clear = true )
77+ ModeMonitor::ModeMonitor ()
7878: Node(" __mode_monitor" ),
79- mode_inference_ (),
80- model_path_(model_path),
81- rate_(rate),
82- clear_screen_(clear),
83- verbose_(verbose)
79+ mode_inference_ ()
8480{
85- RCLCPP_DEBUG (get_logger (), " Constructed mode monitor" );
86-
87- declare_parameter (" modelfile" , rclcpp::ParameterValue (std::string (" " )));
81+ declare_parameter (
82+ " modelfile" ,
83+ rclcpp::ParameterValue (std::string (" " )));
84+ declare_parameter (
85+ " rate" ,
86+ rclcpp::ParameterValue (static_cast <int >(MONITOR_DEFAULT_RATE_MS )));
87+ declare_parameter (
88+ " debug" ,
89+ rclcpp::ParameterValue (static_cast <bool >(MONITOR_DEFAULT_DEBUG )));
90+ declare_parameter (
91+ " verbose" ,
92+ rclcpp::ParameterValue (static_cast <bool >(MONITOR_DEFAULT_VERBOSITY )));
93+
94+ rate_ = get_parameter (" rate" ).as_int ();
95+ clear_screen_ = !get_parameter (" debug" ).as_bool ();
96+ verbose_ = get_parameter (" verbose" ).as_bool ();
97+ model_path_ = get_parameter (" modelfile" ).as_string ();
8898 if (model_path_.empty ()) {
89- rclcpp::Parameter parameter = get_parameter (" modelfile" );
90- model_path_ = parameter.get_value <rclcpp::ParameterType::PARAMETER_STRING >();
91- if (model_path_.empty ()) {
92- throw std::invalid_argument (" Need path to model file." );
93- }
99+ throw std::invalid_argument (" Need path to model file." );
94100 }
95101 mode_inference_ = std::make_shared<ModeInference>(model_path_);
96102
0 commit comments