Goby3 3.2.3
2025.05.13
|
Logging is a critical part of robotic operations for many purposes, such as data collection for research, performance analysis, debugging, etc.
The goby_logger
application allows you to log all or part of the messages being sent on the interprocess
layer between various Goby ZeroMQ applications. These messages are written to a binary .goby file, which can be used to play back messages or for direct post mission analysis by converting to HDF5, JSON, text or other formats.
At its simplest, goby_logger
can be run with just a directory to log to, for example:
The directory must exist and must be writable prior to running goby_logger. The default settings would log all publications to interprocess
regardless of type or group.
Log files are formatted {platform-name}_{date-time}.goby
where {platform-name}
is the value of ‘--interprocess 'platform: "{platform-name}"’and
{date-time}is the start time of
goby_logger` in UTC using the format YYYYMMDDTHHMMSS.
This section covers some of the important goby_logger
configuration settings:
log_dir
: Path to the directory (must exist) to write logs totype_regex
: C++ regex for which types
to include in the log (e.g., for PROTOBUF this would be the message name). Defaults to ".*"
(all types).group_regex
: C++ regex for which Goby groups
to include in the log. Defaults to ".*"
(all groups).load_shared_library
: Path to shared library that contains Protobuf messages. If all Protobuf messages are known to goby_logger
at runtime then they are embedded in the log. This is highly recommended to do as this means that tools like goby log convert
can run correctly even without the original .proto messages used at the time of logging, avoiding the situation where older logs cannot easily be converted if the original messages are not available.The key subscription for goby_logger
(besides all the messages to be logged) is:
If you publish this message you can start/stop or rotate the log file, based on the contents of the message:
For example I can stop logging using:
For use in C++ applications, the groups are defined in:
and the Protobuf messages are in goby/src/middleware/protobuf/logger.proto
and can be included using:
The goby log convert
function of the goby
tool can be used to convert .goby files written by goby_logger
into more usable formats.
For help see goby log help convert
.
This is the default output. To convert all logs within a directory (same as log_dir given to goby_logger
):
The output is the same as the input but with the ".txt" extension instead of the ".goby".
If you have a lot of logs and want to make use of multiple CPU cores:
To use a non-default output, simply use the --format
parameter:
JSON output uses the same name as the input but with the ".json" extension taking the place of the ".goby", so "/var/log/goby/myfile.json" in the example above.
You can also explicitly change the output. For example you can write to stdout to pipe to another tool:
which will give you a pretty-print output using the jq tool.
HDF5 is a widely used scientific data format, and is supported by common tools like Python, MATLAB, Octave, etc.
Here the default extension for the output is .h5
.
To inspect a single file using h5dump
you could run something like:
goby_playback
simply writes some subset of the messages to the current gobyd
interprocess
layer from an existing log.
At its simplest, start a new default gobyd:
And run playback
You can view the new publications from the log using:
You can adjust the playback rate to be faster than real time by setting --rate=N
where N is the multiplier of the real speed to use.
You can filter the variables to publish to choose only a few groups and or types by using the --group_regex
and/or --type_filter
parameters.
Finally, if you didn't load the Protobuf messages when you ran goby_logger
then you need to provide them to goby_playback
using --load_shared_library
.