Statistics
| Branch: | Revision:

scoutos / scout / libscout / src / BehaviorProcess.cpp @ d140fd71

History | View | Annotate | Download (2.62 KB)

1

    
2
/**
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
#include "Sensors.h"
39
#include "assert.h"
40

    
41
int main (int argc, char **argv)
42
{
43
    string scoutname = "";
44
    int behavior_num;
45
    string behavior_name = "";
46

    
47
    // Running with no arguments only supports one scout. Check in case
48
    // the user meant to specify a scout in the arguments.
49
    if (argc < 3)
50
    {
51
        cout << "You have started this behavior in hardware mode." << endl
52
             << "To start in software mode, use: " << argv[0]
53
             << " <scoutname> <behavior#> " << endl;
54
    }
55
    else
56
    {
57
        // Use the provided scoutname for simulator messages
58
        scoutname = argv[1];
59
        behavior_num = atoi(argv[2]);
60

    
61
        ros::init(argc, argv, scoutname + "_behavior");
62
        // one Sensor instance per-class
63
        Sensors* sensors = new Sensors(scoutname);
64
        BehaviorList* list = new BehaviorList(scoutname, sensors);
65
        vector<Behavior*> behavior_list = list->behavior_list;
66
        if (behavior_num < (int)behavior_list.size())
67
        {
68
            (behavior_list[behavior_num])->run();
69
        }
70
        else
71
        {
72
            cout << "There is no behavior number" << behavior_num
73
              << ". There are only " << (int)behavior_list.size() << "behaviors."
74
              << endl;
75
        }
76

    
77
        delete list;
78
    }
79

    
80
    return 0;
81
}