35 std::vector<Action> temp_vec;
36 for (int8_t state = packml_msgs::State::UNDEFINED; state <= packml_msgs::State::COMPLETE; state++)
41 for (int8_t light_value = Light::Value::UNDEFINED; light_value <= Light::Value::BLUE; light_value++)
48 for (int8_t button_value = Button::Value::UNDEFINED; button_value <= Button::Value::RESET; button_value++)
57 case packml_msgs::State::ABORTING:
58 case packml_msgs::State::ABORTED:
59 action.
light_vec_[Light::Value::RED].active_ =
true;
60 action.
light_vec_[Light::Value::RED].flashing_ =
true;
62 action.
light_vec_[Light::Value::BLUE].active_ =
true;
63 action.
light_vec_[Light::Value::BLUE].flashing_ =
true;
65 action.
button_vec_[Button::Value::RESET].light_.active_ =
true;
66 action.
button_vec_[Button::Value::RESET].light_.current_ = Light::Value::BLUE;
67 action.
button_vec_[Button::Value::RESET].light_.flashing_ =
true;
70 case packml_msgs::State::CLEARING:
71 action.
light_vec_[Light::Value::RED].active_ =
true;
72 action.
light_vec_[Light::Value::RED].flashing_ =
true;
74 action.
light_vec_[Light::Value::BLUE].active_ =
true;
75 action.
light_vec_[Light::Value::BLUE].flashing_ =
true;
78 case packml_msgs::State::STOPPING:
79 case packml_msgs::State::STOPPED:
80 action.
light_vec_[Light::Value::RED].active_ =
true;
81 action.
light_vec_[Light::Value::RED].flashing_ =
false;
83 action.
light_vec_[Light::Value::BLUE].active_ =
true;
84 action.
light_vec_[Light::Value::BLUE].flashing_ =
true;
87 case packml_msgs::State::RESETTING:
88 action.
light_vec_[Light::Value::BLUE].active_ =
true;
89 action.
light_vec_[Light::Value::BLUE].flashing_ =
true;
92 case packml_msgs::State::IDLE:
93 action.
light_vec_[Light::Value::GREEN].active_ =
true;
94 action.
light_vec_[Light::Value::GREEN].flashing_ =
true;
96 action.
light_vec_[Light::Value::BLUE].active_ =
true;
97 action.
light_vec_[Light::Value::BLUE].flashing_ =
true;
99 action.
button_vec_[Button::Value::START].light_.active_ =
true;
100 action.
button_vec_[Button::Value::START].light_.current_ = Light::Value::GREEN;
101 action.
button_vec_[Button::Value::START].light_.flashing_ =
true;
104 case packml_msgs::State::STARTING:
105 case packml_msgs::State::UNHOLDING:
106 action.
light_vec_[Light::Value::GREEN].active_ =
true;
107 action.
light_vec_[Light::Value::GREEN].flashing_ =
false;
109 action.
light_vec_[Light::Value::BLUE].active_ =
true;
110 action.
light_vec_[Light::Value::BLUE].flashing_ =
true;
112 action.
button_vec_[Button::Value::START].light_.active_ =
true;
113 action.
button_vec_[Button::Value::START].light_.current_ = Light::Value::GREEN;
114 action.
button_vec_[Button::Value::START].light_.flashing_ =
false;
120 case packml_msgs::State::EXECUTE:
121 action.
light_vec_[Light::Value::GREEN].active_ =
true;
122 action.
light_vec_[Light::Value::GREEN].flashing_ =
false;
124 action.
light_vec_[Light::Value::BLUE].active_ =
true;
125 action.
light_vec_[Light::Value::BLUE].flashing_ =
true;
127 action.
button_vec_[Button::Value::START].light_.active_ =
true;
128 action.
button_vec_[Button::Value::START].light_.current_ = Light::Value::GREEN;
129 action.
button_vec_[Button::Value::START].light_.flashing_ =
false;
132 case packml_msgs::State::HOLDING:
133 case packml_msgs::State::HELD:
134 action.
light_vec_[Light::Value::BLUE].active_ =
true;
135 action.
light_vec_[Light::Value::BLUE].flashing_ =
false;
138 case packml_msgs::State::SUSPENDING:
139 case packml_msgs::State::SUSPENDED:
141 action.
light_vec_[Light::Value::AMBER].active_ =
true;
142 action.
light_vec_[Light::Value::AMBER].flashing_ =
true;
144 action.
light_vec_[Light::Value::BLUE].active_ =
true;
145 action.
light_vec_[Light::Value::BLUE].flashing_ =
true;
147 action.
button_vec_[Button::Value::START].light_.active_ =
true;
148 action.
button_vec_[Button::Value::START].light_.current_ = Light::Value::GREEN;
149 action.
button_vec_[Button::Value::START].light_.flashing_ =
false;
152 case packml_msgs::State::UNSUSPENDING:
153 action.
light_vec_[Light::Value::GREEN].active_ =
true;
154 action.
light_vec_[Light::Value::GREEN].flashing_ =
false;
156 action.
light_vec_[Light::Value::BLUE].active_ =
true;
157 action.
light_vec_[Light::Value::BLUE].flashing_ =
true;
167 temp_vec.push_back(action);
175 return action_vec_[packml_msgs::State::SUSPENDING].light_vec_[Light::Value::AMBER].flashing_;
180 action_vec_[packml_msgs::State::SUSPENDING].light_vec_[Light::Value::AMBER].flashing_ = starving;
181 action_vec_[packml_msgs::State::SUSPENDED].light_vec_[Light::Value::AMBER].flashing_ = starving;
188 static int8_t last_state = -1;
199 static int8_t last_state = -1;
208 ros::Time& last_time,
double on_secs,
double off_secs)
213 if (last_state != current_state.val)
215 last_time = new_time;
216 last_state = current_state.val;
217 last_flash = Flash::Value::ON;
221 if (last_flash == Flash::Value::ON && dur.
toSec() >= on_secs)
223 last_time = new_time;
224 last_flash = Flash::Value::OFF;
228 if (last_flash == Flash::Value::OFF && dur.
toSec() >= off_secs)
230 last_time = new_time;
231 last_flash = Flash::Value::ON;
239 static int8_t last_state = -1;
243 if (last_state != current_state.val)
245 last_time = new_time;
246 last_state = current_state.val;
252 last_time = new_time;
271 std::map<std::string, uint8_t> out_map;
272 packml_msgs::State current;
273 current.val = action.
state_;
278 std::vector<Light>::iterator light_it;
281 if (light_it->current_ == Light::Value::UNDEFINED)
286 uint8_t light_val = 0;
287 if (light_it->active_)
292 if (light_it->flashing_ && light_flash == Flash::Value::OFF)
297 out_map.insert(std::pair<std::string, uint8_t>(light_it->map_.find(light_it->current_)->second, light_val));
300 std::vector<Button>::iterator button_it;
303 if (button_it->current_ == Button::Value::UNDEFINED)
308 uint8_t button_val = 0;
309 if (button_it->light_.active_)
314 if (button_it->light_.flashing_ && light_flash == Flash::Value::OFF)
319 out_map.insert(std::pair<std::string, uint8_t>(button_it->map_.find(button_it->current_)->second, button_val));
333 out_map.insert(std::pair<std::string, uint8_t>(action.
buzzer_.
map_, buz_val));
345 last_time = new_time;
351 last_time = new_time;
355 if (current_state.val == packml_msgs::State::UNDEFINED)
357 last_time = new_time;
363 ROS_WARN(
"%s status_timeout_ reached, setting current_state to %d", __FUNCTION__, packml_msgs::State::UNDEFINED);
364 last_time = new_time;
365 current_state.val = packml_msgs::State::UNDEFINED;
std::map< std::string, uint8_t > getPubMap(Action action)
std::vector< Button > button_vec_
double flash_sec_light_off_
bool setSuspendStarving(bool starving=true)
bool getSuspendStarving()
void maybeResetState(packml_msgs::State ¤t_state, ros::Time &last_time)
Action getActionFromState(packml_msgs::State current_state)
std::vector< Action > action_vec_
bool getShouldPublish(packml_msgs::State current_state)
double publish_frequency_
double flash_sec_buzzer_off_
std::vector< Light > light_vec_
double flash_sec_light_on_
Flash::Value getBuzzerFlash(packml_msgs::State current_state)
Flash::Value getLightFlash(packml_msgs::State current_state)
void getFlash(packml_msgs::State current_state, int8_t &last_state, packml_stacklight::Flash::Value &last_flash, ros::Time &last_time, double on_secs, double off_secs)
double flash_sec_buzzer_on_
std::vector< Action > initDefaultStatusActions()