-
Notifications
You must be signed in to change notification settings - Fork 14
/
RPathPlan.cpp
165 lines (120 loc) · 2.5 KB
/
RPathPlan.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
#include <stdio.h>
#include <stdint.h>
#include <math.h>
#include <string.h>
#include "RPathPlan.h"
#include "RPathPlan_astar.h"
#include "RPathPlan_astarDyn.h"
namespace rtk {
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
RPathPlan::RPathPlan()
{
m_map = NULL;
m_startX = -1;
m_startY = -1;
m_endX = -1;
m_endY = -1;
m_robX = -1;
m_robY = -1;
m_robT = 0;
}
RPathPlan::RPathPlan(RMap *map)
{
m_map = map;
map->getStart(&m_startX, &m_startY);
map->getEnd(&m_endX, &m_endY);
m_robX = -1;
m_robY = -1;
m_robT = 0;
}
RPathPlan::~RPathPlan()
{
}
int RPathPlan::setMap(RMap *map)
{
m_map = map;
map->getStart(&m_startX, &m_startY);
map->getEnd(&m_endX, &m_endY);
return 0;
}
int RPathPlan::getMap(RMap *map)
{
map = m_map;
return 0;
}
int RPathPlan::setStart(int x, int y)
{
m_startX = x;
m_startY = y;
return 0;
}
int RPathPlan::getStart(int *px, int *py)
{
*px = m_startX;
*py = m_startY;
return 0;
}
int RPathPlan::setEnd(int x, int y)
{
m_endX = x;
m_endY = y;
return 0;
}
int RPathPlan::getEnd(int *px, int *py)
{
*px = m_endX;
*py = m_endY;
return 0;
}
int RPathPlan::getPath(RPath *p)
{
*p = *(m_map->getPath());
return 0;
}
RPath* RPathPlan::getPath(void)
{
return m_map->getPath();
}
int RPathPlan::pathPlan(int sx, int sy, int ex, int ey)
{
m_startX = sx;
m_startY = sy;
m_endX = ex;
m_endY = ey;
return pathPlan();
}
int RPathPlan::planBeg(void)
{
printf("ERR: RPathPlan::plangBeg not implemented yet!\n");
return -1;
}
int RPathPlan::planStep(void)
{
printf("ERR: RPathPlan::plangStep not implemented yet!\n");
return -1;
}
int RPathPlan::planStepBackward(void)
{
printf("ERR: RPathPlan::planStepBackward not implemented yet!\n");
return -1;
}
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
RPathPlan* create_PathPlanObj(RPathPlanTypes pp_t)
{
RPathPlan *pp = NULL;
switch(pp_t) {
case RPP_ASTAR:
pp = new RPathPlan_astar;
break;
case RPP_ASTAR_DYNAMIC:
pp = new RPathPlan_astarDyn;
break;
default:
printf("ERR: create_PathPlanObj can not create given type: %d\n", pp_t);
break;
}
return pp;
}
}