root / scout / libscout / src / BehaviorProcess.cpp @ c467de4f
History | View | Annotate | Download (2.72 KB)
1 | d140fd71 | Yuyang | |
---|---|---|---|
2 | c239584b | Priya | /**
|
3 | * Copyright (c) 2011 Colony Project
|
||
4 | *
|
||
5 | * Permission is hereby granted, free of charge, to any person
|
||
6 | * obtaining a copy of this software and associated documentation
|
||
7 | * files (the "Software"), to deal in the Software without
|
||
8 | * restriction, including without limitation the rights to use,
|
||
9 | * copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||
10 | * copies of the Software, and to permit persons to whom the
|
||
11 | * Software is furnished to do so, subject to the following
|
||
12 | * conditions:
|
||
13 | *
|
||
14 | * The above copyright notice and this permission notice shall be
|
||
15 | * included in all copies or substantial portions of the Software.
|
||
16 | *
|
||
17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||
18 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
|
||
19 | * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||
20 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
||
21 | * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||
22 | * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||
23 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
||
24 | * OTHER DEALINGS IN THE SOFTWARE.
|
||
25 | */
|
||
26 | |||
27 | /**
|
||
28 | * @file Behavior.cpp
|
||
29 | * @brief A wrapper that executes PriyaBehavior as an executable.
|
||
30 | *
|
||
31 | * Should be auto-generated in the future.
|
||
32 | *
|
||
33 | * @author Colony Project, CMU Robotics Club
|
||
34 | * @author Alex Zirbel
|
||
35 | */
|
||
36 | |||
37 | #include "BehaviorProcess.h" |
||
38 | d140fd71 | Yuyang | #include "Sensors.h" |
39 | #include "assert.h" |
||
40 | c239584b | Priya | |
41 | int main (int argc, char **argv) |
||
42 | { |
||
43 | string scoutname = ""; |
||
44 | int behavior_num;
|
||
45 | 31be19a6 | Priya | string behavior_name = ""; |
46 | c239584b | Priya | |
47 | // Running with no arguments only supports one scout. Check in case
|
||
48 | // the user meant to specify a scout in the arguments.
|
||
49 | c467de4f | Yuyang Guo | if (argc < 2) |
50 | c239584b | Priya | { |
51 | cout << "You have started this behavior in hardware mode." << endl
|
||
52 | << "To start in software mode, use: " << argv[0] |
||
53 | c467de4f | Yuyang Guo | << " <behavior#> <scoutname> " << endl;
|
54 | c239584b | Priya | } |
55 | else
|
||
56 | { |
||
57 | // Use the provided scoutname for simulator messages
|
||
58 | c467de4f | Yuyang Guo | //scoutname = argv[1];
|
59 | behavior_num = atoi(argv[1]);
|
||
60 | if (argc == 3) { |
||
61 | scoutname = argv[2];
|
||
62 | } |
||
63 | c239584b | Priya | |
64 | c467de4f | Yuyang Guo | ros::init(argc, argv, scoutname + "Behavior");
|
65 | d140fd71 | Yuyang | // one Sensor instance per-class
|
66 | Sensors* sensors = new Sensors(scoutname);
|
||
67 | faa11f08 | Priya | BehaviorList* list = new BehaviorList();
|
68 | vector<behavior_func> behavior_list = list->behavior_list; |
||
69 | c239584b | Priya | if (behavior_num < (int)behavior_list.size()) |
70 | { |
||
71 | faa11f08 | Priya | Behavior* b = behavior_list[behavior_num](scoutname, sensors); |
72 | b->run(); |
||
73 | c239584b | Priya | } |
74 | else
|
||
75 | { |
||
76 | cout << "There is no behavior number" << behavior_num
|
||
77 | << ". There are only " << (int)behavior_list.size() << "behaviors." |
||
78 | << endl; |
||
79 | } |
||
80 | |||
81 | delete list;
|
||
82 | } |
||
83 | |||
84 | return 0; |
||
85 | } |