Skip to content
Snippets Groups Projects
Commit c7f882d4 authored by Joan Vallvé Navarro's avatar Joan Vallvé Navarro
Browse files

new installProcessor for tests

parent a021417f
No related branches found
No related tags found
1 merge request!448Draft: Resolve "Implementation of new nodes creation"
Pipeline #13539 failed
...@@ -168,6 +168,21 @@ class Problem : public std::enable_shared_from_this<Problem> ...@@ -168,6 +168,21 @@ class Problem : public std::enable_shared_from_this<Problem>
const std::string& _corresponding_sensor_name, const std::string& _corresponding_sensor_name,
const std::string& _params_yaml_filename, const std::string& _params_yaml_filename,
const std::vector<std::string>& _folders_schema); const std::vector<std::string>& _folders_schema);
/** \brief Factory method to install (create, and add to sensor) processors only from its properties
*
* This method creates a Processor, and adds it to the specified sensor's list of processors
*
* This method is a helper wrapper around the version accepting a sensor pointer instead of a sensor name.
* \param _prc_type type of processor
* \param _corresponding_sensor corresponding sensor pointer, used to bind the processor to the particular instance of the sensor
* \param _params_yaml_filename name of formatted yaml file defining the processor parameters.
* \param _folders_schema a vector of paths where the schema files (to validate the YAML file) are placed
*/
ProcessorBasePtr installProcessor(const std::string& _prc_type,
SensorBasePtr& _corresponding_sensor,
const std::string& _params_yaml_filename,
const std::vector<std::string>& _folders_schema);
/** \brief get a sensor pointer by its name /** \brief get a sensor pointer by its name
* \param _sensor_name The sensor name, as it was installed with installSensor() * \param _sensor_name The sensor name, as it was installed with installSensor()
......
...@@ -313,6 +313,17 @@ ProcessorBasePtr Problem::installProcessor(const std::string& _prc_type, ...@@ -313,6 +313,17 @@ ProcessorBasePtr Problem::installProcessor(const std::string& _prc_type,
SensorBasePtr sen_ptr = findSensor(_corresponding_sensor_name); SensorBasePtr sen_ptr = findSensor(_corresponding_sensor_name);
if (sen_ptr == nullptr) if (sen_ptr == nullptr)
throw std::runtime_error("Cannot bind processor. Reason: Sensor \"" + _corresponding_sensor_name + "\" not found. Check sensor name, it must match in sensor and processor!"); throw std::runtime_error("Cannot bind processor. Reason: Sensor \"" + _corresponding_sensor_name + "\" not found. Check sensor name, it must match in sensor and processor!");
return installProcessor(_prc_type, sen_ptr, _params_yaml_filename, _folders_schema);
}
ProcessorBasePtr Problem::installProcessor(const std::string& _prc_type,
SensorBasePtr& _corresponding_sensor,
const std::string& _params_yaml_filename,
const std::vector<std::string>& _folders_schema)
{
if (_corresponding_sensor == nullptr)
throw std::runtime_error("Cannot install processor: Null sensor pointer");
if (not file_exists(_params_yaml_filename)) if (not file_exists(_params_yaml_filename))
throw std::runtime_error("Cannot install processor: parameters' YAML file does not exist: " + _params_yaml_filename); throw std::runtime_error("Cannot install processor: parameters' YAML file does not exist: " + _params_yaml_filename);
...@@ -331,8 +342,8 @@ ProcessorBasePtr Problem::installProcessor(const std::string& _prc_type, ...@@ -331,8 +342,8 @@ ProcessorBasePtr Problem::installProcessor(const std::string& _prc_type,
} }
// add processor // add processor
prc_ptr->configure(sen_ptr); prc_ptr->configure(_corresponding_sensor);
prc_ptr->link(sen_ptr); prc_ptr->link(_corresponding_sensor);
} }
return prc_ptr; return prc_ptr;
} }
......
...@@ -116,7 +116,7 @@ TEST(Problem, Installers) ...@@ -116,7 +116,7 @@ TEST(Problem, Installers)
// install processor tracker (dummy installation under an Odometry sensor -- it's OK for this test) // install processor tracker (dummy installation under an Odometry sensor -- it's OK for this test)
auto pt = P->installProcessor("ProcessorTrackerFeatureDummy", auto pt = P->installProcessor("ProcessorTrackerFeatureDummy",
S->getName(), S,
wolf_root + "/test/yaml/processor_tracker_feature_dummy.yaml", wolf_root + "/test/yaml/processor_tracker_feature_dummy.yaml",
{wolf_root}); {wolf_root});
...@@ -125,7 +125,7 @@ TEST(Problem, Installers) ...@@ -125,7 +125,7 @@ TEST(Problem, Installers)
// install processor motion // install processor motion
ProcessorBasePtr pm = P->installProcessor("ProcessorOdom3d", ProcessorBasePtr pm = P->installProcessor("ProcessorOdom3d",
S->getName(), S,
wolf_root + "/test/yaml/processor_odom_3d.yaml", wolf_root + "/test/yaml/processor_odom_3d.yaml",
{wolf_root}); {wolf_root});
...@@ -325,11 +325,11 @@ TEST(Problem, StateBlocks) ...@@ -325,11 +325,11 @@ TEST(Problem, StateBlocks)
ASSERT_EQ(P->getStateBlockNotificationMapSize(), (SizeStd) 2); ASSERT_EQ(P->getStateBlockNotificationMapSize(), (SizeStd) 2);
auto pt = P->installProcessor("ProcessorTrackerFeatureDummy", auto pt = P->installProcessor("ProcessorTrackerFeatureDummy",
Sm->getName(), Sm,
wolf_root + "/test/yaml/processor_tracker_feature_dummy.yaml", wolf_root + "/test/yaml/processor_tracker_feature_dummy.yaml",
{wolf_root}); {wolf_root});
auto pm = P->installProcessor("ProcessorOdom3d", auto pm = P->installProcessor("ProcessorOdom3d",
Sm->getName(), Sm,
wolf_root + "/test/yaml/processor_odom_3d.yaml", wolf_root + "/test/yaml/processor_odom_3d.yaml",
{wolf_root}); {wolf_root});
...@@ -394,11 +394,11 @@ TEST(Problem, Covariances) ...@@ -394,11 +394,11 @@ TEST(Problem, Covariances)
auto pt = P->installProcessor("ProcessorTrackerFeatureDummy", auto pt = P->installProcessor("ProcessorTrackerFeatureDummy",
Sm->getName(), Sm,
wolf_root + "/test/yaml/processor_tracker_feature_dummy.yaml", wolf_root + "/test/yaml/processor_tracker_feature_dummy.yaml",
{wolf_root}); {wolf_root});
auto pm = P->installProcessor("ProcessorOdom3d", auto pm = P->installProcessor("ProcessorOdom3d",
St->getName(), St,
wolf_root + "/test/yaml/processor_odom_3d.yaml", wolf_root + "/test/yaml/processor_odom_3d.yaml",
{wolf_root}); {wolf_root});
......
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