Project

General

Profile

Revision bebd9bcb

IDbebd9bcb180be4f88fc750caa192aaf49f27544c
Parent 76cefba1
Child a4378953

Added by Leon about 12 years ago

WH_Robot preliminary code, untested

View differences:

scout/libscout/src/behaviors/WH_Robot.cpp
1
#include "WH_Robot.h"
2

  
3
/** @brief default warehouse robot constructor **/
4
WH_Robot::WH_Robot()
5
{
6
    curr_task = NULL;
7
}
8

  
9
/** @Brief: warehouse robot constructor **/
10
WH_Robot::WH_Robot(std::string scoutname)
11
{
12
    nav_map = navigationMap(scoutname);
13
    curr_task = NULL;
14
    schedule = Scheduler();
15
}
16

  
17
Time WH_Robot::get_wc_time(State dest)
18
{
19
    //TODO: integrate Lalitha's code
20
    return 0.0;
21
}
22

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

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

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

  
57

  
58
int main(){
59
    return 0;
60
}
scout/libscout/src/behaviors/WH_Robot.h
1
#ifndef _WH_ROBOT_
2
#define _WH_ROBOT_
3

  
4
#include <cstdlib>
5
#include <string>
6

  
7
//#include "../Behavior.h" //TODO: make wh_robots into Behaviors
8
//#include "navigationMap.h"
9
#include "Scheduler.h" //TODO: uncomment once these are in the repo
10
#include "../helper_classes/Order.h"
11

  
12
#define TASK_COMPLETED 0
13
#define TASK_FAILED -1
14

  
15
typedef double Time;
16
// a single number representing a node's number
17
typedef int State;
18

  
19
class WH_Robot{
20

  
21
    public:
22
        WH_Robot();
23
        WH_Robot(std::string scoutname);
24
        void run();
25
     
26
    private:
27
        Time get_wc_time(State dest);
28
        Order wh_get_task();
29
        int exec_task();
30
        
31
        Order curr_task;
32
        //navigationMap nav_map;
33
        Scheduler schedule;
34
};
35

  
36
#endif

Also available in: Unified diff