00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #include <v4r_artoolkitplus/v4r_artoolkitplus.h>
00022 #include <v4r_artoolkitplus/v4r_artoolkitplus_defaults.h>
00023
00024 #include <ARToolKitPlus/ARToolKitPlus.h>
00025
00026
00027
00028 void ARToolKitPlusNode::Parameter::callbackParameters ( v4r_artoolkitplus::ARParamConfig &config, uint32_t level ) {
00029 show_camera_image_ = config.show_camera_image;
00030 distorted_input = config.distorted_input;
00031 skip_frames = config.skip_frames;
00032 useBCH = config.useBCH;
00033 borderWidth = config.borderWidth;
00034 patternWidth = config.patternWidth;
00035 edge_threshold = config.edge_threshold;
00036 undist_mode = config.undist_mode;
00037 pose_estimation_mode = config.pose_estimation_mode;
00038 use_multi_marker_lite_detection = config.use_multi_marker_lite_detection;
00039 }
00040
00041 ARToolKitPlusNode::Parameter::Parameter()
00042 : node("~")
00043 , node_name(node.getNamespace()){
00044
00045 std::string tmp;
00046
00047 node.param<bool>("show_camera_image", show_camera_image_, ARTOOLKITPLUS_DEFAULT_SHOW_CAMERA_IMAGE);
00048 ROS_INFO("%s: show_camera_image: %s", node_name.c_str(), ((show_camera_image_) ? "true" : "false"));
00049
00050 node.param<int>("skip_frames", skip_frames, ARTOOLKITPLUS_DEFAULT_SKIP_FRAMES);
00051 ROS_INFO("%s: skip_frames: %i", node_name.c_str(), skip_frames);
00052
00053
00054 node.param<bool>("tracker_single_marker", tracker_single_marker, ARTOOLKITPLUS_DEFAULT_TRACKER_SINGLE_MARKER);
00055 ROS_INFO("%s: tracker_single_marker: %s", node_name.c_str(), ((tracker_single_marker) ? "true" : "false"));
00056
00057 node.param<bool>("tracker_multi_marker", tracker_multi_marker, ARTOOLKITPLUS_DEFAULT_TRACKER_MULTI_MARKER);
00058 ROS_INFO("%s: tracker_multi_marker: %s", node_name.c_str(), ((tracker_multi_marker) ? "true" : "false"));
00059
00060 if(!tracker_multi_marker && !tracker_single_marker) {
00061 ROS_ERROR("%s: at least tracker_multi_marker or tracker_single_marker must be true", node_name.c_str());
00062 }
00063
00064 node.param<bool>("use_multi_marker_lite_detection", use_multi_marker_lite_detection, ARTOOLKITPLUS_DEFAULT_MULIT_MARKER_LITE_DETECTION);
00065 ROS_INFO("%s: use_multi_marker_lite_detection: %s", node_name.c_str(), ((use_multi_marker_lite_detection) ? "true" : "false"));
00066
00067 node.param<std::string>("pattern_frame", pattern_frame, ARTOOLKITPLUS_DEFAULT_PATTERN_FRAME);
00068 ROS_INFO("%s: pattern_frame: %s", node_name.c_str(), pattern_frame.c_str());
00069
00070 node.param<std::string>("pattern_file", pattern_file, ARTOOLKITPLUS_DEFAULT_PATTERN_FILE);
00071 ROS_INFO("%s: pattern_file: %s", node_name.c_str(), pattern_file.c_str());
00072 if(!tracker_multi_marker && !pattern_file.empty()) {
00073 ROS_WARN("%s: tracker_multi_marker must be true in order to use mutli patterns with a pattern file", node_name.c_str());
00074 }
00075
00076 node.param<std::string>("tf_prefix", tf_prefix, node_name);
00077 ROS_INFO("%s: tf_prefix: %s", node_name.c_str(), tf_prefix.c_str());
00078
00079
00080 node.param<std::string>("marker_mode", tmp, ARTOOLKITPLUS_MARKER_MODE_BCH);
00081 if ((tmp.compare(ARTOOLKITPLUS_MARKER_MODE_BCH) == 0) || (tmp.compare(ARTOOLKITPLUS_MARKER_MODE_SIMPEL) == 0)) {
00082 if (tmp.compare(ARTOOLKITPLUS_MARKER_MODE_BCH) == 0)
00083 useBCH = true;
00084 else
00085 useBCH = false;
00086 ROS_INFO("%s: marker_mode: %s", node_name.c_str(), tmp.c_str());
00087 } else {
00088 ROS_ERROR("%s: marker_mode: %s does not match any known type use %s or %s", node_name.c_str(), tmp.c_str(), ARTOOLKITPLUS_MARKER_MODE_SIMPEL, ARTOOLKITPLUS_MARKER_MODE_BCH);
00089 }
00090
00091 node.param<double>("pattern_width", patternWidth, ARTOOLKITPLUS_DEFAULT_PATTERN_WITH);
00092 ROS_INFO("%s: pattern_width: %4.3f [m] only for single marker", node_name.c_str(), patternWidth);
00093
00094 node.param<int>("edge_threshold", edge_threshold, ARTOOLKITPLUS_DEFAULT_THRESHOLD);
00095 ROS_INFO("%s: edge_threshold: %i, (0 = auto edge_threshold)", node_name.c_str(), edge_threshold);
00096
00097 node.param<double>("border_width", borderWidth, ARTOOLKITPLUS_DEFAULT_BOARDER_WIDTH);
00098 ROS_INFO("%s: border_width: %4.3f, (0 = auto border_width)", node_name.c_str(), borderWidth);
00099
00100 node.param<int>("undist_iterations", undist_iterations, ARTOOLKITPLUS_DEFAULT_UNDIST_INTERATIONS);
00101 ROS_INFO("%s: undist_iterations: %i", node_name.c_str(), undist_iterations);
00102
00103 node.param<bool>("distorted_input", distorted_input, ARTOOLKITPLUS_DEFAULT_DISTORTED_INPUT);
00104 ROS_INFO("%s: distorted_input: %s", node_name.c_str(), ((distorted_input) ? "true" : "false"));
00105
00106 node.param<std::string>("undist_mode", tmp, ARTOOLKITPLUS_DEFAULT_UNDIST_MODE);
00107 if ((tmp.compare(ARTOOLKITPLUS_UNDIST_MODE_NONE) == 0) || (tmp.compare(ARTOOLKITPLUS_UNDIST_MODE_STD) == 0) || (tmp.compare(ARTOOLKITPLUS_UNDIST_MODE_LUT) == 0)) {
00108 if (tmp.compare(ARTOOLKITPLUS_UNDIST_MODE_NONE) == 0)
00109 undist_mode = ARToolKitPlus::UNDIST_NONE;
00110 if (tmp.compare(ARTOOLKITPLUS_UNDIST_MODE_STD) == 0)
00111 undist_mode = ARToolKitPlus::UNDIST_STD;
00112 if (tmp.compare(ARTOOLKITPLUS_UNDIST_MODE_LUT) == 0)
00113 undist_mode = ARToolKitPlus::UNDIST_LUT;
00114 ROS_INFO("%s: undist_mode: %s", node_name.c_str(), tmp.c_str());
00115 } else {
00116 ROS_ERROR("%s: undist_mode: %s does not match any known type use %s, %s or %s", node_name.c_str(), tmp.c_str(), ARTOOLKITPLUS_UNDIST_MODE_NONE, ARTOOLKITPLUS_UNDIST_MODE_STD,
00117 ARTOOLKITPLUS_UNDIST_MODE_LUT);
00118 }
00119
00120 node.param<std::string>("pose_estimation_mode", tmp, ARTOOLKITPLUS_DEFAULT_POSE_ESTIMATION_MODE);
00121 if ((tmp.compare(ARTOOLKITPLUS_POSE_ESTIMATION_MODE_NORMAL) == 0) || (tmp.compare(ARTOOLKITPLUS_POSE_ESTIMATION_MODE_CONT) == 0) || (tmp.compare(ARTOOLKITPLUS_POSE_ESTIMATION_MODE_RPP) == 0)) {
00122 if (tmp.compare(ARTOOLKITPLUS_POSE_ESTIMATION_MODE_NORMAL) == 0)
00123 pose_estimation_mode = ARToolKitPlus::POSE_ESTIMATOR_ORIGINAL;
00124 if (tmp.compare(ARTOOLKITPLUS_POSE_ESTIMATION_MODE_CONT) == 0)
00125 pose_estimation_mode = ARToolKitPlus::POSE_ESTIMATOR_ORIGINAL_CONT;
00126 if (tmp.compare(ARTOOLKITPLUS_POSE_ESTIMATION_MODE_RPP) == 0)
00127 pose_estimation_mode = ARToolKitPlus::POSE_ESTIMATOR_RPP;
00128 ROS_INFO("%s: pose_estimation_mode: %s", node_name.c_str(), tmp.c_str());
00129 } else {
00130 ROS_ERROR("%s: pose_estimation_mode: %s does not match any known type use %s, %s or %s", node_name.c_str(), tmp.c_str(), ARTOOLKITPLUS_POSE_ESTIMATION_MODE_NORMAL,
00131 ARTOOLKITPLUS_POSE_ESTIMATION_MODE_CONT, ARTOOLKITPLUS_POSE_ESTIMATION_MODE_RPP);
00132 }
00133
00134
00135 nPattern = -1;
00136 nUpdateMatrix = true;
00137 reconfigureFnc_ = boost::bind(&ARToolKitPlusNode::Parameter::callbackParameters, this , _1, _2);
00138 reconfigureServer_.setCallback(reconfigureFnc_);
00139 }
00140