ev3_infrared_controller.h
1 /*
2  * This file (ev3_infrared_controller.h) is part of h4r_ev3_control.
3  * Date: 06.01.2016
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 h4r_ev3_control. If not, see <http://www.gnu.org/licenses/>.
20  *
21  */
22 #ifndef EV3_INFRARED_CONTROLLER_H_
23 #define EV3_INFRARED_CONTROLLER_H_
24 
25 #include <controller_interface/controller.h>
26 #include <pluginlib/class_list_macros.h>
27 #include <realtime_tools/realtime_publisher.h>
28 #include <boost/shared_ptr.hpp>
29 #include <sensor_msgs/Range.h>
30 #include <sensor_msgs/Joy.h>
31 #include <h4r_ev3_msgs/Seek.h>
32 #include <limits>
33 
34 #include <h4r_ev3_control/Ev3SensorInterface.h>
35 
36 namespace ev3_control
37 {
38 
53 class Ev3InfraredController: public controller_interface::Controller<
54  Ev3SensorInterface>
55 {
56 private:
57  std::string port_;
58  Ev3Strings::Ev3InfraredMode mode_;
59  Ev3SensorHandle handle_;
60  H4REv3IRSensorSpecIface ir_interface_;
61  bool sensor_mode_needs_init_;
62 
63  double max_range_;
64  double min_range_;
65  std::string frame_id_;
66  unsigned value_number_;
67 
68  //Range Publisher
69  typedef boost::shared_ptr<
70  realtime_tools::RealtimePublisher<sensor_msgs::Range> > RtRangePublisherPtr;
71  RtRangePublisherPtr realtime_range_publisher_;
72 
73  typedef boost::shared_ptr<
74  realtime_tools::RealtimePublisher<h4r_ev3_msgs::Seek> > RtSeekPublisherPtr;
75  RtSeekPublisherPtr realtime_seek_publishers_[4];
76 
77  typedef boost::shared_ptr<
78  realtime_tools::RealtimePublisher<sensor_msgs::Joy> > RtJoyPublisherPtr;
79  RtJoyPublisherPtr realtime_joy_publishers_[4];
80 
81 
82  ros::Time last_publish_time_[4];
83  double publish_rate_;
84  bool first_time_[4];
85 
86 public:
88  virtual ~Ev3InfraredController();
89 
90  virtual bool init(Ev3SensorInterface* hw,
91  ros::NodeHandle &root_nh,
92  ros::NodeHandle& ctrl_nh);
93 
94  virtual void starting(const ros::Time& time);
95  virtual void update(const ros::Time& time, const ros::Duration& /*period*/);
96  virtual void stopping(const ros::Time& /*time*/){}
97 
98 };
99 
100 } /* namespace ev3_control */
101 
102 #endif /* EV3_INFRARED_CONTROLLER_H_ */
Definition: ev3_infrared_controller.h:53
Definition: Ev3SensorInterface.h:35
Definition: Ev3SensorInterface.h:97