Skip to content
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

Refactoring Data-tools #21

Merged
merged 27 commits into from
Aug 22, 2019
Merged

Conversation

matthewspear
Copy link
Collaborator

Working on refactoring data-tool, modernised the C++ usage, remove repeated and unused code.

- clear unused imports
- adjust formatting
- modernise code using auto
- tidy up command-line outputs
Based on google styleguide
- usage of auto when creating new objects
- usage of empty() when checking string length
- changed name to better convey what the function does
- extracted into dataset_utils header
- usage of auto when creating new objects
- usage of empty() when checking string length
- inline checkRequirements function to allow header only usage
- add decimal RegexPattern
- move parameter values into class
- usage of auto when creating new objects
- usage of auto when creating new objects
- usage of empty() when checking string length
- replace plain regex with RegexPattern paramters
Changing `../../dataset-tools/include/...` to just `include/...` for main DatasetReader classes
- usage of auto when creating new objects
- tidy plain regex with RegexPattern parameters
- usage of auto when creating new objects
- usage of empty() when checking string length
- tidy plain regex with RegexPattern parameters
- refactor to use checkRequirement util function
Created a generalised function which can be used to make a grey sensor with reasonable default settings. 

Function allows for additional changes to be made on top of the generalised sensor, reducing the general setup of the sensors.
- nest make functions in slambench::io namespace due to common use of classes within namespace
- extract disparity parameters and types into header files of dataset reader classes
@matthewspear matthewspear marked this pull request as ready for review August 13, 2019 17:10
@matthewspear
Copy link
Collaborator Author

Summary

  • Refactored all of DatasetReaders
  • Usage of RegexPattern in DatasetReaders
  • Added checkRequirements function
  • Added makeSensor functions

@matthewspear
Copy link
Collaborator Author

One part I am not so happy with is when a CameraSensor doesn't use Distortion the make camera function:

inline CameraSensor* makeRGBSensor(const Sensor::pose_t &pose,
                                      const CameraSensor::intrinsics_t &intrinsics,
                                      const CameraSensor::distortion_coefficients_t &distortion);

The function can still be used but with {} as the distortion parameter and after creation the sensor can be defined to have no distortion:

auto rgb_sensor = makeRGBSensor(pose, intrinsics, {});
rgb_sensor->Rate = 1;
rgb_sensor->DistortionType = CameraSensor::NoDistortion;

Just think there might be a nicer way to do this without just making an additional function in dataset_utils.h and some causion might need to be taken due to undefined behaviour of how the distortion parameter is initalised with nothing even though the underlying type is float[5].

@matthewspear
Copy link
Collaborator Author

Another thing to discuss is the opinion to combine makeGreySensor and makeRGBSensor into a makeCameraSensor possibly with a colour parameter since the two function are pretty much the same beyond the colour components - although this might just over complicate it!

@matthewspear matthewspear changed the title WIP: Refactoring Data-tools Refactoring Data-tools Aug 13, 2019
@matthewspear
Copy link
Collaborator Author

8d3090bb6687f5f0d6677bb062a13860  testing_master/rgbd_dataset_freiburg1_xyz.slam
c230ffe7f2d1c4f14b32b645e208738e  testing_dataset_tools/rgbd_dataset_freiburg1_xyz.slam

97ddd483afcab4b13cc39cedf68506f8  testing_master/rgbd_bonn_balloon.slam
bbcaf1513e1661a0dad2c92762b2f268  testing_dataset_tools/rgbd_bonn_balloon.slam

dfa1b40bf36f83ed9049a2436c507713  testing_master/artificial.slam
dfa1b40bf36f83ed9049a2436c507713  testing_dataset_tools/artificial.slam

cca2ec46bd20d265ac85cee75e683f58  testing_master/living_room_traj2_loop.slam
e12b4e377ae3de47df1e513eaa6523a1  testing_dataset_tools/living_room_traj2_loop.slam

