root / scout / painter / src / painter.cpp @ 66f55732
History | View | Annotate | Download (2.71 KB)
1 |
/**
|
---|---|
2 |
* Copyright (c) 2011 Colony Project
|
3 |
*
|
4 |
* Permission is hereby granted, free of charge, to any person
|
5 |
* obtaining a copy of this software and associated documentation
|
6 |
* files (the "Software"), to deal in the Software without
|
7 |
* restriction, including without limitation the rights to use,
|
8 |
* copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9 |
* copies of the Software, and to permit persons to whom the
|
10 |
* Software is furnished to do so, subject to the following
|
11 |
* conditions:
|
12 |
*
|
13 |
* The above copyright notice and this permission notice shall be
|
14 |
* included in all copies or substantial portions of the Software.
|
15 |
*
|
16 |
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17 |
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
|
18 |
* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19 |
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
20 |
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
21 |
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
22 |
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
23 |
* OTHER DEALINGS IN THE SOFTWARE.
|
24 |
*/
|
25 |
|
26 |
/**
|
27 |
* @file painter.cpp
|
28 |
* @brief Contains code to control the painter and query the metal detector.
|
29 |
*
|
30 |
* @author Colony Project, CMU Robotics Club
|
31 |
* @author Tom Mullins
|
32 |
*
|
33 |
*/
|
34 |
|
35 |
#define QUEUE_SIZE 10 |
36 |
|
37 |
#include <cstdlib> |
38 |
#include <ros/ros.h> |
39 |
#include <messages/set_paintboard.h> |
40 |
#include <messages/query_paintboard.h> |
41 |
#include <messages/query_metal_detector.h> |
42 |
|
43 |
using namespace std; |
44 |
|
45 |
/**
|
46 |
* @brief ROS callback to turn the paint output on or off
|
47 |
*/
|
48 |
void paint_set(const ::messages::set_paintboard::ConstPtr& msg) |
49 |
{ |
50 |
} |
51 |
|
52 |
/**
|
53 |
* @brief ROS callback to query whether the paint output is on or off
|
54 |
*/
|
55 |
bool paint_query(::messages::query_paintboard::Request &req,
|
56 |
::messages::query_paintboard::Response &res) |
57 |
{ |
58 |
return true; |
59 |
} |
60 |
|
61 |
/**
|
62 |
* @brief ROS callback to query whether there is metal detected
|
63 |
*/
|
64 |
bool metal_query(::messages::query_metal_detector::Request &req,
|
65 |
::messages::query_metal_detector::Response &res) |
66 |
{ |
67 |
return true; |
68 |
} |
69 |
|
70 |
/**
|
71 |
* @brief Painter driver for ROS, to control the painter and metal detector
|
72 |
*
|
73 |
* @param argc The number of command line arguments (should be 1)
|
74 |
* @param argv The array of command line arguments
|
75 |
*/
|
76 |
int main(int argc, char **argv) |
77 |
{ |
78 |
ros::init(argc, argv, "painter");
|
79 |
ros::NodeHandle node; |
80 |
|
81 |
ros::Subscriber painter_sub = node.subscribe("/set_paintboard", QUEUE_SIZE,
|
82 |
paint_set); |
83 |
ros::ServiceServer painter_srv = node.advertiseService("/query_paintboard",
|
84 |
paint_query); |
85 |
ros::ServiceServer metal_srv = node.advertiseService("/query_metal_detector",
|
86 |
metal_query); |
87 |
|
88 |
ROS_INFO("Painter node ready.");
|
89 |
ros::spin(); |
90 |
|
91 |
return 0; |
92 |
} |