root / scout / libscout / src / test_encoders.cpp @ 34a600c5
History | View | Annotate | Download (839 Bytes)
1 | 9f547ef7 | Alex Zirbel | |
---|---|---|---|
2 | #include <ros/ros.h> |
||
3 | #include <encoders/query_encoders.h> |
||
4 | |||
5 | int main(int argc, char **argv) |
||
6 | { |
||
7 | ros::init(argc, argv, "test_encoders");
|
||
8 | ros::NodeHandle node; |
||
9 | |||
10 | ros::ServiceClient query_encoders_client = |
||
11 | node.serviceClient<encoders::query_encoders>("/scout1/query_encoders");
|
||
12 | |||
13 | ros::Rate r(10);
|
||
14 | |||
15 | while (ros::ok())
|
||
16 | { |
||
17 | encoders::query_encoders srv; |
||
18 | if (query_encoders_client.call(srv))
|
||
19 | { |
||
20 | printf("Got encoders: fl:%u, fr:%u, bl:%u, br:%u).\n",
|
||
21 | srv.response.fl_distance, |
||
22 | srv.response.fr_distance, |
||
23 | srv.response.bl_distance, |
||
24 | srv.response.br_distance); |
||
25 | } |
||
26 | else
|
||
27 | { |
||
28 | printf("ERROR: Failed to call service.\n");
|
||
29 | } |
||
30 | |||
31 | ros::spinOnce(); |
||
32 | r.sleep(); |
||
33 | } |
||
34 | |||
35 | return 0; |
||
36 | } |