Revision 1019d31f
Adding Maung's paintboard i2c code
scout/painter/src/painter.cpp | ||
---|---|---|
1 | 1 |
/** |
2 |
* Copyright (c) 2011 Colony Project
|
|
2 |
* Copyright (c) 2013 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 |
... | ... | |
39 | 39 |
#include <messages/set_paintboard.h> |
40 | 40 |
#include <messages/query_paintboard.h> |
41 | 41 |
#include <messages/query_metal_detector.h> |
42 |
#include "paint-i2c.h" |
|
42 | 43 |
|
43 | 44 |
using namespace std; |
44 | 45 |
|
46 |
int painter_value; |
|
47 |
|
|
45 | 48 |
/** |
46 | 49 |
* @brief ROS callback to turn the paint output on or off |
47 | 50 |
*/ |
48 | 51 |
void paint_set(const ::messages::set_paintboard::ConstPtr& msg) |
49 | 52 |
{ |
53 |
painter_value = msg->setting; |
|
54 |
set_servo(0, painter_value); |
|
50 | 55 |
} |
51 | 56 |
|
52 | 57 |
/** |
... | ... | |
55 | 60 |
bool paint_query(::messages::query_paintboard::Request &req, |
56 | 61 |
::messages::query_paintboard::Response &res) |
57 | 62 |
{ |
63 |
res.setting = painter_value; |
|
58 | 64 |
return true; |
59 | 65 |
} |
60 | 66 |
|
... | ... | |
64 | 70 |
bool metal_query(::messages::query_metal_detector::Request &req, |
65 | 71 |
::messages::query_metal_detector::Response &res) |
66 | 72 |
{ |
73 |
res.metal = get_input(0); |
|
67 | 74 |
return true; |
68 | 75 |
} |
69 | 76 |
|
... | ... | |
78 | 85 |
ros::init(argc, argv, "painter"); |
79 | 86 |
ros::NodeHandle node; |
80 | 87 |
|
88 |
i2c_start(); |
|
89 |
set_motor(0, 0); |
|
90 |
set_servo(0, 0); |
|
91 |
|
|
81 | 92 |
ros::Subscriber painter_sub = node.subscribe("/set_paintboard", QUEUE_SIZE, |
82 | 93 |
paint_set); |
83 | 94 |
ros::ServiceServer painter_srv = node.advertiseService("/query_paintboard", |
... | ... | |
88 | 99 |
ROS_INFO("Painter node ready."); |
89 | 100 |
ros::spin(); |
90 | 101 |
|
102 |
i2c_stop(); |
|
103 |
|
|
91 | 104 |
return 0; |
92 | 105 |
} |
Also available in: Unified diff