Closed tinmodeHuang closed 3 years ago
Sampling is applied in the ConfigWithEase
scenario generation.
In these two spots sampling is being applied:
If you want a deterministic scenario, I would recommend you to overwrite the def position(self, world):
function with one that does not make use of sampling and that has no call to self.ds()
. However, in terms of training a behavior policy a varying number of vehicles might avoid overfitting.
I have already checked the scenario generation quite many times, the maximum number of agents generated shoule be 8 by calculating instead of 9, I wonder what was omitted
how did you calculate this? I think only the rear point of the vehicle is used in the simple scenario generation (config with ease).
For more elaborate uses I would recommend using the ConfigurableScenarioGeneration.
the function position()
of theLaneCorridorConfig
class define calculation of the number of agents to generate.
for left lane, self._s_min, self._s_max = 3, 44, with the minimum spacing self._ds_min=7
, the number of agents which can be generated in the range (3, 44) is 5. (44-3)//7=5
for right lane, self._s_min, self._s_max = 3, 26, with the minimum spacing self._ds_min=7
, the number of agents which can be generated in the range (3, 26) is 5. (26-3)//7=3
I assume you are talking about https://github.com/bark-simulator/bark-ml/blob/b9b42ab8124ab31781573b6a804e762271ca4ce6/bark_ml/environments/blueprints/merging/merging.py#L65
Have a look at the values in the blueprint. The ranges have been slightly changed in the latest push to make the traffic more realitistic.
Yeap, the value of sef._ds_min
above is from ds_min
in dense
mode
So we have 40//7=5
and 20//7=2
. each can have a starting position at zero.
Thus, 5+1
and 2+1
equals 9
. So I think this should be correct, but in case you find a fix for it can also create a pull request.
here starting positions is at self._s_min
, namely three, this is reason why the subtracter is 3 in the expression (26-3)//7=3
instead of zero
def position(self, world):
...
if self._current_s == None:
self._current_s = np.random.uniform(self._s_min, self._ds_max)
xy_point = GetPointAtS(centerline, self._current_s)
angle = GetTangentAngleAtS(centerline, self._current_s)
if self._current_s > self._s_max:
return None
self._current_s += self.ds()
return (xy_point.x(), xy_point.y(), angle)
I cannot follow your calculation exactly. However, does it really matter if there are 8 or 9 vehicles generated? Traffic also varies in reality by number and order. To trace the number during training and evaluation you could implement a vehicle count evaluator.
Will close this for now.
a road with two lane, self._ds_min, self._ds_max = 7, 12 for left lane, self._s_min, self._s_max = 3, 44 for other one, self._s_min, self._s_max = 3, 26 there should are only 8 agents generated in observation of the world, but it is learned from the simplified output printed that 9 agents were generated.
I have been confused about it after checked out the
config_with_ease.py
to generate agents several times. I'll appreciate it if you could make it clear.