Revision ce559b91
ID | ce559b91dc2723f09fa0c381cd4ebff86d4f8e10 |
Fixed the encoders node.
Simplified the node to only advertise a single service - a query allows other nodes to find out, simply, the total distance traveled. The node also only handles plain encoder ticks, because distance and such computation should be done on the library end.
scout/encoders/src/encoders.h | ||
---|---|---|
25 | 25 |
|
26 | 26 |
/** |
27 | 27 |
* @file encoders.h |
28 |
* @brief Contains encoder declarations and functions |
|
28 |
* @brief Contains encoder declarations and functions.
|
|
29 | 29 |
* |
30 |
* Contains functions and definitions for the use of |
|
31 |
* encoders. |
|
32 |
* |
|
33 | 30 |
* @author Colony Project, CMU Robotics Club |
31 |
* @author Alex Zirbel |
|
34 | 32 |
**/ |
35 | 33 |
|
36 | 34 |
#ifndef _ENCODERS_H_ |
37 | 35 |
#define _ENCODERS_H_ |
38 | 36 |
|
39 | 37 |
#include "encoders/query_encoders.h" |
40 |
#include "encoders/encoders_state.h" |
|
41 |
|
|
42 |
#define ENCODERS_TICKS 't' |
|
43 |
#define ENCODERS_MM 'm' |
|
44 |
#define ENCODERS_CM 'c' |
|
45 |
#define ENCODERS_DEG 'd' |
|
46 |
|
|
47 |
#define NUM_TICKS 100 |
|
48 |
#define WHEEL_RADIUS_MM 20 |
|
49 |
#define PI 3.14159265 |
|
50 | 38 |
|
51 | 39 |
/** @brief Initialize the encoders module and driver **/ |
52 | 40 |
int main(int argc, char **argv); |
53 |
/** @brief Responds to topic to get encoder state **/ |
|
54 |
void encoder_set_mode(const encoders::encoders_state::ConstPtr& msg); |
|
55 |
/** @brief Publishes encoder state **/ |
|
56 |
void encoders_state_publish(); |
|
41 |
|
|
57 | 42 |
/** @brief Responds to service to query encoder data **/ |
58 |
bool encoders_query(encoders::query_encoders::Request &req, |
|
59 |
encoders::query_encoders::Response &res); |
|
60 |
/** @brief Converts encoder values to selected units **/ |
|
61 |
int encoders_ticks_to_units(int ticks, char units); |
|
43 |
bool handle_encoders_query(encoders::query_encoders::Request &req, |
|
44 |
encoders::query_encoders::Response &res); |
|
62 | 45 |
|
63 | 46 |
#endif |
Also available in: Unified diff