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

Commit 7b90062

Browse files
committed
gi
1 parent e5a6eab commit 7b90062

File tree

1 file changed

+46
-2
lines changed

1 file changed

+46
-2
lines changed

src/rrt/2dplane/PlaneStateSpace.hpp

Lines changed: 46 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,54 @@ 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, (float) rand() / RAND_MAX);
37-
float logitY = logit(goalBias, (float) rand() / RAND_MAX);
36+
float rand1 = (float) rand() / RAND_MAX;
37+
float rand2 = (float) rand() / RAND_MAX;
3838
float offsetY = 0;
3939
float offsetX = 0;
40+
float logitX;
41+
float logitY;
42+
43+
if (rand1 < .5) {
44+
if (rand1 < (float) goalState.x() / width()) {
45+
logitX = logit(goalBias, rand1);
46+
offsetX = goalState.x() * logitX;
47+
} else {
48+
logitX = -1 * (logit(goalBias, rand1));
49+
offsetX = goalState.x() * logitX;
50+
}
51+
} else {
52+
if (rand1 > (float) (width() - goalState.x())/width()) {
53+
logitX = logit(goalBias, rand1);
54+
offsetX = goalState.x() * logitX;
55+
} else {
56+
logitX = -logit(goalBias, rand1);
57+
offsetX = goalState.x() * logitX;
58+
}
59+
}
60+
61+
if (rand2 < .5) {
62+
if (rand2 < (float) goalState.y() / height()) {
63+
logitY = logit(goalBias, rand2);
64+
offsetY = goalState.y() * logitY;
65+
} else {
66+
logitY = -1 * logit(goalBias, rand2);
67+
offsetY = goalState.y() * logitY;
68+
}
69+
} else {
70+
if (rand2 > (float) (height() - goalState.y())/height()) {
71+
logitY = logit(goalBias, rand2);
72+
offsetY = goalState.y() * logitY;
73+
} else {
74+
logitY = -logit(goalBias, rand2);
75+
offsetY = goalState.y() * logitY;
76+
}
77+
}
78+
79+
80+
81+
// float logitX = logit(goalBias, rand1);
82+
// float logitY = logit(goalBias, rand2);
83+
4084

4185
// Scale X value based on distance from border
4286
if (logitX > 0) {

0 commit comments

Comments
 (0)