-
Notifications
You must be signed in to change notification settings - Fork 103
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
External sampler does not work with object positioning #294
Comments
Hi Arjan! This is definitely a gap in the current Scenic functionality, but I think there might be a workaround that's not too difficult to implement for now. I would recommend creating a subclass ExternalParameter which wraps the region and who's |
Hi @Eric-Vin, What do you mean by "subclass Something along the lines of: class Values(ExternalParameter):
def __init__(self, *values: Any):
super().__init__()
self._values = values
def sampleGiven(self, value):
if self.sampler is None:
return self._values[0]
return super().sampleGiven(value) Just simply return the first option if no samples have been generated by our custom |
Hi Arjan, the Stepping back a bit, if all you want is to make sure you systematically iterate through all of the regions (rather than picking one at random), VerifAI's grid sampler does that. For example: param verifaiSamplerType = "grid"
ego = new Object in VerifaiOptions([Region1, Region2]) will pick from dotmap import DotMap
param verifaiSamplerType = "grid"
param verifaiSamplerParams = DotMap(repeat=True)
ego = new Object in VerifaiOptions([Region1, Region2]) Unfortunately this doesn't work right now (the repeat flag is ignored and VerifAI raises an exception after both options have been exhausted) due to a bug in the grid sampler which I only just noticed. So we'll work on fixing that too :) |
The VerifAI solution @dfremont suggested should now function correctly (with latest code on the VerifAI repo's main branch)! |
@amolenaar Eric pushed a temporary fix for the assertion failure you were getting above: you'll likely get a warning instead, which you can ignore. If the fix doesn't solve your problem, please feel free to reopen this issue. |
System Details
Detailed Description
For our use case (railway) we want to make sure we create samples in different regions: plains, tunnel, forest area.
To make this work we created an external sampler. Although we can use the external sampler to define values for arbitrary parameters (defined with the
with
keyword), we cannot assign a region (on
/in
keyword) from our distribution.It would be really nice if we can use external parameters to define regions.
For comparison, this is a working scenario:
While this scenario fails:
Steps To Reproduce
Have a look at a sample repository I created: https://github.com/amolenaar/scenic-external-sampler
You can easily set up an environment with Poetry:
All tests succeed, except test_regions_with_externally_sampled_distribution. This test tries to set a region from an external parameter. It fails, since the external sampler has not been initialized yet.
It shows a stack trace:
Issue Submission Checklist
The text was updated successfully, but these errors were encountered: