Skip to content

Commit

Permalink
add collision check
Browse files Browse the repository at this point in the history
  • Loading branch information
goktug97 committed Dec 23, 2019
1 parent 176a5ea commit ba6549c
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/dwa.c
Original file line number Diff line number Diff line change
Expand Up @@ -59,11 +59,22 @@ calculateClearanceCost(Pose pose, Velocity velocity, Point *pointCloud, Robot co
float dx;
float dy;

float x;
float y;

while (time < config.predictTime) {
pPose = motion(pPose, velocity, config.dt);

for(int i = 0; i < sizeof(pointCloud)/sizeof(pointCloud[0]); ++i) {
dx = pPose.point.x - pointCloud[i].x;
dy = pPose.point.y - pointCloud[i].y;
x = -dx * cos(pPose.yaw) + -dy * -sin(pPose.yaw);
y = -dx * sin(pPose.yaw) + -dy * cos(pPose.yaw);
if (x <= config.base.xtop &&
x >= config.base.xbottom &&
y <= config.base.yleft &&
y >= config.base.yright)
return FLT_MAX;
r = sqrt(dx*dx + dy*dy);
if (r < minr)
minr = r;
Expand Down

0 comments on commit ba6549c

Please sign in to comment.