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

Commit e5a6eab

Browse files
authored
Merge pull request #1 from Jason27chan/randomBiasState
Random bias state
2 parents d17729f + 371876c commit e5a6eab

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

src/rrt/2dplane/PlaneStateSpace.hpp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -33,27 +33,27 @@ class PlaneStateSpace : public StateSpace<POINT_CLASS> {
3333
*/
3434
POINT_CLASS randomBiasState(const POINT_CLASS& goalState, float goalBias) const {
3535
// Generates random value based on goalBias
36-
float logitX = logit(goalBias, drand48() * .8 + .1);
37-
float logitY = logit(goalBias, drand48() * .8 + .1);
36+
float logitX = logit(goalBias, (float) rand() / RAND_MAX);
37+
float logitY = logit(goalBias, (float) rand() / RAND_MAX);
3838
float offsetY = 0;
3939
float offsetX = 0;
4040

4141
// Scale X value based on distance from border
4242
if (logitX > 0) {
43-
offsetX = (width() - goalState.x()) / log(9) * logitX;
43+
offsetX = (width() - goalState.x()) * logitX;
4444
} else if (logitX < 0) {
45-
offsetX = goalState.x() / log(9) * logitX;
45+
offsetX = goalState.x() * logitX;
4646
}
4747

4848
// Scale Y value based on distance from border
4949
if (logitY > 0) {
50-
offsetY = (height() - goalState.y()) / log(9) * logitY;
50+
offsetY = (height() - goalState.y()) * logitY;
5151
} else if (logitY < 0) {
52-
offsetY = goalState.y() / log(9) * logitY;
52+
offsetY = goalState.y() * logitY;
5353
}
5454

55-
int randX = goalState.x() + offsetX, width();
56-
int randY = goalState.y() + offsetY, height();
55+
int randX = goalState.x() + offsetX;
56+
int randY = goalState.y() + offsetY;
5757
return POINT_CLASS(randX, randY);
5858
}
5959

0 commit comments

Comments
 (0)