Skip to content

Commit 934eff7

Browse files
authored
Merge pull request #131 from open-dynamic-robot-initiative/fkloss/cleanup_logger
Remove obsolete code from RobotLogger
2 parents 8a4a461 + f8a2eb7 commit 934eff7

File tree

2 files changed

+5
-60
lines changed

2 files changed

+5
-60
lines changed

include/robot_interfaces/pybind_helper.hpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -165,10 +165,9 @@ void create_robot_logger_python_bindings(pybind11::module &m)
165165

166166
pybind11::class_<typename Types::Logger> logger(m, "Logger");
167167
logger
168-
.def(pybind11::init<typename Types::BaseDataPtr, size_t, int>(),
168+
.def(pybind11::init<typename Types::BaseDataPtr, size_t>(),
169169
pybind11::arg("robot_data"),
170-
pybind11::arg("buffer_limit"),
171-
pybind11::arg("block_size") = 100)
170+
pybind11::arg("buffer_limit"))
172171
.def("start",
173172
&Types::Logger::start,
174173
pybind11::call_guard<pybind11::gil_scoped_release>())

include/robot_interfaces/robot_logger.hpp

Lines changed: 3 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -81,17 +81,15 @@ class RobotLogger
8181
* @brief Initialize logger.
8282
*
8383
* @param robot_data Pointer to the robot data instance.
84-
* @param block_size Block size for writing data to the file when running
85-
* the logger in the background.
84+
* @param buffer_limit Max. size of the log buffer (in timesteps). If the
85+
* buffer is full, old time steps will be dropped as new ones are added.
8686
*/
8787
RobotLogger(
8888
std::shared_ptr<robot_interfaces::RobotData<Action, Observation>>
8989
robot_data,
90-
size_t buffer_limit,
91-
int block_size = 100)
90+
size_t buffer_limit)
9291
: logger_data_(robot_data),
9392
buffer_limit_(buffer_limit),
94-
block_size_(block_size),
9593
stop_was_called_(false),
9694
enabled_(false)
9795
{
@@ -329,7 +327,6 @@ class RobotLogger
329327
std::vector<LogEntry> buffer_;
330328
size_t buffer_limit_;
331329

332-
int block_size_;
333330
long int index_;
334331

335332
std::atomic<bool> stop_was_called_;
@@ -566,57 +563,6 @@ class RobotLogger
566563
append_logger_buffer(*output);
567564
}
568565

569-
/**
570-
* @brief Writes everything to the log file.
571-
*
572-
* It dumps all the data corresponding to block_size_ number of time indices
573-
* at one go.
574-
*/
575-
void loop()
576-
{
577-
enabled_ = true;
578-
579-
write_header_to_file(output_file_name_);
580-
581-
while (!stop_was_called_ &&
582-
!(logger_data_->desired_action->length() > 0))
583-
{
584-
std::this_thread::sleep_for(std::chrono::milliseconds(100));
585-
}
586-
587-
index_ = logger_data_->observation->newest_timeindex();
588-
589-
while (!stop_was_called_)
590-
{
591-
if (index_ + block_size_ <=
592-
logger_data_->observation->newest_timeindex())
593-
{
594-
#ifdef VERBOSE
595-
auto t1 = std::chrono::high_resolution_clock::now();
596-
#endif
597-
598-
append_robot_data_to_file(
599-
output_file_name_, index_, block_size_);
600-
601-
index_ += block_size_;
602-
603-
#ifdef VERBOSE
604-
auto t2 = std::chrono::high_resolution_clock::now();
605-
auto duration =
606-
std::chrono::duration_cast<std::chrono::microseconds>(t2 -
607-
t1)
608-
.count();
609-
610-
// to print the time taken for one block of data to be logged.
611-
std::cout << "Time taken for one block of data to be logged: "
612-
<< duration << std::endl;
613-
#endif
614-
}
615-
}
616-
617-
enabled_ = false;
618-
}
619-
620566
//! Get observations from logger_data_ and add them to the buffer.
621567
void buffer_loop()
622568
{

0 commit comments

Comments
 (0)