Skip to content
This repository was archived by the owner on Mar 16, 2024. It is now read-only.

Commit da5cbff

Browse files
committed
maxDist adjustments
1 parent 7707a9d commit da5cbff

File tree

2 files changed

+9
-6
lines changed

2 files changed

+9
-6
lines changed

src/2dplane/ObstacleGrid.cpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@
22
#include <stdlib.h>
33
#include <iostream>
44

5-
#define SQRT2 1.41421356237
6-
75
using namespace Eigen;
86
using namespace std;
97

@@ -32,8 +30,8 @@ float ObstacleGrid::nearestObstacleDist(const Vector2f &state, float maxDist) co
3230
//x and y are the indices of the cell that state is located in
3331
float x = (state.x() / (_width / _discretizedWidth));
3432
float y = (state.y() / (_height / _discretizedHeight));
35-
int xSearchRad = maxDist * _discretizedWidth / (_width * SQRT2);
36-
int ySearchRad = maxDist * _discretizedHeight / (_height * SQRT2);
33+
int xSearchRad = maxDist * _discretizedWidth / _width;
34+
int ySearchRad = maxDist * _discretizedHeight / _height;
3735
//here we loop through the cells around (x,y) to find the minimum distance of the point to the nearest obstacle
3836
for (int i = x - xSearchRad; i <= x + xSearchRad; i++) {
3937
for (int j = y - ySearchRad; j <= y + ySearchRad; j++) {

src/2dplane/ObstacleGrid.hpp

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,13 @@ class ObstacleGrid {
1414

1515
Eigen::Vector2i gridSquareForLocation(const Eigen::Vector2f &loc) const;
1616

17-
// finds the distance from state to its neareset obstacle. Only searches up to maxDist around
18-
// state so as to not waste time checking far away and irrelevant obstacles.
17+
/**
18+
* Finds the distance from state to its neareset obstacle. Only searches up to maxDist around
19+
* state so as to not waste time checking far away and irrelevant obstacles.
20+
*
21+
* @param state The location to search with respect to for the nearest obstacle dist
22+
* @param maxDist The maximum vertical and horizontal distance from state to search for obstacles
23+
*/
1924
float nearestObstacleDist(const Eigen::Vector2f &state, float maxDist) const;
2025
void clear();
2126
bool &obstacleAt(int x, int y);

0 commit comments

Comments
 (0)