ev3_ultrasonic_controller.h
1 /*
2  * This file (Ev3UltraSonicController.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 #ifndef EV3_ULTRASONIC_CONTROLLER_H_
23 #define EV3_ULTRASONIC_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 <std_msgs/Bool.h>
31 #include <limits>
32 
33 #include <h4r_ev3_control/Ev3SensorInterface.h>
34 
35 namespace ev3_control
36 {
37 
52 class Ev3UltrasonicController: public controller_interface::Controller<
53  Ev3SensorInterface>
54 {
55 private:
56  std::string port_;
57  Ev3Strings::Ev3UltrasonicMode mode_;
58  Ev3SensorHandle handle_;
59  H4REv3UltraSonicSensorSpecIface us_interface_;
60  bool sensor_mode_needs_init_;
61 
62  double max_range_;
63  double min_range_;
64  std::string frame_id_;
65 
66  //Range Publisher
67  typedef boost::shared_ptr<
68  realtime_tools::RealtimePublisher<sensor_msgs::Range> > RtRangePublisherPtr;
69  RtRangePublisherPtr realtime_range_publisher_;
70 
71  typedef boost::shared_ptr<
72  realtime_tools::RealtimePublisher<std_msgs::Bool> > RtBoolPublisherPtr;
73  RtBoolPublisherPtr realtime_bool_publisher_;
74 
75 
76  ros::Time last_publish_time_;
77  double publish_rate_;
78 
79 public:
81  virtual ~Ev3UltrasonicController();
82 
83  virtual bool init(Ev3SensorInterface* hw,
84  ros::NodeHandle &root_nh,
85  ros::NodeHandle& ctrl_nh);
86 
87  virtual void starting(const ros::Time& time);
88  virtual void update(const ros::Time& time, const ros::Duration& /*period*/);
89  virtual void stopping(const ros::Time& /*time*/){}
90 
91 };
92 
93 } /* namespace ev3_control */
94 
95 #endif /* EV3_ULTRASONIC_CONTROLLER_H_ */
Definition: Ev3SensorInterface.h:35
Definition: ev3_ultrasonic_controller.h:52
Definition: Ev3SensorInterface.h:97