Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 #include <robot_calibration/capture/feature_finder.h>
00020 #include <robot_calibration/capture/led_finder.h>
00021 #include <robot_calibration/capture/checkerboard_finder.h>
00022 #include <robot_calibration/capture/ground_plane_finder.h>
00023 #include <robot_calibration/capture/plane_finder.h>
00024
00025 namespace robot_calibration
00026 {
00027
00028 bool loadFeatureFinders(ros::NodeHandle& nh,
00029 FeatureFinderMap& features)
00030 {
00031
00032 features.clear();
00033
00034
00035 XmlRpc::XmlRpcValue finder_params;
00036 if (!nh.getParam("features", finder_params))
00037 {
00038 ROS_FATAL("Parameter 'features' is not set!");
00039 return false;
00040 }
00041
00042
00043 if (finder_params.getType() != XmlRpc::XmlRpcValue::TypeStruct)
00044 {
00045 ROS_FATAL("Parameter 'features' should be a struct.");
00046 return false;
00047 }
00048
00049 ROS_INFO("Loading %d feature finders.", (int)finder_params.size());
00050
00051
00052 for (XmlRpc::XmlRpcValue::iterator it = finder_params.begin();
00053 it != finder_params.end();
00054 it++)
00055 {
00056
00057 std::string name = static_cast<std::string>(it->first);
00058 ros::NodeHandle finder_handle(nh, "features/"+name);
00059
00060
00061 std::string type;
00062 if (!finder_handle.getParam("type", type))
00063 {
00064 ROS_FATAL("Feature finder %s has no type defined", name.c_str());
00065 return false;
00066 }
00067
00068
00069
00070 FeatureFinderPtr finder;
00071 if (type == "robot_calibration/LedFinder")
00072 {
00073 ROS_INFO(" New robot_calibration/LedFinder: %s", name.c_str());
00074 finder.reset(new robot_calibration::LedFinder(finder_handle));
00075 }
00076 else if (type == "robot_calibration/GroundPlaneFinder")
00077 {
00078 ROS_INFO(" New robot_calibration/GroundPlaneFinder: %s", name.c_str());
00079 finder.reset(new robot_calibration::GroundPlaneFinder(finder_handle));
00080 }
00081 else if (type == "robot_calibration/CheckerboardFinder")
00082 {
00083 ROS_INFO(" New robot_calibration/CheckerboardFinder: %s", name.c_str());
00084 finder.reset(new robot_calibration::CheckerboardFinder(finder_handle));
00085 }
00086 else if (type == "robot_calibration/PlaneFinder")
00087 {
00088 ROS_INFO(" New robot_calibration/PlaneFinder: %s", name.c_str());
00089 finder.reset(new robot_calibration::PlaneFinder(finder_handle));
00090 }
00091 else
00092 {
00093 ROS_FATAL("Unknown finder: %s", type.c_str());
00094 return false;
00095 }
00096
00097 features[name] = finder;
00098 }
00099
00100 return true;
00101 }
00102
00103 }