@@ -102,6 +102,79 @@ std::list<gridNode_t> SpiralSTC::spiral(std::vector<std::vector<bool> > const& g
102
102
return pathNodes;
103
103
}
104
104
105
+
106
+ // /**
107
+ // * Uses a wavefront algorithm to determine the nearest open verticies/corner on the grid.
108
+ // * The mountain pattern (bourstrophedon) should idealy begin from the corner of the grid.
109
+ // * @param grid internal map representation
110
+ // * @param corner_list Output map in which all cells except the corners are marked as visited (true).
111
+ // * @param start_x The x position of the corner to begin search
112
+ // * @param start_y The y position of the corner to begin search
113
+ // */
114
+ // void findNearestOpenVerticies(std::vector<std::vector<bool>> const& grid,
115
+ // std::vector<std::vector<bool>>& corner_list,
116
+ // int start_x,
117
+ // int start_y)
118
+ // {
119
+ // std::queue<std::tuple<int, int>> nodes;
120
+ // int bound_x = -1, bound_y = -1;
121
+ // bool processed[grid.size()][grid[0].size()] = {false}; // store node indicies which are already processed
122
+ // nodes.push({start_x, start_y}); // add first node to queue
123
+
124
+ // while(!nodes.empty()) {
125
+
126
+ // // get current node
127
+ // int x = std::get<0>(nodes.front());
128
+ // int y = std::get<1>(nodes.front());
129
+ // nodes.pop();
130
+
131
+ // // check node
132
+ // // To accomodate box case such as:
133
+ // // 0000000000000
134
+ // // 0011111111100
135
+ // // 0011000001100
136
+ // // 0011000001100
137
+ // // 0011111111100
138
+ // // 0000000000000
139
+ // if ((bound_x == -1 || bound_y == -1) && grid[x][y] == eNodeVisited) {
140
+ // bound_x == x;
141
+ // bound_y = y;
142
+ // } else {
143
+ // if((x < bound_x || y < bound_y) && grid[x][y] == eNodeVisited) {
144
+ // bound_x = dmin(x, bound_x);
145
+ // bound_y = dmin(y, bound_y);
146
+ // }
147
+ // if (grid[x][y] == eNodeOpen) {
148
+ // if (bound_x == -1 || bound_y == -1) {
149
+ // }
150
+ // corner_list[x][y] = eNodeOpen;
151
+ // return;
152
+ // }
153
+ // }
154
+
155
+
156
+ // // If node is not open, add unprocessed adjacent nodes to queue
157
+ // if (x+1 < grid.size() && processed[x+1][y] == false) {
158
+ // nodes.push({x+1, y});
159
+ // processed[x+1][y] == true;
160
+ // } // East
161
+ // if (x-1 > 0 && processed[x-1][y] == false) {
162
+ // nodes.push({x-1, y});
163
+ // processed[x-1][y] == true;
164
+ // } // West
165
+ // if (y+1 < grid[0].size() && processed[x][y+1] == false) {
166
+ // nodes.push({x, y+1});
167
+ // processed[x][y+1] == true;
168
+ // } // North
169
+ // if (y-1 > 0 && processed[x][y-1] == false) {
170
+ // nodes.push({x, y-1});
171
+ // processed[x][y-1] == true;
172
+ // } // South
173
+
174
+ // }
175
+
176
+ // }
177
+
105
178
std::list<Point_t> SpiralSTC::spiral_stc (std::vector<std::vector<bool > > const & grid,
106
179
Point_t& init,
107
180
int &multiple_pass_counter,
@@ -135,6 +208,30 @@ std::list<Point_t> SpiralSTC::spiral_stc(std::vector<std::vector<bool> > const&
135
208
#endif
136
209
137
210
pathNodes = SpiralSTC::spiral (grid, pathNodes, visited); // First spiral fill
211
+ // std::list<Point_t> map_verticies;
212
+ // map_verticies.push_back({0, 0});
213
+ // map_verticies.push_back({nCols, 0});
214
+ // map_verticies.push_back({nCols, nRows});
215
+ // map_verticies.push_back({0, nRows});
216
+ // std::vector<std::vector<bool>> corner_list(nCols, std::vector<bool>(nRows, eNodeVisited));
217
+ // findNearestOpenVerticies(grid, corner_list, 0, 0);
218
+ // findNearestOpenVerticies(grid, corner_list, 0, nRows-1);
219
+ // findNearestOpenVerticies(grid, corner_list, nCols-1, 0);
220
+ // findNearestOpenVerticies(grid, corner_list, nCols-1, nRows-1);
221
+
222
+ // for (int i = 0; i < nRows; ++i)
223
+ // {
224
+ // for (int j = 0; j < nCols; ++j)
225
+ // {
226
+ // std::cout << grid[i][j] << ' ';
227
+ // }
228
+ // std::cout << std::endl;
229
+ // }
230
+
231
+ // if (a_star_to_open_space(grid, pathNodes.back(), 1, corner_list, map_verticies, pathNodes)) {
232
+ // ROS_INFO("A_star_to_open_space is resigning");
233
+ // }
234
+
138
235
std::list<Point_t> goals = map_2_goals (visited, eNodeOpen); // Retrieve remaining goalpoints
139
236
// Add points to full path
140
237
std::list<gridNode_t>::iterator it;
@@ -191,6 +288,7 @@ std::list<Point_t> SpiralSTC::spiral_stc(std::vector<std::vector<bool> > const&
191
288
#endif
192
289
193
290
// Spiral fill from current position
291
+ // TODO: Convert to U-turn pattern
194
292
pathNodes = spiral (grid, pathNodes, visited);
195
293
196
294
#ifdef DEBUG_PLOT
0 commit comments