Project

General

Profile

Statistics
| Branch: | Revision:

root / scout / libscout / src / behaviors / WH_Robot.cpp @ fe8da1b9

History | View | Annotate | Download (1.2 KB)

1
#include "WH_Robot.h"
2

    
3
/** @brief default warehouse robot constructor **/
4
WH_Robot::WH_Robot()
5
{
6
    nav_map = navigationMap("nyan");
7
    curr_task = NULL;
8
    schedule = Scheduler();
9
}
10

    
11
/** @Brief: warehouse robot constructor **/
12
WH_Robot::WH_Robot(std::string scoutname)
13
{
14
    nav_map = navigationMap(scoutname);
15
    // this probably won't work :x
16
    curr_task = NULL;
17
    schedule = Scheduler();
18
}
19

    
20
Time WH_Robot::get_wc_time(State dest)
21
{
22
    //TODO: integrate Lalitha's code
23
    return 0.0;
24
}
25

    
26
Order WH_Robot::wh_get_task()
27
{
28
    schedule.get_task(this);
29
    while (curr_task == NULL) //waits for get_task process to return a task
30
        continue;        
31
    return curr_task;    
32
}
33

    
34
int WH_Robot::exec_task(){
35
    if (curr_task == NULL)
36
    {
37
        //TODO: raise error
38
        return TASK_FAILED;
39
    }
40
    else{
41
        //TODO: do task
42
        return TASK_COMPLETED;
43
    }
44
}
45

    
46
void WH_Robot::run (){
47
    wh_get_task();
48
    bool error = (exec_task() == TASK_FAILED);
49
    if(!error)
50
    {
51
        schedule.task_complete(curr_task);
52
    }
53
    else
54
    {
55
        schedule.task_failed(curr_task);
56
    }
57
    curr_task = NULL;
58
}
59

    
60

    
61
int main(){
62
    return 0;
63
}