Skip to content

Commit

Permalink
fixed bug when playing back from file
Browse files Browse the repository at this point in the history
  • Loading branch information
berndpfrommer committed Nov 23, 2023
1 parent bb53c1c commit 0f00bad
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 16 deletions.
1 change: 1 addition & 0 deletions include/metavision_driver/metavision_wrapper.h
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ class MetavisionWrapper
const std::string & getExternalTriggerInMode() const { return (triggerInMode_); }
const std::string & getSyncMode() const { return (syncMode_); }
const std::string & getSensorVersion() const { return (sensorVersion_); }
const std::string & getFromFile() const { return (fromFile_); }

void setSerialNumber(const std::string & sn) { serialNumber_ = sn; }
void setFromFile(const std::string & f) { fromFile_ = f; }
Expand Down
14 changes: 8 additions & 6 deletions src/driver_ros1.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -158,13 +158,15 @@ void DriverROS1::start()
// ------ start camera, may get callbacks from then on
wrapper_->startCamera(this);

initializeBiasParameters(wrapper_->getSensorVersion());
// hook up dynamic config server *after* the camera has
// been initialized so we can read the bias values
configServer_.reset(new dynamic_reconfigure::Server<Config>(nh_));
configServer_->setCallback(boost::bind(&DriverROS1::configure, this, _1, _2));
if (wrapper_->getFromFile().empty()) {
initializeBiasParameters(wrapper_->getSensorVersion());
// hook up dynamic config server *after* the camera has
// been initialized so we can read the bias values
configServer_.reset(new dynamic_reconfigure::Server<Config>(nh_));
configServer_->setCallback(boost::bind(&DriverROS1::configure, this, _1, _2));

saveBiasService_ = nh_.advertiseService("save_biases", &DriverROS1::saveBiases, this);
saveBiasService_ = nh_.advertiseService("save_biases", &DriverROS1::saveBiases, this);
}
}

void DriverROS1::initializeBiasParameters(const std::string & sensorVersion)
Expand Down
20 changes: 11 additions & 9 deletions src/driver_ros2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -252,16 +252,18 @@ void DriverROS2::start()
// ------ start camera, may get callbacks from then on
wrapper_->startCamera(this);

declareBiasParameters(wrapper_->getSensorVersion());
callbackHandle_ = this->add_on_set_parameters_callback(
std::bind(&DriverROS2::parameterChanged, this, std::placeholders::_1));
parameterSubscription_ = rclcpp::AsyncParametersClient::on_parameter_event(
this->get_node_topics_interface(),
std::bind(&DriverROS2::onParameterEvent, this, std::placeholders::_1));
if (wrapper_->getFromFile().empty()) {
declareBiasParameters(wrapper_->getSensorVersion());
callbackHandle_ = this->add_on_set_parameters_callback(
std::bind(&DriverROS2::parameterChanged, this, std::placeholders::_1));
parameterSubscription_ = rclcpp::AsyncParametersClient::on_parameter_event(
this->get_node_topics_interface(),
std::bind(&DriverROS2::onParameterEvent, this, std::placeholders::_1));

saveBiasesService_ = this->create_service<Trigger>(
"save_biases",
std::bind(&DriverROS2::saveBiases, this, std::placeholders::_1, std::placeholders::_2));
saveBiasesService_ = this->create_service<Trigger>(
"save_biases",
std::bind(&DriverROS2::saveBiases, this, std::placeholders::_1, std::placeholders::_2));
}
}

bool DriverROS2::stop()
Expand Down
2 changes: 1 addition & 1 deletion src/metavision_wrapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -336,7 +336,7 @@ bool MetavisionWrapper::initializeCamera()
LOG_WARN_NAMED("reading bias file failed with error: " << e.what());
LOG_WARN_NAMED("continuing with default biases!");
}
} else {
} else if (fromFile_.empty()) { // only load biases when not playing from file!
LOG_INFO_NAMED("no bias file provided, using camera defaults:");
const Metavision::Biases biases = cam_.biases();
Metavision::I_LL_Biases * hw_biases = biases.get_facility();
Expand Down

0 comments on commit 0f00bad

Please sign in to comment.