1717#include < rclcpp/node_interfaces/node_parameters.hpp>
1818#include < rclcpp/parameter_map.hpp>
1919
20+ #include < lifecycle_msgs/msg/state.hpp>
21+
2022#include < map>
2123#include < mutex>
2224#include < vector>
2325#include < string>
2426#include < memory>
2527#include < utility>
2628
29+ using lifecycle_msgs::msg::State;
30+
2731namespace system_modes
2832{
2933
@@ -49,17 +53,22 @@ struct StateAndMode
4953 mode = newmode;
5054 }
5155
52- bool operator ! =(const StateAndMode & cmp) const
56+ bool operator = =(const StateAndMode & cmp) const
5357 {
54- return cmp.state == state && // same state
55- (cmp.mode .compare (mode) == 0 || // same mode
58+ if (cmp.state != state) {
59+ return false ;
60+ } else if (cmp.state != State::PRIMARY_STATE_ACTIVE ) {
61+ return true ;
62+ }
63+
64+ return (cmp.mode .compare (mode) == 0 || // same mode
5665 (cmp.mode .compare (DEFAULT_MODE ) == 0 && mode.empty ()) || // we consider empty and
5766 (mode.compare (DEFAULT_MODE ) == 0 && cmp.mode .empty ())); // DEFAULT_MODE the same
5867 }
5968
60- bool operator = =(const StateAndMode & cmp) const
69+ bool operator ! =(const StateAndMode & cmp) const
6170 {
62- return !(*this ! = cmp);
71+ return !(*this = = cmp);
6372 }
6473
6574 void from_string (const std::string & sam) {
@@ -73,9 +82,8 @@ struct StateAndMode
7382 }
7483 }
7584
76- std::string as_string () const
77- {
78- if (mode.empty ()) {
85+ std::string as_string () const {
86+ if (state != State::PRIMARY_STATE_ACTIVE || mode.empty ()) {
7987 return state_label_ (state);
8088 }
8189 return state_label_ (state) + " ." + mode;
0 commit comments