Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Hi! I am trying to use open_vins as a VIO solution on a drone and noticed that open_vins outputs a lot of stuff to the terminal. Said another way, it floods the terminal with print statements making it difficult to see my own codes prints.
I think it might be a good idea to add the ability to change the verbosity level of open_vins so that different prints can be enabled at different times. For example we could set open_vins into "silent" mode where all prints are silenced, into "error" mode where only error messages are printed or into debug mode where all debug messages are printed.
I have implemented various levels of verbosity for open_vins and was hoping to get that merged into the repo if possible. Also sorry if this is not the correct process for getting code into the main repo. This is my first time contributing to an open source project.
How my changes work
Instead of doing
printf(...)
in the code you could use of print functions defined in "ov_core/src/utils/print.h":PRINT_ALL(...)
PRINT_DEBUG(...)
PRINT_INFO(...)
PRINT_WARNING(...)
PRINT_ERROR(...)
where the arguments into the print functions are identical to whatever you would use for
printf
(aka just replaceprintf
with the appropriate print function with no other changes)You can then change the verbosity level by doing:
ov_core::Printer::setPrintLevel(ov_core::Printer::PrintLevel::XXXXX);
Which will change the print level to whatever is required. This can be done at anytime in case the user wants to change the print level of open_vins while it is running (but it is not thread safe so maybe dont do that)
The various print levels work in the following way:
PrintLevel::ALL
: AllPRINT_XXXX
will output to the consolePrintLevel::DEBUG
: "DEBUG", "INFO", "WARNING" and "ERROR" will be printed. "ALL" will be silencedPrintLevel::INFO
: "INFO", "WARNING" and "ERROR" will be printed. "ALL" and "DEBUG" will be silencedPrintLevel::WARNING
: "WARNING" and "ERROR" will be printed. "ALL", "DEBUG" and "INFO" will be silencedPrintLevel::ERROR
: Only "ERROR" will be printed. All the rest are silencedPrintLevel::SILENT
: AllPRINT_XXXX
will be silenced.I also added the file name and the line number at the head of all the print outputs to make it easy to find the print statement in question. So now the prints look like this:
/open_vins/ov_msckf/src/core/VioManager.cpp:682): bg = -0.0025,0.0212,0.0768 | ba = -0.0118,0.1530,0.0532 en_vins/ov_msckf/src/core/RosVisualizer.cpp:159): [TIME]: 0.0001 seconds for visualization /open_vins/ov_msckf/src/core/VioManager.cpp:637): [TIME]: 0.0129 seconds for tracking /open_vins/ov_msckf/src/core/VioManager.cpp:638): [TIME]: 0.0002 seconds for propagation /open_vins/ov_msckf/src/core/VioManager.cpp:639): [TIME]: 0.0062 seconds for MSCKF update (21 feats) /open_vins/ov_msckf/src/core/VioManager.cpp:644): [TIME]: 0.0047 seconds for re-tri & marg (11 clones in state) /open_vins/ov_msckf/src/core/VioManager.cpp:652): [TIME]: 0.02406 seconds for total (camera 0 1)
The file path is truncated to the last 50 characters so long file paths do not fill the screen. Im not sure if this feature (the filename and line number of the print) is wanted and if not can easily be removed.