diff --git a/src/publisher_vision.cpp b/src/publisher_vision.cpp index c0ba11eb1fc6b63b74248f5e274becc1ca61fa6f..6ba1556f654ad620cc37bb6f26ea0d33a1dc7069 100644 --- a/src/publisher_vision.cpp +++ b/src/publisher_vision.cpp @@ -113,28 +113,15 @@ PublisherVisionDebug::PublisherVisionDebug(const std::string &_unique_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()) - { - 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 (not processor_vision_) + auto proc = problem_->findProcessor(processor_name); + if (not proc) throw std::runtime_error( "PublisherVisionDebug: processor " + processor_name + " not found."); + processor_vision_ = std::dynamic_pointer_cast<ProcessorVisualOdometry>(proc); + if (not processor_vision_) + throw std::runtime_error( + "PublisherVisionDebug: processor " + processor_name + " is not of type ProcessorVisualOdometry"); + } void PublisherVisionDebug::initialize(ros::NodeHandle &nh, const std::string &topic)