mrpt_localization_node_parameters.cpp
Go to the documentation of this file.
1 /***********************************************************************************
2  * Revised BSD License *
3  * Copyright (c) 2014, Markus Bader <markus.bader@tuwien.ac.at> *
4  * All rights reserved. *
5  * *
6  * Redistribution and use in source and binary forms, with or without *
7  * modification, are permitted provided that the following conditions are met: *
8  * * Redistributions of source code must retain the above copyright *
9  * notice, this list of conditions and the following disclaimer. *
10  * * Redistributions in binary form must reproduce the above copyright *
11  * notice, this list of conditions and the following disclaimer in the *
12  * documentation and/or other materials provided with the distribution. *
13  * * Neither the name of the Vienna University of Technology nor the *
14  * names of its contributors may be used to endorse or promote products *
15  * derived from this software without specific prior written permission. *
16  * *
17  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
18  *AND *
19  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
20  **
21  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE *
22  * DISCLAIMED. IN NO EVENT SHALL Markus Bader BE LIABLE FOR ANY *
23  * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES *
24  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
25  **
26  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND *
27  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT *
28  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29  **
30  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31  ** *
32  ***********************************************************************************/
33 
34 #include "mrpt_localization_node.h"
36 
38  : PFLocalization::Parameters(p), node("~")
39 {
40  node.param<double>("transform_tolerance", transform_tolerance, 0.1);
41  ROS_INFO("transform_tolerance: %f", transform_tolerance);
42  node.param<double>("no_update_tolerance", no_update_tolerance, 1.0);
43  ROS_INFO("no_update_tolerance: %f", no_update_tolerance);
44  node.param<double>(
45  "no_inputs_tolerance", no_inputs_tolerance,
46  std::numeric_limits<double>::infinity());
47  ROS_INFO(
48  "no_inputs_tolerance: %f", no_inputs_tolerance); // disabled by default
50  ROS_INFO("rate: %f", rate);
51  node.getParam("gui_mrpt", gui_mrpt);
52  ROS_INFO("gui_mrpt: %s", gui_mrpt ? "true" : "false");
53  node.param<int>(
54  "parameter_update_skip", parameter_update_skip,
56  ROS_INFO("parameter_update_skip: %i", parameter_update_skip);
57  node.getParam("ini_file", ini_file);
58  ROS_INFO("ini_file: %s", ini_file.c_str());
59  node.getParam("map_file", map_file);
60  ROS_INFO("map_file: %s", map_file.c_str());
61  node.getParam("sensor_sources", sensor_sources);
62  ROS_INFO("sensor_sources: %s", sensor_sources.c_str());
63  node.param<std::string>("global_frame_id", global_frame_id, "map");
64  ROS_INFO("global_frame_id: %s", global_frame_id.c_str());
65  node.param<std::string>("odom_frame_id", odom_frame_id, "odom");
66  ROS_INFO("odom_frame_id: %s", odom_frame_id.c_str());
67  node.param<std::string>("base_frame_id", base_frame_id, "base_link");
68  ROS_INFO("base_frame_id: %s", base_frame_id.c_str());
69  node.param<bool>("pose_broadcast", pose_broadcast, false);
70  ROS_INFO("pose_broadcast: %s", pose_broadcast ? "true" : "false");
71  node.param<bool>("tf_broadcast", tf_broadcast, true);
72  ROS_INFO("tf_broadcast: %s", tf_broadcast ? "true" : "false");
73  node.param<bool>("use_map_topic", use_map_topic, false);
74  ROS_INFO("use_map_topic: %s", use_map_topic ? "true" : "false");
75  node.param<bool>("first_map_only", first_map_only, false);
76  ROS_INFO("first_map_only: %s", first_map_only ? "true" : "false");
77  node.param<bool>("debug", debug, true);
78  ROS_INFO("debug: %s", debug ? "true" : "false");
79  node.param<double>("initial_pose_x", init_x, 0.0);
80  ROS_INFO("initial_pose_x: %f", init_x);
81  node.param<double>("initial_pose_y", init_y, 0.0);
82  ROS_INFO("initial_pose_y: %f", init_y);
83  node.param<double>("initial_pose_phi", init_phi, 0.0); // radians
84  ROS_INFO("initial_pose_phi: %f rad", init_phi);
85  node.param<double>("initial_pose_std_xy", init_std_xy, init_std_xy); // m
86  ROS_INFO("initial_pose_std_xy: %f m", init_std_xy);
87  node.param<double>("initial_pose_std_phi", init_std_phi, init_std_phi); // radians
88  ROS_INFO("initial_pose_std_phi: %f rad", init_std_phi);
89 
90  reconfigure_cb_ = boost::bind(
93 }
94 
95 void PFLocalizationNode::Parameters::update(const unsigned long& loop_count)
96 {
97  if (loop_count % parameter_update_skip) return;
98  node.getParam("debug", debug);
99  if (loop_count == 0) ROS_INFO("debug: %s", debug ? "true" : "false");
100  {
102  node.param<int>(
103  "particlecloud_update_skip", particlecloud_update_skip,
105  if (v != particlecloud_update_skip)
106  ROS_INFO(
107  "particlecloud_update_skip: %i", particlecloud_update_skip);
108  }
109  {
110  int v = map_update_skip;
111  node.param<int>(
112  "map_update_skip", map_update_skip,
114  if (v != map_update_skip)
115  ROS_INFO("map_update_skip: %i", map_update_skip);
116  }
117 }
118 
120  mrpt_localization::MotionConfig& config, uint32_t level)
121 {
122  if (config.motion_noise_type == MOTION_MODEL_GAUSSIAN)
123  {
124  motion_model_options->modelSelection =
125  CActionRobotMovement2D::mmGaussian;
126 
127  motion_model_options->gaussianModel.a1 = config.gaussian_alpha_1;
128  motion_model_options->gaussianModel.a2 = config.gaussian_alpha_2;
129  motion_model_options->gaussianModel.a3 = config.gaussian_alpha_3;
130  motion_model_options->gaussianModel.a4 = config.gaussian_alpha_4;
131  motion_model_options->gaussianModel.minStdXY = config.gaussian_alpha_xy;
132  motion_model_options->gaussianModel.minStdPHI =
133  config.gaussian_alpha_phi;
134  ROS_INFO("gaussianModel.type: gaussian");
135  ROS_INFO(
136  "gaussianModel.a1: %f", motion_model_options->gaussianModel.a1);
137  ROS_INFO(
138  "gaussianModel.a2: %f", motion_model_options->gaussianModel.a2);
139  ROS_INFO(
140  "gaussianModel.a3: %f", motion_model_options->gaussianModel.a3);
141  ROS_INFO(
142  "gaussianModel.a4: %f", motion_model_options->gaussianModel.a4);
143  ROS_INFO(
144  "gaussianModel.minStdXY: %f",
145  motion_model_options->gaussianModel.minStdXY);
146  ROS_INFO(
147  "gaussianModel.minStdPHI: %f",
148  motion_model_options->gaussianModel.minStdPHI);
149  }
150  else
151  {
152  ROS_INFO("We support at the moment only gaussian motion models");
153  }
154  *use_motion_model_default_options = config.use_default_motion;
155  ROS_INFO(
156  "use_motion_model_default_options: %s",
157  use_motion_model_default_options ? "true" : "false");
158  motion_model_default_options->gaussianModel.minStdXY =
159  config.default_noise_xy;
160  ROS_INFO(
161  "default_noise_xy: %f",
162  motion_model_default_options->gaussianModel.minStdXY);
163  motion_model_default_options->gaussianModel.minStdPHI =
164  config.default_noise_phi;
165  ROS_INFO(
166  "default_noise_phi: %f",
167  motion_model_default_options->gaussianModel.minStdPHI);
168  update_while_stopped = config.update_while_stopped;
169  ROS_INFO(
170  "update_while_stopped: %s", update_while_stopped ? "true" : "false");
171  update_sensor_pose = config.update_sensor_pose;
172  ROS_INFO("update_sensor_pose: %s", update_sensor_pose ? "true" : "false");
173 }
#define MRPT_LOCALIZATION_NODE_DEFAULT_PARTICLECLOUD_UPDATE_SKIP
dynamic_reconfigure::Server< mrpt_localization::MotionConfig > reconfigure_server_
#define MRPT_LOCALIZATION_NODE_DEFAULT_PARAMETER_UPDATE_SKIP
int parameter_update_skip
we wait before start complaining
bool param(const std::string &param_name, T &param_val, const T &default_val) const
dynamic_reconfigure::Server< mrpt_localization::MotionConfig >::CallbackType reconfigure_cb_
void callbackParameters(mrpt_localization::MotionConfig &config, uint32_t level)
CActionRobotMovement2D::TMotionModelOptions * motion_model_options
#define ROS_INFO(...)
bool getParam(const std::string &key, std::string &s) const
#define MRPT_LOCALIZATION_NODE_DEFAULT_MAP_UPDATE_SKIP
CActionRobotMovement2D::TMotionModelOptions * motion_model_default_options
void update(const unsigned long &loop_count)
double no_inputs_tolerance
using filter time instead of Time::now
#define MRPT_LOCALIZATION_NODE_DEFAULT_RATE
double no_update_tolerance
the published tf to extend its validity


mrpt_localization
Author(s): Markus Bader, Raphael Zack
autogenerated on Thu Jun 1 2023 03:07:06