Skip to content
Snippets Groups Projects
Commit 51411285 authored by Joan Solà Ortega's avatar Joan Solà Ortega
Browse files

fix some logic regarding how to find the processor by name

parent f640f7bc
No related branches found
No related tags found
2 merge requests!3After cmake and const refactor,!1Resolve "Publisher for visual odometry"
......@@ -71,7 +71,7 @@ PublisherVisionDebug::PublisherVisionDebug(const std::string &_unique_name,
img_transport_(ros::NodeHandle())
{
// if user do not provide processor's name, first processor of type PublisherVisionDebug is taken
auto processor_name = getParamWithDefault<std::string>(_server, prefix_ + "/processor_name", "");
auto processor_name = getParamWithDefault<std::string>(_server, prefix_ + "/processor_name", "");
show_tracks_ID_ = getParamWithDefault<bool>(_server, prefix_ + "/show_tracks_ID", false);
show_landmarks_ID_ = getParamWithDefault<bool>(_server, prefix_ + "/show_landmarks_ID", false);
......@@ -90,21 +90,32 @@ PublisherVisionDebug::PublisherVisionDebug(const std::string &_unique_name,
// search the processor
if (processor_name == "")
throw std::runtime_error(
"PublisherVisionDebug: name of processor of type ProcessorVisualOdometry not provided");
for (auto sen : _problem->getHardware()->getSensorList())
{
for (auto proc : sen->getProcessorList())
{
processor_vision_ = std::dynamic_pointer_cast<ProcessorVisualOdometry>(proc);
if (processor_vision_ and (proc->getName() == processor_name or processor_name == ""))
break;
if (proc->getName() == processor_name)
{
processor_vision_ = std::dynamic_pointer_cast<ProcessorVisualOdometry>(proc);
if (processor_vision_)
break; //
else
{
throw std::runtime_error(
"PublisherVisionDebug: processor " + processor_name + " is not of type ProcessorVisualOdometry");
break;
}
}
}
if (processor_vision_)
break;
}
if (not processor_vision_)
throw std::runtime_error(
"PublisherVisionDebug processor of type ProcessorVisualOdometry with the provided name was not found.");
"PublisherVisionDebug: processor " + processor_name + " not found.");
}
void PublisherVisionDebug::initialize(ros::NodeHandle &nh, const std::string &topic)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment