Project

General

Profile

Statistics
| Branch: | Revision:

root / rgbdslam / src / parameter_server.cpp @ 9240aaa3

History | View | Annotate | Download (6.48 KB)

1
/* This file is part of RGBDSLAM.
2
 * 
3
 * RGBDSLAM is free software: you can redistribute it and/or modify
4
 * it under the terms of the GNU General Public License as published by
5
 * the Free Software Foundation, either version 3 of the License, or
6
 * (at your option) any later version.
7
 * 
8
 * RGBDSLAM is distributed in the hope that it will be useful,
9
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11
 * GNU General Public License for more details.
12
 * 
13
 * You should have received a copy of the GNU General Public License
14
 * along with RGBDSLAM.  If not, see <http://www.gnu.org/licenses/>.
15
 */
16
#include "parameter_server.h"
17

    
18
using namespace std;
19

    
20
ParameterServer* ParameterServer::_instance = NULL;
21

    
22
ParameterServer::ParameterServer() {
23
    pre = ros::this_node::getName();
24
    pre += "/config/";
25

    
26
    defaultConfig();
27
    getValues();
28
}
29

    
30
ParameterServer* ParameterServer::instance() {
31
    if (_instance == NULL) {
32
        _instance = new ParameterServer();
33
    }
34
    return _instance;
35
}
36
void ParameterServer::defaultConfig() {
37
    config["topic_image_mono"]              = std::string("/camera/rgb/image_mono");
38
    config["topic_image_depth"]             = std::string("/camera/depth/image");
39
    config["topic_points"]                  = std::string("/camera/rgb/points");
40
    config["wide_topic"]                    = std::string("/wide_stereo/left/image_mono");
41
    config["wide_cloud_topic"]              = std::string("/wide_stereo/points2");
42
    config["camera_info_topic"]             = std::string("/camera/rgb/camera_info");
43
    config["individual_cloud_out_topic"]    = std::string("/rgbdslam/batch_clouds");
44
    config["aggregate_cloud_out_topic"]     = std::string("/rgbdslam/aggregate_clouds");
45
    config["fixed_frame_name"]              = std::string("/map");
46
    config["ground_truth_frame_name"]       = std::string("");                  //use empty string if no ground truth tf frame available
47
    config["base_frame_name"]               = std::string("/openni_camera");    //if the camera is articulated use robot base
48
    config["bagfile_name"]                  = std::string("");                  //will be processed if given
49
    config["batch_processing"]              = static_cast<bool> (false);        //store results and close after bagfile has been processed
50
    config["fixed_camera"]                  = static_cast<bool> (true);         //is camera fixed relative to base?
51
    config["feature_detector_type"]         = std::string("SURF");              //SURF, SIFT, FAST, ... see misc.cpp
52
    config["feature_extractor_type"]        = std::string("SURF");              //SURF or SIFT
53
    config["start_paused"]                  = static_cast<bool> (true);
54
    config["store_pointclouds"]             = static_cast<bool> (false);
55
    config["optimizer_iterations"]          = static_cast<int> (2);
56
    config["subscriber_queue_size"]         = static_cast<int> (2);
57
    config["publisher_queue_size"]          = static_cast<int> (1);
58
    config["max_keypoints"]                 = static_cast<int> (1000);          //will also be used as max for SiftGPU
59
    config["min_keypoints"]                 = static_cast<int> (500);
60
    config["min_matches"]                   = static_cast<int> (100);           //if using SiftGPU and GLSL you should use max. 60 matches
61
    config["fast_max_iterations"]           = static_cast<int> (10);
62
    config["surf_max_iterations"]           = static_cast<int> (5);
63
    config["min_translation_meter"]         = static_cast<double> (0.1);
64
    config["min_rotation_degree"]           = static_cast<int> (5);
65
    config["min_time_reported"]             = static_cast<double> (0.01);
66
    config["squared_meshing_threshold"]     = static_cast<double> (0.0009);
67
    config["use_glwidget"]                  = static_cast<bool> (true);
68
    config["preserve_raster_on_save"]       = static_cast<bool> (false);
69
    config["connectivity"]                  = static_cast<int> (10);
70
    config["max_connections"]               = static_cast<int> (10);
71
    config["max_dist_for_inliers"]          = static_cast<double> (0.03);
72
    config["drop_async_frames"]             = static_cast<bool> (false);
73
    config["ransac_iterations"]             = static_cast<int> (1000);
74
    config["use_gui"]                       = static_cast<bool> (true);
75
    config["use_wide"]                      = static_cast<bool> (true);
76
    config["concurrent_node_construction"]  = static_cast<bool> (true);
77
    config["voxelfilter_size"]              = static_cast<double> (-1.0); //in meters. Values <= 0 deactivate
78
    config["wide_queue_size"]               = static_cast<int> (2);
79
    config["visualization_skip_step"]       = static_cast<int> (1);
80
    config["optimizer_skip_step"]           = static_cast<int> (1);
81
    config["data_skip_step"]                = static_cast<int> (1);
82
    config["use_flann"]                     = static_cast<bool> (true); //use flann insteald of the brute force matcher
83
    config["show_axis"]                     = static_cast<bool> (true); //use flann insteald of the brute force matcher
84
    config["depth_scaling_factor"]          = static_cast<double> (1.0); //Some kinects have a wrongly scaled depth
85
}
86

    
87
void ParameterServer::getValues() {
88
    map<string, boost::any>::const_iterator itr;
89
    for (itr = config.begin(); itr != config.end(); ++itr) {
90
        string name = itr->first;
91
        if (itr->second.type() == typeid(string)) {
92
            config[name] = getFromParameterServer<string> (pre + name,
93
                    boost::any_cast<string>(itr->second));
94
            ROS_DEBUG_STREAM("Value for " << name << ":             " << boost::any_cast<string>(itr->second));
95
        } else if (itr->second.type() == typeid(int)) {
96
            config[name] = getFromParameterServer<int> (pre + name,
97
                    boost::any_cast<int>(itr->second));
98
            ROS_DEBUG_STREAM("Value for " << name << ":             " << boost::any_cast<int>(itr->second));
99
        } else if (itr->second.type() == typeid(double)) {
100
            config[name] = getFromParameterServer<double> (pre + name,
101
                    boost::any_cast<double>(itr->second));
102
            ROS_DEBUG_STREAM("Value for " << name << ":             " << boost::any_cast<double>(itr->second));
103
        } else if (itr->second.type() == typeid(bool)) {
104
            config[name] = getFromParameterServer<bool> (pre + name,
105
                    boost::any_cast<bool>(itr->second));
106
            ROS_DEBUG_STREAM("Value for " << name << ":             " << boost::any_cast<bool>(itr->second));
107
        }
108
    }
109
}
110