addtogroup gazebo_util
More...
#include <util/util.hh>
Inherits SingletonT< LogRecord >.
|
void | Add (const std::string &_name, const std::string &_filename, std::function< bool(std::ostringstream &)> _logCallback) |
| Add an object to a log file.
|
|
std::string | BasePath () const |
| Get the base path for a log recording.
|
|
unsigned int | BufferSize () const |
| Get the size of the buffer.
|
|
const std::string & | Encoding () const |
| Get the encoding used.
|
|
std::string | Filename (const std::string &_name="") const |
| Get the filename for a log object.
|
|
unsigned int | FileSize (const std::string &_name="") const |
| Get the file size for a log object.
|
|
std::string | Filter () const |
| Get the log recording filter string.
|
|
void | Fini () |
| Finialize, and shutdown.
|
|
bool | FirstUpdate () const |
| Return true if an Update has not yet been completed.
|
|
bool | Init (const std::string &_subdir) |
| Initialize logging into a subdirectory.
|
|
bool | IsReadyToStart () const |
| Get whether the logger is ready to start, which implies that any previous runs have finished.
|
|
void | Notify () |
| Tell the recorder that an update should occur.
|
|
bool | Paused () const |
| Get whether logging is paused.
|
|
double | Period () const |
| Get the log recording period.
|
|
bool | RecordResources () const |
| Get whether the model meshes and materials are saved when recording.
|
|
bool | Remove (const std::string &_name) |
| Remove an entity from a log.
|
|
bool | Running () const |
| Get whether logging is running.
|
|
common::Time | RunTime () const |
| Get the run time in sim time.
|
|
bool | SaveFiles (const std::set< std::string > &resources) |
| Return true if all the files are saved successfully.
|
|
bool | SaveModels (const std::set< std::string > &models) |
| Return true if all the models are saved successfully.
|
|
void | SetBasePath (const std::string &_path) |
| Set the base path.
|
|
void | SetFilter (const std::string &_filter) |
| Set the log recording filter string.
|
|
void | SetPaused (const bool _paused) |
| Set whether logging should pause.
|
|
void | SetPeriod (const double _period) |
| Set the log recording period.
|
|
void | SetRecordResources (const bool _record) |
| Set whether to save model meshes and materials when recording.
|
|
bool | Start (const LogRecordParams &_params) |
| Start the logger.
|
|
bool | Start (const std::string &_encoding="zlib", const std::string &_path="") |
| Start the logger.
|
|
void | Stop () |
| Stop the logger.
|
|
void | Write (const bool _force=false) |
| Write all logs.
|
|
addtogroup gazebo_util
Handles logging of data to disk
The LogRecord class is a Singleton that manages data logging of any entity within a running simulation. An entity may be a World, Model, or any of their child entities. This class only writes log files, see LogPlay for playback functionality.
State information for an entity may be logged through the LogRecord::Add function, and stopped through the LogRecord::Remove function. Data may be logged into a single file, or split into many separate files by specifying different filenames for the LogRecord::Add function.
The LogRecord is updated at the start of each simulation step. This guarantees that all data is stored.
- See also
- Logplay, State
◆ Add()
void Add |
( |
const std::string & | _name, |
|
|
const std::string & | _filename, |
|
|
std::function< bool(std::ostringstream &)> | _logCallback ) |
Add an object to a log file.
Add a new object to a log. An object can be any valid named object in simulation, including the world itself. Duplicate additions are ignored. Objects can be added to the same file by specifying the same _filename.
- Parameters
-
[in] | _name | Name of the object to log. |
[in] | _filename | Filename of the log file. |
[in] | _logCallback | Function used to log data for the object. Typically an object will have a log function that outputs data to the provided ofstream. |
- Exceptions
-
◆ BasePath()
std::string BasePath |
( |
| ) |
const |
Get the base path for a log recording.
- Returns
- Path for log recording.
◆ BufferSize()
unsigned int BufferSize |
( |
| ) |
const |
Get the size of the buffer.
- Returns
- Size of the buffer, in bytes.
◆ Encoding()
const std::string & Encoding |
( |
| ) |
const |
Get the encoding used.
- Returns
- Either [txt, zlib, or bz2], where txt is plain txt and bz2 and zlib are compressed data with Base64 encoding.
◆ Filename()
std::string Filename |
( |
const std::string & | _name = "" | ) |
const |
Get the filename for a log object.
- Parameters
-
[in] | _name | Name of the log object. |
- Returns
- Filename, empty string if not found.
◆ FileSize()
unsigned int FileSize |
( |
const std::string & | _name = "" | ) |
const |
Get the file size for a log object.
- Parameters
-
[in] | _name | Name of the log object. |
- Returns
- Size in bytes.
◆ Filter()
std::string Filter |
( |
| ) |
const |
Get the log recording filter string.
- Returns
- Log recording filter string.
◆ Fini()
◆ FirstUpdate()
bool FirstUpdate |
( |
| ) |
const |
Return true if an Update has not yet been completed.
- Returns
- True if an Update has not yet been completed.
◆ Init()
bool Init |
( |
const std::string & | _subdir | ) |
|
Initialize logging into a subdirectory.
Init may only be called once, False will be returned if called multiple times.
- Parameters
-
[in] | _subdir | Directory to record to |
- Returns
- True if successful.
◆ Instance()
Get an instance of the singleton.
◆ IsReadyToStart()
bool IsReadyToStart |
( |
| ) |
const |
Get whether the logger is ready to start, which implies that any previous runs have finished.
◆ Notify()
Tell the recorder that an update should occur.
◆ Paused()
◆ Period()
Get the log recording period.
- Returns
- Log recording period in seconds.
◆ RecordResources()
bool RecordResources |
( |
| ) |
const |
Get whether the model meshes and materials are saved when recording.
- Returns
- True if model meshes and materials are saved when recording.
◆ Remove()
bool Remove |
( |
const std::string & | _name | ) |
|
Remove an entity from a log.
Removes an entity from the logger. The stops data recording for the entity and all its children. For example, specifying a world will stop all data logging.
- Parameters
-
- Returns
- True if the entity existed and was removed. False if the entity was not registered with the logger.
◆ Running()
Get whether logging is running.
- Returns
- True if logging has been started.
◆ RunTime()
Get the run time in sim time.
- Returns
- Run sim time.
◆ SaveFiles()
bool SaveFiles |
( |
const std::set< std::string > & | resources | ) |
|
Return true if all the files are saved successfully.
- Returns
- True if all the files are saved successfully, and false if there are errors saving the files.
◆ SaveModels()
bool SaveModels |
( |
const std::set< std::string > & | models | ) |
|
Return true if all the models are saved successfully.
- Returns
- True if all the models are saved successfully.
◆ SetBasePath()
void SetBasePath |
( |
const std::string & | _path | ) |
|
Set the base path.
- Parameters
-
[in] | _path | Path to the new logging location. |
◆ SetFilter()
void SetFilter |
( |
const std::string & | _filter | ) |
|
Set the log recording filter string.
- Parameters
-
[in] | _filter | New log record filter regex string |
◆ SetPaused()
void SetPaused |
( |
const bool | _paused | ) |
|
Set whether logging should pause.
A paused state means the log file is still open, but data is not written to it.
- Parameters
-
[in] | _paused | True to pause data logging. |
- See also
- LogRecord::GetPaused
◆ SetPeriod()
void SetPeriod |
( |
const double | _period | ) |
|
Set the log recording period.
- Parameters
-
[in] | _period | New log recording period in seconds. |
◆ SetRecordResources()
void SetRecordResources |
( |
const bool | _record | ) |
|
Set whether to save model meshes and materials when recording.
- Parameters
-
[in] | _record | True to save model resources when recording. |
◆ Start() [1/2]
Start the logger.
\params[in] _params Log recording parameters.
◆ Start() [2/2]
bool Start |
( |
const std::string & | _encoding = "zlib", |
|
|
const std::string & | _path = "" ) |
Start the logger.
- Parameters
-
[in] | _encoding | The type of encoding (txt, zlib, or bz2). |
[in] | _path | Path in which to store log files. |
◆ Stop()
◆ Write()
void Write |
( |
const bool | _force = false | ) |
|
Write all logs.
- Parameters
-
[in] | _force | True to skip waiting on dataAvailableCondition. |
The documentation for this class was generated from the following file: