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

Optional verbosity modes #197

Closed
wants to merge 3 commits into from

Conversation

asyounis
Copy link
Contributor

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 replace printf 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 : All PRINT_XXXX will output to the console
  • PrintLevel::DEBUG : "DEBUG", "INFO", "WARNING" and "ERROR" will be printed. "ALL" will be silenced
  • PrintLevel::INFO : "INFO", "WARNING" and "ERROR" will be printed. "ALL" and "DEBUG" will be silenced
  • PrintLevel::WARNING : "WARNING" and "ERROR" will be printed. "ALL", "DEBUG" and "INFO" will be silenced
  • PrintLevel::ERROR : Only "ERROR" will be printed. All the rest are silenced
  • PrintLevel::SILENT : All PRINT_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.

@goldbattle
Copy link
Member

Closed via #209

@goldbattle goldbattle closed this Dec 13, 2021
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.

None yet

2 participants