forked from glennliu/uavformation
-
Notifications
You must be signed in to change notification settings - Fork 0
/
formation_control.h
51 lines (40 loc) · 969 Bytes
/
formation_control.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
#include <ros/ros.h>
#include "math.h"
#include <iostream>
#include <sstream>
#include <cmath>
int formation_mode;
struct position
{
float x,y,z;
}uav1,uav2,uav3,uav4;
void form_square(double xc,double yc,double zc,double g,double b)
{
uav1.x=xc-1.41*g*cos(b);
uav1.y=yc+1.41*g*sin(b);
uav1.z=zc;
uav2.x=xc-1.41*g*sin(b);
uav2.y=yc-1.41*g*cos(b);
uav2.z=zc;
uav3.x=xc+1.41*g*cos(b);
uav3.y=yc-1.41*g*sin(b);
uav3.z=zc;
uav4.x=xc+1.41*g*sin(b);
uav4.y=yc+1.41*g*cos(b);
uav4.z=zc;
}
void form_line(double xc,double yc,double zc,double g,double a)
{
uav1.x=xc-3*g*cos(a);
uav1.y=yc-3*g*sin(a);
uav1.z=zc;
uav2.x=xc-g*cos(a);
uav2.y=yc-g*sin(a);
uav2.z=zc;
uav3.x=xc+g*cos(a);
uav3.y=yc+g*sin(a);
uav3.z=zc;
uav4.x=xc+3*g*cos(a);
uav4.y=yc+3*g*sin(a);
uav4.z=zc;
}