Revision da889457
ID | da889457e79e3e7e2d37b071dffdef00b81595f3 |
Created nav_lib.cpp/h, with functions forward, backward, left, right,
and stop to set the mikrokopter's movement direction.
Replaced code in wasd_nav.cpp's main with forward(pub) and stop(pub)
from nav_lib.cpp.
Added nav_lib.cpp to CMakeLists.txt
mikrokopter/src/wasd_nav.cpp | ||
---|---|---|
1 | 1 |
#include "ros/ros.h" |
2 | 2 |
#include "mikrokopter/Control.h" |
3 |
#include "nav_lib.h" |
|
3 | 4 |
#include <cstdlib> |
4 | 5 |
|
5 | 6 |
|
... | ... | |
9 | 10 |
|
10 | 11 |
ros::NodeHandle n; |
11 | 12 |
ros::Publisher pub = n.advertise<mikrokopter::Control>("/mikrokopter/req_set_control", 100); |
12 |
mikrokopter::Control req; |
|
13 |
req.digital[0] = 0; |
|
14 |
req.digital[1] = 0; |
|
15 |
req.remoteKey = 0; |
|
16 |
req.pitch = 0; |
|
17 |
req.roll = 0; |
|
18 |
req.yaw = 0; |
|
19 |
req.thrust = 40; |
|
20 |
req.height = 0; |
|
21 |
req.free = 0; |
|
22 |
req.frame = 7; |
|
23 |
req.config = 1; |
|
24 | 13 |
|
25 | 14 |
ros::Rate loop_rate(25); |
26 | 15 |
|
27 | 16 |
printf("moving\n"); |
28 |
|
|
29 |
req.roll = -15; |
|
30 |
req.pitch = -15; /* nick is pitch */ |
|
31 |
pub.publish(req); |
|
32 |
ros::spinOnce(); |
|
17 |
forward(pub); |
|
33 | 18 |
|
34 | 19 |
sleep(5); |
35 | 20 |
printf("evening out\n"); |
36 |
req.roll = 0; |
|
37 |
req.pitch = 0; |
|
38 |
pub.publish(req); |
|
39 |
ros::spinOnce(); |
|
40 |
|
|
41 |
} |
|
42 |
void forward() |
|
43 |
{ |
|
44 |
|
|
45 |
|
|
21 |
stop(pub); |
|
22 |
|
|
23 |
return 0; |
|
46 | 24 |
} |
47 |
|
Also available in: Unified diff