-
Notifications
You must be signed in to change notification settings - Fork 47
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
scan API restructure #3
Comments
I do agree that the parameters with their default parameters are messy, this is "historical" since the whole thing emerged from a single python script to simulate the velodyne. Getting rid of this is definitely a worthy task, but you are right. one reason for not passing the obj itself is the fact that this code can be called from other python scripts that just use the active camera as the scanner. Using some kind of inheritance for sensor parameters however seems to be very useful ProposalCreate a Sensor class that combines the default parameters and has a constructor that takes a Camera object and copies the relevant data into the sensor object. class Sensor(object):
max_distance = 120
def __init__(self, blender_object):
self.max_distance = blender_object.max_distance
class Velodyne(Sensor):
rotation_speed = 15
angle_resolution = 0.1728
...
...
def __init__(self, blender_object):
Sensor.__init__(self, blender_object)
self.rotation_speed = blender_object.rotation_speed
self.angle_resolution = blender_object.angle_resolution
...
...
...
sensor = Velodyne(obj)
scan_advanced(sensor,'test.evd', Matrix()) |
I think copying from Using your proposal, if you wished to create a "sensor" without modifying the active camera, you could do:
But with mine the only difference would be
Perhaps I'll code it up and if you find any use cases that need the separate |
Hmm there could theoretically be a scenario where the sensor objects store information that is not stored as blender properties. For example: If a sensor is it's own object it could have save/load methods to store the sensor configuration in a file. Thinking further into the future i think the addProperties should be done by the Sensor object too. That way the default values would only be held in one place. But we can go with your approach for now and check if the requirements i mentioned are really an issue or not |
Well currently laser configurations are stored in each object, and that would remain the case. So different sensors could be represented by different cameras in the scene. If you wanted to be able to load parameters from a file into a blender object, it'd be easy to write an operator to do it. As far as further into the future goes, I think it makes sense for the I'll get started on the refactoring and see what issues I run into on the way :) |
I know, storing the sensor properties in the blender file greatly simplifies the distribution of scans without having to send the whole scan result. Well then it's decided. :) |
Problem
There are a lot of parameters to the scan functions
scan_advanced
andscan_range
. This makes code harder to read and maintain and because each parameter has a default value led to some bugs where parameters were accidentally missing.An example function call is:
Possible Solution
As can be seen above, most of the parameters are from the sensor object
obj
. Why not just pass this as a parameter instead? Thescan_advanced
interface would then become something likePotential Problems
I'm guessing that the reason for the explicit parameters was that so that
scan_advanced
could be run without having a sensor object. A workaround for this in the proposed interface would be wrapping parameters in a dummy class.Other than testing, for which the dummy class is probably ok, I can't think of any use cases that require the parameters to be separated as they are.
Conclusion
If think that the parameters should be left as they are, feel free to close this issue. If, however, you're happy with the proposal, I'll go ahead and do it, and submit the patch as a pull request.
The text was updated successfully, but these errors were encountered: