Revision 572adceb
Fixed the analog node.
Only a couple small changes were needed here. For the most part, good job Dev - looks like this is set up correctly for a skeleton. Changes were debugging only.
scout/analog/src/analog.cpp | ||
---|---|---|
33 | 33 |
* @author Dev Gurjar |
34 | 34 |
**/ |
35 | 35 |
|
36 |
#include "ros/ros.h" |
|
36 |
#include <ros/ros.h> |
|
37 |
|
|
37 | 38 |
#include "analog.h" |
38 |
//#include "libscout/src/constants.h" |
|
39 |
#include <cstdlib> |
|
40 | 39 |
|
41 | 40 |
/** |
42 | 41 |
* @defgroup analog Analog |
... | ... | |
49 | 48 |
/** @todo Fix types: static */ |
50 | 49 |
unsigned int port; /**< The current port from which we are reading from. */ |
51 | 50 |
|
52 |
|
|
53 | 51 |
/** |
54 | 52 |
* @brief Outputs current analog data at a given port |
55 | 53 |
* |
... | ... | |
58 | 56 |
* @param req The request. The only field is the units requested. |
59 | 57 |
* @param res The response. The fields will be filled with values. |
60 | 58 |
*/ |
61 |
bool analog_query(motors::query_analog::Request &req,
|
|
62 |
motors::query_analog::Response &res)
|
|
59 |
bool analog_query(analog::query_analog::Request &req,
|
|
60 |
analog::query_analog::Response &res)
|
|
63 | 61 |
{ |
64 |
int port = port; |
|
62 |
int port = req.port;
|
|
65 | 63 |
res.sensor_data = get_sensor_data(port); |
66 | 64 |
|
67 | 65 |
ROS_DEBUG("Analog data queried"); |
... | ... | |
75 | 73 |
* |
76 | 74 |
* @param port The port we want to read from |
77 | 75 |
*/ |
78 |
unsigned int get_sensor_data(int port){
|
|
79 |
|
|
80 |
ROS_DEBUG("Got Analog data from the sensor"); |
|
76 |
unsigned int get_sensor_data(int port) |
|
77 |
{ |
|
78 |
ROS_DEBUG("Got Analog data from the sensor [Unimplemented]");
|
|
81 | 79 |
return 0; |
82 | 80 |
} |
83 | 81 |
|
84 | 82 |
/** |
85 |
* @brief Motors driver. This is a ROS node that controls motor speeds. |
|
86 |
* |
|
87 |
* This is the main function for the motors node. It is run when the node |
|
88 |
* starts and initializes the motors. It then subscribes to the |
|
89 |
* set_motors, and set_motor_speeds topics, and advertises the |
|
90 |
* query_motors service. |
|
91 |
* |
|
92 |
* @param argc The number of command line arguments (should be 1) |
|
93 |
* @param argv The array of command line arguments |
|
94 |
**/ |
|
83 |
* @brief Analog driver. Provides an interface to read data from analog ports. |
|
84 |
*/ |
|
95 | 85 |
int main(int argc, char **argv) |
96 | 86 |
{ |
97 | 87 |
/* Initialize in ROS the motors driver node */ |
... | ... | |
102 | 92 |
ros::ServiceServer service = n.advertiseService("query_analog", |
103 | 93 |
analog_query); |
104 | 94 |
|
105 |
/* Initialize hardware for motors */ |
|
95 |
/* Initialize hardware for analog */ |
|
96 |
|
|
106 | 97 |
// Hardware init functions here |
107 | 98 |
ros::spin(); |
108 | 99 |
|
Also available in: Unified diff