-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathhover.h
108 lines (78 loc) · 2.53 KB
/
hover.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
/** @file demo_local_position_control.h
* @version 3.3
* @date September, 2017
*
* @brief
* demo sample of how to use local position control APIs
*
* @copyright 2017 DJI. All rights reserved.
*
*/
#ifndef PROJECT_DEMO_LOCAL_POSITION_CONTROL_H
#define PROJECT_DEMO_LOCAL_POSITION_CONTROL_H
#endif //PROJECT_DEMO_LOCAL_POSITION_CONTROL_H
#include <dji_sdk/SetLocalPosRef.h>
#include <ros/ros.h>
#include <geometry_msgs/PointStamped.h>
#include <geometry_msgs/QuaternionStamped.h>
#include <geometry_msgs/Vector3Stamped.h>
#include <std_msgs/UInt8.h>
#include <sensor_msgs/Joy.h>
#include <sensor_msgs/Imu.h>
#include <sensor_msgs/NavSatFix.h>
#include <geometry_msgs/Vector3.h>
//DJI SDK includes
#include <dji_sdk/DroneTaskControl.h>
#include <dji_sdk/SDKControlAuthority.h>
#include <dji_sdk/QueryDroneVersion.h>
#include <tf/tf.h>
#define C_EARTH (double)6378137.0
#define C_PI (double)3.141592653589793
#define DEG2RAD(DEG) ((DEG) * ((C_PI) / (180.0)))
bool set_local_position();
float target_offset_x;
float target_offset_y;
float target_offset_z;
float target_yaw;
int target_set_state = 0;
float yawinRad;
float rollinRad;
float pitchinRad;
float x_error=0;
float y_error=0;
float dx_error=0;
float dy_error=0;
float max_angle=0.1;/// 5 moires
float rolld;
float pitchd;
float pitch;
float roll;
float xspeed_prev=0;
float xspeed=0;float yspeed=0;float yspeed_prev=0;
float ax_prev=0; float ay_prev=0;float ay=0;float ax=0;
float dximu=0;float dyimu=0;float dxuwb=0; float dyuwb=0;// distances
double dt,dt1;
ros::Time start_, end_,s1,e1;
void setTarget(float x, float y, float z, float yaw)
{
target_offset_x = x;
target_offset_y = y;
target_offset_z = z;
target_yaw = yaw;
}
void imu_callback(const sensor_msgs::Imu::ConstPtr& msg);
void initial_pos_callback(const geometry_msgs::Point::ConstPtr& msg);
void uwb_position_callback(const geometry_msgs::Point::ConstPtr& msg);
void local_position_callback(const geometry_msgs::PointStamped::ConstPtr& msg);
void display_mode_callback(const std_msgs::UInt8::ConstPtr& msg);
void attitude_callback(const geometry_msgs::QuaternionStamped::ConstPtr& msg);
void flight_status_callback(const std_msgs::UInt8::ConstPtr& msg);
void gps_position_callback(const sensor_msgs::NavSatFix::ConstPtr& msg);
void gps_health_callback(const std_msgs::UInt8::ConstPtr& msg);
bool takeoff_land(int task);
bool obtain_control();
geometry_msgs::Vector3 toEulerAngle(geometry_msgs::Quaternion quat);
bool is_M100();
bool monitoredTakeoff();
bool M100monitoredTakeoff();
void local_position_ctrl();