mgschwan/blensor — Issue #3: scan API restructure 
Author: petermoz
Created: 2012-03-07 11:51:51+00:00
State: open

### Problem
There are a lot of parameters to the scan functions ``scan_advanced`` and ``scan_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:

blensor.blendodyne.scan_advanced( angle_resolution=obj.velodyne_angle_resolution,
max_distance=obj.velodyne_max_dist, start_angle=obj.velodyne_start_angle,
end_angle=obj.velodyne_end_angle, noise_mu = obj.velodyne_noise_mu,
noise_sigma=obj.velodyne_noise_sigma, add_blender_mesh=obj.add_scan_mesh,
add_noisy_blender_mesh=obj.add_noise_scan_mesh,
rotation_speed = obj.velodyne_rotation_speed, evd_file=filename,
world_transformation = world_transformation )

### 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? The ``scan_advanced`` interface would then become something like

def scan_advanced(sensor, evd_file, world_transform):

### Potential 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.

class Namespace(object):
pass

sensor = Namespace()
sensor.velodyne_angle_resolution = 0.1
sensor.max_distance = 120
...
scan_advanced(sensor, 'test.evd', Matrix())

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.