Project

General

Profile

Statistics
| Branch: | Revision:

root / mikrokopter / src / nav_lib.cpp @ da889457

History | View | Annotate | Download (747 Bytes)

1
#include "nav_lib.h"
2

    
3
void set_roll_pitch(ros::Publisher& pub, int roll, int pitch) {
4
    mikrokopter::Control req;
5
    req.digital[0] = 0;
6
    req.digital[1] = 0;
7
    req.remoteKey = 0;
8
    req.pitch = roll;
9
    req.roll = pitch;
10
    req.yaw = 0;
11
    req.thrust = 40;
12
    req.height = 0;
13
    req.free = 0;
14
    req.frame = 7;
15
    req.config = 1;
16
    pub.publish(req);
17
    ros::spinOnce();
18
}
19

    
20

    
21
void forward(ros::Publisher& pub)
22
{
23
    set_roll_pitch(pub, -15, -15);
24
}
25

    
26
void backward(ros::Publisher& pub)
27
{
28
    set_roll_pitch(pub, 15, 15);
29
}
30

    
31
void left(ros::Publisher& pub)
32
{
33
    set_roll_pitch(pub, -15, 15);
34
}
35

    
36
void right(ros::Publisher& pub)
37
{
38
    set_roll_pitch(pub, 15, -15);
39
}
40

    
41
void stop(ros::Publisher& pub)
42
{
43
    set_roll_pitch(pub, 0, 0);
44
}