utils.h
Go to the documentation of this file.
1 /*
2  * Software License Agreement (Apache License)
3  *
4  * Copyright (c) 2019 Joshua Hatzenbuehler
5  *
6  * Licensed under the Apache License, Version 2.0 (the "License");
7  * you may not use this file except in compliance with the License.
8  * You may obtain a copy of the License at
9  *
10  * http://www.apache.org/licenses/LICENSE-2.0
11  *
12  * Unless required by applicable law or agreed to in writing, software
13  * distributed under the License is distributed on an "AS IS" BASIS,
14  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15  * See the License for the specific language governing permissions and
16  * limitations under the License.
17  */
18 
19 #ifndef PACKML_STACKLIGHT_UTILS_H
20 #define PACKML_STACKLIGHT_UTILS_H
21 
22 #include <map>
23 #include <ros/ros.h>
29 
30 namespace packml_stacklight
31 {
32 class Utils
33 {
34 protected:
35  std::vector<Action> action_vec_ = initDefaultStatusActions();
36 
37 public:
38  double flash_sec_light_on_ = 2.0;
39  double flash_sec_light_off_ = 2.0;
40  double flash_sec_buzzer_on_ = 2.0;
41  double flash_sec_buzzer_off_ = 2.0;
42  double publish_frequency_ = 0.5;
43  double status_timeout_ = 30.0;
44 
45 private:
46  std::vector<Action> initDefaultStatusActions();
47  void getFlash(packml_msgs::State current_state, int8_t& last_state, packml_stacklight::Flash::Value& last_flash,
48  ros::Time& last_time, double on_secs, double off_secs);
49 
50 protected:
51  Flash::Value getLightFlash(packml_msgs::State current_state);
52  Flash::Value getBuzzerFlash(packml_msgs::State current_state);
53  Action getActionFromState(packml_msgs::State current_state);
54  std::map<std::string, uint8_t> getPubMap(Action action);
55 
56 public:
57  Utils();
58  ~Utils();
59  bool getSuspendStarving();
60  bool setSuspendStarving(bool starving = true);
61  bool getShouldPublish(packml_msgs::State current_state);
62  std::map<std::string, uint8_t> getPubMap(packml_msgs::State current_state);
63  void maybeResetState(packml_msgs::State& current_state, ros::Time& last_time);
64 };
65 
66 } // namespace packml_stacklight
67 
68 #endif // PACKML_STACKLIGHT_UTILS_H
std::map< std::string, uint8_t > getPubMap(Action action)
Definition: utils.cpp:269
double flash_sec_light_off_
Definition: utils.h:39
bool setSuspendStarving(bool starving=true)
Definition: utils.cpp:178
double status_timeout_
Definition: utils.h:43
void maybeResetState(packml_msgs::State &current_state, ros::Time &last_time)
Definition: utils.cpp:338
Action getActionFromState(packml_msgs::State current_state)
Definition: utils.cpp:259
std::vector< Action > action_vec_
Definition: utils.h:35
bool getShouldPublish(packml_msgs::State current_state)
Definition: utils.cpp:236
double publish_frequency_
Definition: utils.h:42
double flash_sec_buzzer_off_
Definition: utils.h:41
double flash_sec_light_on_
Definition: utils.h:38
Flash::Value getBuzzerFlash(packml_msgs::State current_state)
Definition: utils.cpp:196
Flash::Value getLightFlash(packml_msgs::State current_state)
Definition: utils.cpp:185
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)
Definition: utils.cpp:207
double flash_sec_buzzer_on_
Definition: utils.h:40
std::vector< Action > initDefaultStatusActions()
Definition: utils.cpp:33


packml_stacklight
Author(s): Joshua Hatzenbuehler
autogenerated on Fri Jul 12 2019 03:31:01