Skip to content

Commit

Permalink
[mc_control] Correctly resume logging on reset
Browse files Browse the repository at this point in the history
Closes #403

The issue is two-fold:
- logging was started and not resumed, this caused key events to be
  missing from the second log
- key events might have been emitted before the resume call and this
  could cause too many key events to be in the log
  • Loading branch information
gergondet committed Oct 26, 2023
1 parent 6515811 commit 9611186
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 3 deletions.
5 changes: 4 additions & 1 deletion src/mc_control/MCController.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -737,9 +737,11 @@ void MCController::reset(const ControllerResetData & reset_data)
updateContacts();
if(gui_)
{
gui_->removeElement({"Contacts"}, "Contacts");
gui_->addElement({"Contacts"}, mc_rtc::gui::Table("Contacts", {"R1", "S1", "R2", "S2", "DoF", "Friction"},
[this]() -> const std::vector<ContactTableDataT> &
{ return contacts_table_; }));
gui_->removeElement({"Contacts", "Add"}, "Add contact");
gui_->addElement({"Contacts", "Add"},
mc_rtc::gui::Form(
"Add contact",
Expand All @@ -760,7 +762,8 @@ void MCController::reset(const ControllerResetData & reset_data)
mc_rtc::gui::FormNumberInput("Friction", false, mc_rbdyn::Contact::defaultFriction),
mc_rtc::gui::FormArrayInput<Eigen::Vector6d>("dof", false, Eigen::Vector6d::Ones())));
}
logger().addLogEntry("perf_UpdateContacts", [this]() { return updateContacts_dt_.count(); });
logger().addLogEntry(
"perf_UpdateContacts", [this]() { return updateContacts_dt_.count(); }, true);
}

void MCController::updateContacts()
Expand Down
3 changes: 2 additions & 1 deletion src/mc_control/mc_global_controller.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1029,7 +1029,8 @@ bool MCGlobalController::GoToHalfSitPose()

void MCGlobalController::start_log()
{
controller_->logger().start(current_ctrl, controller_->timeStep);
controller_->logger().start(current_ctrl, controller_->timeStep,
setup_logger_.find(current_ctrl) != setup_logger_.end());
setup_log();
if(server_) { server_->set_logger(controller_->logger_); }
}
Expand Down
3 changes: 2 additions & 1 deletion src/mc_rtc/Logger.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,8 @@ void Logger::start(const std::string & ctl_name, double timestep, bool resume, d
{
if(resume)
{
// Repeat the added key events
// Re-create key events based on the current set of entries
log_events_.clear();
for(const auto & e : log_entries_) { log_events_.push_back(KeyAddedEvent{e.type, e.key}); }
}
else { impl_->log_iter_ = start_t; }
Expand Down

0 comments on commit 9611186

Please sign in to comment.