ev3_color_controller.h
1 /*
2  * This file (ev3_color_controller.h) is part of h4r_ev3_control.
3  * Date: 10.12.2015
4  *
5  * Author: Christian Holl
6  * http://github.com/Hacks4ROS
7  *
8  * h4r_ev3_control is free software: you can redistribute it and/or modify
9  * it under the terms of the GNU General Public License as published by
10  * the Free Software Foundation, either version 3 of the License, or
11  * (at your option) any later version.
12  *
13  * h4r_ev3_control is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License
19  * along with ev3_control. If not, see <http://www.gnu.org/licenses/>.
20  *
21  */
22 
23 
24 #ifndef EV3_COLOR_CONTROLLER_H_
25 #define EV3_COLOR_CONTROLLER_H_
26 
27 #include <controller_interface/controller.h>
28 #include <pluginlib/class_list_macros.h>
29 #include <realtime_tools/realtime_publisher.h>
30 #include <boost/shared_ptr.hpp>
31 #include <sensor_msgs/Illuminance.h>
32 #include <std_msgs/ColorRGBA.h>
33 #include <std_msgs/UInt8.h>
34 #include <limits>
35 
36 #include <h4r_ev3_control/Ev3SensorInterface.h>
37 
38 namespace ev3_control
39 {
40 
55 class Ev3ColorController: public controller_interface::Controller<
56  Ev3SensorInterface>
57 {
58 private:
59  std::string port_;
60  Ev3Strings::Ev3ColorMode mode_;
61  Ev3SensorHandle handle_;
62  H4REv3ColorSensorSpecIface color_interface_;
63  bool sensor_mode_needs_init_;
64  std::string frame_id_;
65 
66  //Range Publisher
67  typedef boost::shared_ptr<
68  realtime_tools::RealtimePublisher<sensor_msgs::Illuminance> > RtIlluminancePublisherPtr;
69  RtIlluminancePublisherPtr realtime_illuminance_publisher_;
70 
71  typedef boost::shared_ptr<
72  realtime_tools::RealtimePublisher<std_msgs::ColorRGBA> > RtColorPublisherPtr;
73  RtColorPublisherPtr realtime_color_publisher_;
74 
75  typedef boost::shared_ptr<
76  realtime_tools::RealtimePublisher<std_msgs::UInt8> > RtColorNumberPublisherPtr;
77  RtColorNumberPublisherPtr realtime_color_number_publisher_;
78 
79  ros::Time last_publish_time_;
80  double publish_rate_;
81 
82 public:
84  virtual ~Ev3ColorController();
85 
86  virtual bool init(Ev3SensorInterface* hw,
87  ros::NodeHandle &root_nh,
88  ros::NodeHandle& ctrl_nh);
89 
90  virtual void starting(const ros::Time& time);
91  virtual void update(const ros::Time& time, const ros::Duration& /*period*/);
92  virtual void stopping(const ros::Time& /*time*/){}
93 
94 };
95 
96 } /* namespace ev3_control */
97 
98 #endif /* EV3_COLOR_CONTROLLER_H_ */
Definition: ev3_color_controller.h:55
Definition: Ev3SensorInterface.h:35
Definition: Ev3SensorInterface.h:97