@@ -81,17 +81,15 @@ class RobotLogger
81
81
* @brief Initialize logger.
82
82
*
83
83
* @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 .
86
86
*/
87
87
RobotLogger (
88
88
std::shared_ptr<robot_interfaces::RobotData<Action, Observation>>
89
89
robot_data,
90
- size_t buffer_limit,
91
- int block_size = 100 )
90
+ size_t buffer_limit)
92
91
: logger_data_(robot_data),
93
92
buffer_limit_ (buffer_limit),
94
- block_size_(block_size),
95
93
stop_was_called_(false ),
96
94
enabled_(false )
97
95
{
@@ -329,7 +327,6 @@ class RobotLogger
329
327
std::vector<LogEntry> buffer_;
330
328
size_t buffer_limit_;
331
329
332
- int block_size_;
333
330
long int index_;
334
331
335
332
std::atomic<bool > stop_was_called_;
@@ -566,57 +563,6 @@ class RobotLogger
566
563
append_logger_buffer (*output);
567
564
}
568
565
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
-
620
566
// ! Get observations from logger_data_ and add them to the buffer.
621
567
void buffer_loop ()
622
568
{
0 commit comments