43754c7401879e02aa903270e7d4936f  testing_master/MH_01_easy.slam
6553eb6a2468612614d17a863e16e2d4  testing_dataset_tools/MH_01_easy.slam

Tried checksum-ing comparision of slamfiles between master to dataset-tools but they come out different. This could be down to a number of reasons. Some of the names of the sensors has been changed across the various targets.

@matthewspear
Copy link
Collaborator Author

Tested each using pangolin-loader, everything seems ok except for EUROCMAV one:

Parameter input assigned value ../testing_dataset_tools/MH_01_easy.slam
*** Duplicated long option replaced: 'Grey-intrinsics-parameters'

@mihaibujanca
Copy link
Owner

While I agree with spaces over tabs, I feel like it's making it really hard to look through the changes, which also makes it likely that it will take longer for Bruno to review and integrate this into the main repo - assuming Bruno would be fine with the change to spaces in the first place.

I think for that reason it may be worth sticking to the current spacing method

@mihaibujanca
Copy link
Owner

One part I am not so happy with is when a CameraSensor doesn't use Distortion the make camera function:

inline CameraSensor* makeRGBSensor(const Sensor::pose_t &pose,
                                      const CameraSensor::intrinsics_t &intrinsics,
                                      const CameraSensor::distortion_coefficients_t &distortion);

The function can still be used but with {} as the distortion parameter and after creation the sensor can be defined to have no distortion:

auto rgb_sensor = makeRGBSensor(pose, intrinsics, {});
rgb_sensor->Rate = 1;
rgb_sensor->DistortionType = CameraSensor::NoDistortion;

You could set the default distortion parameter to be empty. Then, inside your makeRGBSensor, check if the distortion parameter is still empty and set the DistortionType to NoDistortion accordingly

@matthewspear
Copy link
Collaborator Author

You could set the default distortion parameter to be empty. Then, inside your makeRGBSensor, check if the distortion parameter is still empty and set the DistortionType to NoDistortion accordingly

Is there any case where that causes problems, if a given set of distortion parameters were actually an empty set of 0'd values?

@mihaibujanca
Copy link
Owner

You could set the default distortion parameter to be empty. Then, inside your makeRGBSensor, check if the distortion parameter is still empty and set the DistortionType to NoDistortion accordingly

Is there any case where that causes problems, if a given set of distortion parameters were actually an empty set of 0'd values?

I doubt so. If a dataset provides information about lens distortion, then it has to be included. If no distortion information is available, the most sensible option seems to be assuming no distortion.

@matthewspear
Copy link
Collaborator Author

https://github.com/Matthewspear/slambench2/tree/data-tools-builder – Drafted the API in a seperate branch, implemented TUM as an example, feels like it reinvents the wheel (or sensor really).

It can be tidied up, was trying to make it completely generic so one of the template parameters can be removed.

@mihaibujanca
Copy link
Owner

Looks pretty good, I haven't tried building the datasets with the latest commits yet.
I think given that many things are standard, we could also add defaults in sensor_builder, where we set the most common things to certain values (e.g in most cases, the frame rate is 30, each of the sensors has a name matching the sensor type, the frame size is (640,480) etc".

Similar to how we have
sensor->Description = description_.empty() ? "Default description" : description_;,

- added defaults to SensorBuilder subclasses
- made SensorBuilder constructor protected for avoid implementation
Copy link
Owner

@mihaibujanca mihaibujanca left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice job! Had a few comments - some of them are admittedly issues not introduced in this PR, but it's not much work to change them and since we're refactoring this, it's worth fixing thm

- extract name into separate parameters for builders
- use sensor size to set index in ICLNUIM
- usage of nullptr over NULL in ICLNUIM
Half complete refactor, easier to revert and complete later and have input from library author on implementation details.
Having two methods to add distortion complicates the usage of the API, so it was removed.
@mihaibujanca mihaibujanca merged commit 10006f2 into mihaibujanca:master Aug 22, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants