Revision 7cb5de78
ID | 7cb5de78f535a69b8104606a6eac7994534f3f61 |
Updated encoder node code with preliminary driver functionality.
Renamed encoder_state.msg to encoders_state.msg.
Added functions to encoders.cpp to send message of current encoder state.
Added function headers to encoders.h.
Added function to encoders.cpp to convert to different units.
Added additional global variables to store encoder state.
Updated encoder_state.msg and query_encoders.srv with additional fields for units.
Node is not completed. Still requires lowest level driver functionality. Needs constants for encoders and wheels. Needs initialization in main for encoders_state publisher. Needs implementation of encoders_set_mode, which should change what units the encoders node publishes the encoders_state message, and with which frequency.
I know this is bad practice, but I have not tried compiling my changes. I broke my computer's ability to compile ROS code, so this is untested. However, it should work. SORRY.
scout/encoders/src/encoders.h | ||
---|---|---|
1 | 1 |
/** |
2 |
*Copyright (c) 2007 Colony Project
|
|
2 |
*Copyright (c) 2011 Colony Project
|
|
3 | 3 |
* |
4 | 4 |
* Permission is hereby granted, free of charge, to any person |
5 | 5 |
* obtaining a copy of this software and associated documentation |
... | ... | |
34 | 34 |
* @author Colony Project, CMU Robotics Club |
35 | 35 |
**/ |
36 | 36 |
|
37 |
/* Authors: Ben Wasserman, Lalitha Ganesan |
|
38 |
*/ |
|
39 |
|
|
40 | 37 |
#ifndef _ENCODERS_H_ |
41 | 38 |
#define _ENCODERS_H_ |
42 | 39 |
|
43 | 40 |
#include "encoders/query_encoders.h" |
44 |
#include "encoders/encoder_state.h" |
|
41 |
#include "encoders/encoders_state.h" |
|
42 |
|
|
43 |
#define ENCODERS_TICKS 't' |
|
44 |
#define ENCODERS_MM 'm' |
|
45 |
#define ENCODERS_CM 'c' |
|
46 |
#define ENCODERS_DEG 'd' |
|
45 | 47 |
|
48 |
#define NUM_TICKS 100 |
|
49 |
#define WHEEL_RADIUS_MM 20 |
|
50 |
#define PI 3.14159265 |
|
46 | 51 |
|
47 | 52 |
/** @brief Initialize the encoders module and driver **/ |
48 | 53 |
int main(int argc, char **argv); |
49 | 54 |
/** @brief Responds to topic to get encoder state **/ |
50 |
void encoder_state(const encoders::encoder_state::ConstPtr& msg); |
|
55 |
void encoder_set_mode(const encoders::encoders_state::ConstPtr& msg); |
|
56 |
/** @brief Publishes encoder state **/ |
|
57 |
void encoders_state_publish(); |
|
51 | 58 |
/** @brief Responds to service to query encoder data **/ |
52 | 59 |
bool encoders_query(encoders::query_encoders::Request &req, |
53 | 60 |
encoders::query_encoders::Response &res); |
61 |
/** @brief Converts encoder values to selected units **/ |
|
62 |
int encoders_ticks_to_units(int ticks, char units); |
|
54 | 63 |
|
55 | 64 |
#endif |
Also available in: Unified diff