scoutos / scout / libscout / src / test_behaviors / ApproachEmitter.cpp @ b71f5bca
History | View | Annotate | Download (2.07 KB)
1 | 9b5d3fff | Hui Jun Tay | /**
|
---|---|---|---|
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 | #include "ApproachEmitter.h" |
||
27 | 46daeb86 | Hui Jun Tay | #define BOM_W1 5 |
28 | #define BOM_W2 10 |
||
29 | #define BOM_W3 15 |
||
30 | #define BOM_W4 20 |
||
31 | #define BOM_W5 30 |
||
32 | 9b5d3fff | Hui Jun Tay | |
33 | using namespace std; |
||
34 | |||
35 | ApproachEmitter::ApproachEmitter(string scoutname, Sensors* sensors)
|
||
36 | : Behavior(scoutname, "Approach Emitter", sensors) {
|
||
37 | name = scoutname; |
||
38 | scout_pos = new pos;
|
||
39 | } |
||
40 | |||
41 | void ApproachEmitter::run() {
|
||
42 | b71f5bca | Yuyang (Misty) Guo | ROS_INFO("BOM Main Running");
|
43 | 8ae3771a | Yuyang (Misty) Guo | BomReadings bomR; |
44 | ac55b507 | Yuyang (Misty) Guo | int r_weighted, l_weighted;
|
45 | int speed = 20; |
||
46 | 8ae3771a | Yuyang (Misty) Guo | vector<uint32_t> r; |
47 | vector<uint32_t> s; |
||
48 | 2380e2a4 | Yuyang (Misty) Guo | while (ok()) {
|
49 | 8ae3771a | Yuyang (Misty) Guo | bomR = bom->query(); |
50 | r = bomR.readings; |
||
51 | s = bomR.senders; |
||
52 | b71f5bca | Yuyang (Misty) Guo | ROS_INFO("BOM Main Running");
|
53 | ac55b507 | Yuyang (Misty) Guo | if (accumulate(r.begin(), r.end(), 0)) { |
54 | b71f5bca | Yuyang (Misty) Guo | for (int i=0; i<10; ++i) { |
55 | ROS_INFO("BOM %d reading is %d sender is %d", i, r[i], s[i]);
|
||
56 | } |
||
57 | |||
58 | //motors->set_sides(min(r_weighted+speed, 100),
|
||
59 | // min(l_weighted+speed, 102), MOTOR_PERCENT);
|
||
60 | ac55b507 | Yuyang (Misty) Guo | } |
61 | 2380e2a4 | Yuyang (Misty) Guo | } |
62 | 9b5d3fff | Hui Jun Tay | } |