bebop_driver_nodelet.h
Go to the documentation of this file.
1 
25 #ifndef BEBOP_AUTONOMY_BEBOP_DRIVER_NODELET_H
26 #define BEBOP_AUTONOMY_BEBOP_DRIVER_NODELET_H
27 
28 // TODO(mani-monaj): Use forward decl here if possible
29 
30 #include <string>
31 
32 #include <ros/timer.h>
33 #include <nodelet/nodelet.h>
34 #include <geometry_msgs/Twist.h>
35 #include <std_msgs/Empty.h>
36 #include <std_msgs/UInt8.h>
37 #include <std_msgs/Float32.h>
38 #include <std_msgs/Bool.h>
39 #include <std_msgs/String.h>
42 #include <dynamic_reconfigure/server.h>
43 
44 #include <boost/thread.hpp>
45 #include <boost/shared_ptr.hpp>
46 
47 #include "bebop_driver/bebop.h"
48 
49 #define CLAMP(x, l, h) (((x) > (h)) ? (h) : (((x) < (l)) ? (l) : (x)))
50 
51 namespace bebop_driver
52 {
53 
54 // TODO(mani-monaj): Move these to util.h
55 namespace util
56 {
57  static const ros::console::levels::Level arsal_level_to_ros[ARSAL_PRINT_MAX] = {
63  ros::console::levels::Debug};
64 
65  static const double eps = 1.0e-6;
66  static const double deg2rad = 3.14159265 / 180.0;
67 
69 
70  void ResetTwist(geometry_msgs::Twist& t)
71  {
72  t.linear.x = 0.0;
73  t.linear.y = 0.0;
74  t.linear.z = 0.0;
75  t.angular.x = 0.0;
76  t.angular.y = 0.0;
77  t.angular.z = 0.0;
78  }
79 
80  // True: Equal, false otherwise
81  // TODO(mani-monaj): refactor
82  inline bool CompareTwists(const geometry_msgs::Twist& lhs, const geometry_msgs::Twist& rhs)
83  {
84  return (fabs(lhs.linear.x - rhs.linear.x) < eps) &&
85  (fabs(lhs.linear.y - rhs.linear.y) < eps) &&
86  (fabs(lhs.linear.z - rhs.linear.z) < eps) &&
87  (fabs(lhs.angular.x - rhs.angular.x) < eps) &&
88  (fabs(lhs.angular.y - rhs.angular.y) < eps) &&
89  (fabs(lhs.angular.z - rhs.angular.z) < eps);
90  }
91 
92  int BebopPrintToROSLogCB(eARSAL_PRINT_LEVEL level, const char *tag, const char *format, va_list va);
93 } // namespace util
94 
95 // Forward decl
96 class BebopArdrone3Config;
97 class Bebop;
98 
100 {
101 private:
105 
106  geometry_msgs::Twist prev_bebop_twist_;
108  boost::mutex twist_mutex_;
109 
110  geometry_msgs::Twist camera_twist_;
111  geometry_msgs::Twist prev_camera_twist_;
112 
127 
131 
135 
136  sensor_msgs::CameraInfoPtr camera_info_msg_ptr_;
137 
138  // Dynamic Reconfigure
140 
141  // Params (not dynamically reconfigurable, persistent)
143  std::string param_odom_frame_id_;
146 
147  // This runs in its own context
148  void CameraPublisherThread();
149 
150  // Safety monitor + ROS specfic publishers (TF, Odom, etc)
151  void AuxThread();
152 
153  void CmdVelCallback(const geometry_msgs::TwistConstPtr& twist_ptr);
154  void CameraMoveCallback(const geometry_msgs::TwistConstPtr& twist_ptr);
155  void TakeoffCallback(const std_msgs::EmptyConstPtr& empty_ptr);
156  void LandCallback(const std_msgs::EmptyConstPtr& empty_ptr);
157  void EmergencyCallback(const std_msgs::EmptyConstPtr& empty_ptr);
158  void FlatTrimCallback(const std_msgs::EmptyConstPtr& empty_ptr);
159  void NavigateHomeCallback(const std_msgs::BoolConstPtr& start_stop_ptr);
160  void StartAutonomousFlightCallback(const std_msgs::StringConstPtr& file_path_ptr);
161  void PauseAutonomousFlightCallback(const std_msgs::EmptyConstPtr& empty_ptr);
162  void StopAutonomousFlightCallback(const std_msgs::EmptyConstPtr& empty_ptr);
163  void FlipAnimationCallback(const std_msgs::UInt8ConstPtr& animid_ptr);
164  void TakeSnapshotCallback(const std_msgs::EmptyConstPtr& empty_ptr);
165  void SetExposureCallback(const std_msgs::Float32ConstPtr& exposure_ptr);
166  void ToggleRecordingCallback(const std_msgs::BoolConstPtr& toggle_ptr);
167 
168  void ParamCallback(bebop_driver::BebopArdrone3Config &config, uint32_t level);
169 
170 public:
172  virtual ~BebopDriverNodelet();
173 
174  virtual void onInit();
175 };
176 } // namespace bebop_driver
177 
178 #endif // BEBOP_AUTONOMY_BEBOP_DRIVER_NODELET_H
boost::shared_ptr< boost::thread > aux_thread_ptr_
boost::shared_ptr< image_transport::ImageTransport > image_transport_ptr_
image_transport::CameraPublisher image_transport_pub_
boost::shared_ptr< boost::thread > camera_pub_thread_ptr_
boost::shared_ptr< dynamic_reconfigure::Server< bebop_driver::BebopArdrone3Config > > dynr_serv_ptr_
static char bebop_err_str[BEBOP_ERR_STR_SZ]
bool CompareTwists(const geometry_msgs::Twist &lhs, const geometry_msgs::Twist &rhs)
sensor_msgs::CameraInfoPtr camera_info_msg_ptr_
int BebopPrintToROSLogCB(eARSAL_PRINT_LEVEL level, const char *tag, const char *format, va_list va)
void ResetTwist(geometry_msgs::Twist &t)
boost::shared_ptr< bebop_driver::Bebop > bebop_ptr_
boost::shared_ptr< camera_info_manager::CameraInfoManager > cinfo_manager_ptr_
static const double deg2rad
static const ros::console::levels::Level arsal_level_to_ros[ARSAL_PRINT_MAX]
#define BEBOP_ERR_STR_SZ
Definition: bebop.h:28
static const double eps


bebop_driver
Author(s): Mani Monajjemi
autogenerated on Mon Jun 10 2019 12:58:56