18 #define BOOST_NO_SCOPED_ENUMS 21 #include <std_msgs/Empty.h> 22 #include <std_msgs/UInt32.h> 23 #include <std_msgs/String.h> 24 #include <visualization_msgs/MarkerArray.h> 26 #include <boost/filesystem/path.hpp> 27 #include <boost/shared_ptr.hpp> 28 #include <boost/bind.hpp> 29 #include <boost/date_time/posix_time/posix_time.hpp> 30 #include <boost/date_time/posix_time/posix_time_io.hpp> 31 #include <boost/algorithm/string.hpp> 36 #include <ISM/combinatorial_trainer/CombinatorialTrainer.hpp> 37 #include <ISM/combinatorial_trainer/CombinatorialTrainerParameters.hpp> 38 #include <ISM/common_type/RecognitionResult.hpp> 39 #include <ISM/utility/Util.hpp> 41 using boost::filesystem::path;
52 ISM::CombinatorialTrainerParameters params;
55 ISM::TableHelperPtr table_helper = ISM::TableHelperPtr(
new ISM::TableHelper(params.general.dbfilename));
56 if(!table_helper->recordDataExists())
58 ISM::printRed(
"The database \"" + params.general.dbfilename +
"\" doesn't contain any recordings!\n");
63 ISM::CombinatorialTrainerPtr combinatorialTrainer = ISM::CombinatorialTrainerPtr(
new ISM::CombinatorialTrainer(params));
64 combinatorialTrainer->learn();
69 readParameter(node_handle,
"dbfilename", ¶ms->general.dbfilename,
"");
70 readParameter(node_handle,
"outputDataPath", ¶ms->general.outputDataPath,
"");
71 readParameter(node_handle,
"testSetCount", ¶ms->general.testSetCount, 0u);
72 readParameter(node_handle,
"useClassifier", ¶ms->general.useClassifier,
false);
73 readParameter(node_handle,
"loadValidTestSetsFrom", ¶ms->general.loadValidTestSetsFrom,
"");
74 readParameter(node_handle,
"loadInvalidTestSetsFrom", ¶ms->general.loadInvalidTestSetsFrom,
"");
75 readParameter(node_handle,
"storeValidTestSetsTo", ¶ms->general.storeValidTestSetsTo,
"");
76 readParameter(node_handle,
"storeInvalidTestSetsTo", ¶ms->general.storeInvalidTestSetsTo,
"");
77 readParameter(node_handle,
"loadStartTopologiesFrom", ¶ms->general.loadStartTopologiesFrom,
"");
78 readParameter(node_handle,
"storeFullyMeshedISM", ¶ms->general.storeFullyMeshedISM,
false);
79 readParameter(node_handle,
"storeStartTopologyISM", ¶ms->general.storeStartTopologyISM,
false);
81 readParameter(node_handle,
"evaluatorId", ¶ms->evaluator.evaluatorId, 0);
82 readParameter(node_handle,
"bin_size", ¶ms->evaluator.binSize, 0.08);
83 readParameter(node_handle,
"maxAngleDeviation", ¶ms->evaluator.maxAngleDeviation, 10);
84 readParameter(node_handle,
"confidenceThreshold", ¶ms->evaluator.confidenceThreshold, 0.99);
85 readParameter(node_handle,
"testForFalseNegatives", ¶ms->evaluator.testForFalseNegatives,
false);
87 readParameter(node_handle,
"topologyGeneratorId", ¶ms->topologyGenerator.topologyGeneratorId, 0);
88 readParameter(node_handle,
"swapRelations", ¶ms->topologyGenerator.swapRelations,
true);
89 readParameter(node_handle,
"removeRelations", ¶ms->topologyGenerator.removeRelations,
true);
90 readParameter(node_handle,
"maxNeighbourCount", ¶ms->topologyGenerator.maxNeighbourCount, -1);
92 readParameter(node_handle,
"treeValidatorId", ¶ms->treeValidator.treeValidatorId, 0);
93 readParameter(node_handle,
"maxTreeHeight", ¶ms->treeValidator.maxTreeHeight, 2);
95 readParameter(node_handle,
"optimizationAlgorithmId", ¶ms->optimizationAlgorithm.optimizationAlgorithmId, 0);
96 readParameter(node_handle,
"randomRestartProbability", ¶ms->optimizationAlgorithm.randomRestartProbability, 0);
97 readParameter(node_handle,
"randomWalkProbability", ¶ms->optimizationAlgorithm.randomWalkProbability, 0);
98 readParameter(node_handle,
"startFromRandomTopology", ¶ms->optimizationAlgorithm.startFromRandomTopology,
false);
100 readParameter(node_handle,
"startTemperature", ¶ms->optimizationAlgorithm.startTemperature, 0);
101 readParameter(node_handle,
"endTemperature", ¶ms->optimizationAlgorithm.endTemperature, 0);
102 readParameter(node_handle,
"temperatureFactor", ¶ms->optimizationAlgorithm.temperatureFactor, 0);
103 readParameter(node_handle,
"repetitionsBeforeUpdated", ¶ms->optimizationAlgorithm.repetitionsBeforeUpdated, 0);
105 readParameter(node_handle,
"initialAcceptableCostDelta", ¶ms->optimizationAlgorithm.initialAcceptableCostDelta, 0);
106 readParameter(node_handle,
"costDeltaDecreaseFactor", ¶ms->optimizationAlgorithm.costDeltaDecreaseFactor , 0);
107 readParameter(node_handle,
"costFunctionId", ¶ms->costFunction.costFunctionId, 0);
108 readParameter(node_handle,
"alpha", ¶ms->costFunction.alpha, 1);
109 readParameter(node_handle,
"beta", ¶ms->costFunction.beta, 1);
114 node_handle.
param<
double>(parameterName, *d, defaultValue);
115 ROS_INFO(
"%s = %.4lf", parameterName.c_str(), *d);
120 node_handle.
param<std::string>(parameterName, *s, defaultValue);
121 ROS_INFO(
"%s = %s", parameterName.c_str(), (*s).c_str());
126 node_handle.
param<
int>(parameterName, *i, defaultValue);
127 ROS_INFO(
"%s = %d", parameterName.c_str(), *i);
132 node_handle.
param<
bool>(parameterName, *b, defaultValue);
133 ROS_INFO(
"%s = %s", parameterName.c_str(), *b ?
"true" :
"false");
139 node_handle.
param<
int>(parameterName, tmp, defaultValue);
140 *ui = boost::lexical_cast<
unsigned int>(tmp);
141 ROS_INFO(
"%s = %u", parameterName.c_str(), *ui);
145 int main(
int argc,
char **argv)
147 auto unix_timestamp = std::chrono::seconds(std::time(NULL));
148 std::cout <<
"Start Time: " << unix_timestamp.count() << std::endl;
150 boost::posix_time::time_facet *facet =
new boost::posix_time::time_facet(
"%d-%b-%Y %H:%M:%S");
151 std::cout.imbue(std::locale(std::cout.getloc(), facet));
152 std::cout << boost::posix_time::second_clock::local_time() << std::endl;
154 auto t1 = std::chrono::high_resolution_clock::now();
156 ros::init(argc, argv,
"combinatorialTrainer");
159 auto t2 = std::chrono::high_resolution_clock::now();
160 auto duration = std::chrono::duration_cast<std::chrono::microseconds>( t2 - t1 ).count();
161 std::cout <<
"Duration: " << duration << std::endl;
ROSCPP_DECL void init(int &argc, char **argv, const std::string &name, uint32_t options=0)
void getCombinatorialTrainerParameters(const ros::NodeHandle &node_handle, ISM::CombinatorialTrainerParameters *params)
void readParameter(const ros::NodeHandle &node_handle, const std::string ¶meterName, bool *b, const bool defaultValue)
void readParameter(const ros::NodeHandle &node_handle, const std::string ¶meterName, int *i, const int defaultValue)
void readParameter(const ros::NodeHandle &node_handle, const std::string ¶meterName, std::string *s, const std::string defaultValue)
bool param(const std::string ¶m_name, T ¶m_val, const T &default_val) const
void readParameter(const ros::NodeHandle &node_handle, const std::string ¶meterName, double *d, const double defaultValue)
int main(int argc, char **argv)
void readParameter(const ros::NodeHandle &node_handle, const std::string ¶meterName, unsigned int *ui, const unsigned int defaultValue)