data_cleaner.cpp
Go to the documentation of this file.
1 
18 //Global includes
19 
20 
21 
22 //Pkg includes
23 #include <ros/ros.h>
24 
25 
26 //ISM includes
27 #include <ISM/tools/DataCleaner.hpp>
28 
29 
30 bool getNodeParameters(ros::NodeHandle nh, std::vector<std::string>& database_files, bool& clean_records, bool& clean_models)
31 {
32  bool success = true;
33 
34  if (!nh.getParam("databases", database_files) || database_files.empty())
35  {
36  ROS_INFO("Missing parameter: \"databases\"");
37  success = false;
38  }
39  else
40  {
41  std::stringstream info;
42  info << "databases:";
43  for (const std::string& file : database_files)
44  {
45  info << std::endl << "\t" << file;
46  }
47  ROS_INFO_STREAM(info.str());
48  }
49 
50  if (!nh.getParam("clean_records", clean_records))
51  {
52  ROS_INFO("Missing parameter: \"clean_records\"");
53  success = false;
54  }
55  else
56  {
57  ROS_INFO_STREAM("clean_records: " << clean_records);
58  }
59 
60  if (!nh.getParam("clean_models", clean_models))
61  {
62  ROS_INFO("Missing parameter: \"clean_models\"");
63  success = false;
64  }
65  else
66  {
67  ROS_INFO_STREAM("clean_models: " << clean_models);
68  }
69 
70 
71  return success;
72 }
73 
74 int main (int argc, char **argv)
75 {
76  //Usual ros node stuff
77  ros::init(argc, argv, "data_cleaner");
78  ros::NodeHandle nh("~");
79  ISM::DataCleaner data_cleaner;
80 
81  std::vector<std::string> database_files;
82  bool clean_records;
83  bool clean_models;
84 
85  if(getNodeParameters(nh, database_files, clean_records, clean_models))
86  {
87  if (clean_records)
88  {
89  data_cleaner.cleanRecords(database_files);
90  }
91 
92  if (clean_models)
93  {
94  data_cleaner.cleanModels(database_files);
95  }
96  ROS_INFO("DATA CLEANING COMPLETED!");
97  }
98  else
99  {
100  ROS_INFO("DATA CLEANING ABORTED! Check launch-file for missing parameter.");
101  }
102 
103  return 0;
104 }
bool getNodeParameters(ros::NodeHandle nh, std::vector< std::string > &database_files, bool &clean_records, bool &clean_models)
ROSCPP_DECL void init(int &argc, char **argv, const std::string &name, uint32_t options=0)
#define ROS_INFO(...)
int main(int argc, char **argv)
#define ROS_INFO_STREAM(args)
bool getParam(const std::string &key, std::string &s) const


asr_ism
Author(s): Borella Jocelyn, Hanselmann Fabian, Heller Florian, Heizmann Heinrich, Kübler Marcel, Mehlhaus Jonas, Meißner Pascal, Qattan Mohamad, Reckling Reno, Stroh Daniel
autogenerated on Thu Jan 9 2020 07:20:58