mrpt_localization_node.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 <boost/interprocess/sync/scoped_lock.hpp>
35 #include <geometry_msgs/PoseArray.h>
37 
38 #include <mrpt_bridge/pose.h>
39 #include <mrpt_bridge/laser_scan.h>
40 #include <mrpt_bridge/time.h>
41 #include <mrpt_bridge/map.h>
42 #include <mrpt_bridge/beacon.h>
43 
44 #include <mrpt/version.h>
45 #include <mrpt/obs/CObservationBeaconRanges.h>
46 using namespace mrpt::obs;
47 
48 #include <mrpt/version.h>
49 //
50 #if MRPT_VERSION >= 0x199
51 #include <mrpt/system/COutputLogger.h>
52 using namespace mrpt::system;
53 #else
55 using namespace mrpt::utils;
56 #endif
57 
59 
60 #include "mrpt_localization_node.h"
61 
62 #include <mrpt/maps/COccupancyGridMap2D.h>
64 
65 int main(int argc, char** argv)
66 {
67  ros::init(argc, argv, "localization");
68  ros::NodeHandle nh;
69  PFLocalizationNode my_node(nh);
70  my_node.init();
71  my_node.loop();
72  return 0;
73 }
74 
78  nh_(n),
79  first_map_received_(false),
80  loop_count_(0)
81 {
82 }
83 
85 {
87 }
88 
90 {
91  // Use MRPT library the same log level as on ROS nodes (only for
92  // MRPT_VERSION >= 0x150)
94 
97  "initialpose", 1, &PFLocalizationNode::callbackInitialpose, this);
98 
101 
102  // Subscribe to one or more laser sources:
103  std::vector<std::string> sources;
104  mrpt::system::tokenize(param()->sensor_sources, " ,\t\n", sources);
106  !sources.empty(),
107  "*Fatal*: At least one sensor source must be provided in "
108  "~sensor_sources (e.g. \"scan\" or \"beacon\")");
109  sub_sensors_.resize(sources.size());
110  for (size_t i = 0; i < sources.size(); i++)
111  {
112  if (sources[i].find("scan") != std::string::npos)
113  {
115  sources[i], 1, &PFLocalizationNode::callbackLaser, this);
116  }
117  else if (sources[i].find("beacon") != std::string::npos)
118  {
120  sources[i], 1, &PFLocalizationNode::callbackBeacon, this);
121  }
122  else
123  {
125  sources[i], 1, &PFLocalizationNode::callbackRobotPose, this);
126  }
127  }
128 
129  if (!param()->map_file.empty())
130  {
131 #if MRPT_VERSION >= 0x199
132  if (metric_map_.countMapsByClass<COccupancyGridMap2D>())
133  {
135  *metric_map_.mapByClass<COccupancyGridMap2D>(), resp_.map);
136  }
137 #else
139  {
141  }
142 #endif
143  pub_map_ = nh_.advertise<nav_msgs::OccupancyGrid>("map", 1, true);
144  pub_metadata_ =
145  nh_.advertise<nav_msgs::MapMetaData>("map_metadata", 1, true);
147  "static_map", &PFLocalizationNode::mapCallback, this);
148  }
150  nh_.advertise<geometry_msgs::PoseArray>("particlecloud", 1, true);
151 
152  pub_pose_ = nh_.advertise<geometry_msgs::PoseWithCovarianceStamped>(
153  "mrpt_pose", 2, true);
154 }
155 
157 {
158  ROS_INFO("loop");
159  for (ros::Rate rate(param()->rate); ros::ok(); loop_count_++)
160  {
162 
163  if ((loop_count_ % param()->map_update_skip == 0) &&
164 #if MRPT_VERSION >= 0x199
165  (metric_map_.countMapsByClass<COccupancyGridMap2D>()))
166 #else
168 #endif
169  publishMap();
170  if (loop_count_ % param()->particlecloud_update_skip == 0)
172  if (param()->tf_broadcast) publishTF();
173  if (param()->pose_broadcast) publishPose();
174 
175  ros::spinOnce();
176  rate.sleep();
177  }
178 }
179 
181  mrpt::poses::CPose3D& des, const std::string& target_frame,
182  const std::string& source_frame, const ros::Time& time,
183  const ros::Duration& timeout, const ros::Duration& polling_sleep_duration)
184 {
186  try
187  {
189  target_frame, source_frame, time, timeout, polling_sleep_duration);
191  target_frame, source_frame, time, transform);
192  }
193  catch (tf::TransformException& e)
194  {
195  ROS_WARN(
196  "Failed to get transform target_frame (%s) to source_frame (%s): "
197  "%s",
198  target_frame.c_str(), source_frame.c_str(), e.what());
199  return false;
200  }
201  mrpt_bridge::convert(transform, des);
202  return true;
203 }
204 
206 {
207  using namespace mrpt::maps;
208  using namespace mrpt::obs;
209 
211 
212  // ROS_INFO("callbackLaser");
213  auto laser = CObservation2DRangeScan::Create();
214 
215  // printf("callbackLaser %s\n", _msg.header.frame_id.c_str());
216  if (laser_poses_.find(_msg.header.frame_id) == laser_poses_.end())
217  {
218  updateSensorPose(_msg.header.frame_id);
219  }
220  else if (state_ != IDLE) // updating filter; we must be moving or
221  // update_while_stopped set to true
222  {
223  if(param()->update_sensor_pose) {
224  updateSensorPose(_msg.header.frame_id);
225  }
226  // mrpt::poses::CPose3D pose = laser_poses_[_msg.header.frame_id];
227  // ROS_INFO("LASER POSE %4.3f, %4.3f, %4.3f, %4.3f, %4.3f, %4.3f",
228  // pose.x(), pose.y(), pose.z(), pose.roll(), pose.pitch(), pose.yaw());
229  mrpt_bridge::convert(_msg, laser_poses_[_msg.header.frame_id], *laser);
230 
231  auto sf = CSensoryFrame::Create();
232  CObservationOdometry::Ptr odometry;
233  odometryForCallback(odometry, _msg.header);
234 
235  CObservation::Ptr obs = CObservation::Ptr(laser);
236  sf->insert(obs);
237  observation(sf, odometry);
238  if (param()->gui_mrpt) show3DDebug(sf);
239  }
240 }
241 
244 {
245  using namespace mrpt::maps;
246  using namespace mrpt::obs;
247 
249 
250  // ROS_INFO("callbackBeacon");
251  auto beacon = CObservationBeaconRanges::Create();
252  // printf("callbackBeacon %s\n", _msg.header.frame_id.c_str());
253  if (beacon_poses_.find(_msg.header.frame_id) == beacon_poses_.end())
254  {
255  updateSensorPose(_msg.header.frame_id);
256  }
257  else if (state_ != IDLE) // updating filter; we must be moving or
258  // update_while_stopped set to true
259  {
260  if(param()->update_sensor_pose) {
261  updateSensorPose(_msg.header.frame_id);
262  }
263  // mrpt::poses::CPose3D pose = beacon_poses_[_msg.header.frame_id];
264  // ROS_INFO("BEACON POSE %4.3f, %4.3f, %4.3f, %4.3f, %4.3f, %4.3f",
265  // pose.x(), pose.y(), pose.z(), pose.roll(), pose.pitch(), pose.yaw());
267  _msg, beacon_poses_[_msg.header.frame_id], *beacon);
268 
269  auto sf = CSensoryFrame::Create();
270  CObservationOdometry::Ptr odometry;
271  odometryForCallback(odometry, _msg.header);
272 
273  CObservation::Ptr obs = CObservation::Ptr(beacon);
274  sf->insert(obs);
275  observation(sf, odometry);
276  if (param()->gui_mrpt) show3DDebug(sf);
277  }
278 }
279 
281  const geometry_msgs::PoseWithCovarianceStamped& _msg)
282 {
283  using namespace mrpt::maps;
284  using namespace mrpt::obs;
285 
287 
288  // Robot pose externally provided; we update filter regardless state_
289  // attribute's value, as these
290  // corrections are typically independent from robot motion (e.g. inputs from
291  // GPS or tracking system)
292  // XXX admittedly an arbitrary choice; feel free to open an issue if you
293  // think it doesn't make sense
294 
295  static std::string base_frame_id =
296  tf::resolve(param()->tf_prefix, param()->base_frame_id);
297  static std::string global_frame_id =
298  tf::resolve(param()->tf_prefix, param()->global_frame_id);
299 
300  tf::StampedTransform map_to_obs_tf;
301  try
302  {
304  global_frame_id, _msg.header.frame_id, ros::Time(0.0),
305  ros::Duration(0.5));
307  global_frame_id, _msg.header.frame_id, ros::Time(0.0),
308  map_to_obs_tf);
309  }
310  catch (tf::TransformException& ex)
311  {
312  ROS_ERROR("%s", ex.what());
313  return;
314  }
315 
316  // Transform observation into global frame, including covariance. For that,
317  // we must first obtain
318  // the global frame -> observation frame tf as a Pose msg, as required by
319  // pose_cov_ops::compose
320  geometry_msgs::Pose map_to_obs_pose;
321  tf::pointTFToMsg(map_to_obs_tf.getOrigin(), map_to_obs_pose.position);
323  map_to_obs_tf.getRotation(), map_to_obs_pose.orientation);
324  geometry_msgs::PoseWithCovarianceStamped obs_pose_world;
325  obs_pose_world.header.stamp = _msg.header.stamp;
326  obs_pose_world.header.frame_id = global_frame_id;
327  pose_cov_ops::compose(map_to_obs_pose, _msg.pose, obs_pose_world.pose);
328 
329  // Ensure the covariance matrix can be inverted (no zeros in the diagonal)
330  for (unsigned int i = 0; i < obs_pose_world.pose.covariance.size(); ++i)
331  {
332  if (i / 6 == i % 6 && obs_pose_world.pose.covariance[i] <= 0.0)
333  obs_pose_world.pose.covariance[i] =
334  std::numeric_limits<double>().infinity();
335  }
336 
337  // Covert the received pose into an observation the filter can integrate
338  auto feature = CObservationRobotPose::Create();
339 
340  feature->sensorLabel = _msg.header.frame_id;
341  mrpt_bridge::convert(_msg.header.stamp, feature->timestamp);
342  mrpt_bridge::convert(obs_pose_world.pose, feature->pose);
343 
344  auto sf = CSensoryFrame::Create();
345  CObservationOdometry::Ptr odometry;
346  odometryForCallback(odometry, _msg.header);
347 
348  CObservation::Ptr obs = CObservation::Ptr(feature);
349  sf->insert(obs);
350  observation(sf, odometry);
351  if (param()->gui_mrpt) show3DDebug(sf);
352 }
353 
355  CObservationOdometry::Ptr& _odometry, const std_msgs::Header& _msg_header)
356 {
357  std::string base_frame_id =
358  tf::resolve(param()->tf_prefix, param()->base_frame_id);
359  std::string odom_frame_id =
360  tf::resolve(param()->tf_prefix, param()->odom_frame_id);
361  mrpt::poses::CPose3D poseOdom;
362  if (this->waitForTransform(
363  poseOdom, odom_frame_id, base_frame_id, _msg_header.stamp,
364  ros::Duration(1.0)))
365  {
366  _odometry = CObservationOdometry::Create();
367  _odometry->sensorLabel = odom_frame_id;
368  _odometry->hasEncodersInfo = false;
369  _odometry->hasVelocities = false;
370  _odometry->odometry.x() = poseOdom.x();
371  _odometry->odometry.y() = poseOdom.y();
372  _odometry->odometry.phi() = poseOdom.yaw();
373  }
374 }
375 
377 {
378  int wait_counter = 0;
379  int wait_limit = 10;
380 
381  if (param()->use_map_topic)
382  {
383  sub_map_ =
385  ROS_INFO("Subscribed to map topic.");
386 
387  while (!first_map_received_ && ros::ok() && wait_counter < wait_limit)
388  {
389  ROS_INFO("waiting for map callback..");
390  ros::Duration(0.5).sleep();
391  ros::spinOnce();
392  wait_counter++;
393  }
394  if (wait_counter != wait_limit)
395  {
396  return true;
397  }
398  }
399  else
400  {
401  client_map_ = nh_.serviceClient<nav_msgs::GetMap>("static_map");
402  nav_msgs::GetMap srv;
403  while (!client_map_.call(srv) && ros::ok() && wait_counter < wait_limit)
404  {
405  ROS_INFO("waiting for map service!");
406  ros::Duration(0.5).sleep();
407  wait_counter++;
408  }
410  if (wait_counter != wait_limit)
411  {
412  ROS_INFO_STREAM("Map service complete.");
413  updateMap(srv.response.map);
414  return true;
415  }
416  }
417 
418  ROS_WARN_STREAM("No map received.");
419  return false;
420 }
421 
423 {
424  if (param()->first_map_only && first_map_received_)
425  {
426  return;
427  }
428 
429  ROS_INFO_STREAM("Map received.");
430  updateMap(msg);
431 
432  first_map_received_ = true;
433 }
434 
435 void PFLocalizationNode::updateSensorPose(std::string _frame_id)
436 {
439  try
440  {
441  std::string base_frame_id =
442  tf::resolve(param()->tf_prefix, param()->base_frame_id);
444  base_frame_id, _frame_id, ros::Time(0), transform);
445  tf::Vector3 translation = transform.getOrigin();
446  tf::Quaternion quat = transform.getRotation();
447  pose.x() = translation.x();
448  pose.y() = translation.y();
449  pose.z() = translation.z();
450  tf::Matrix3x3 Rsrc(quat);
452  for (int c = 0; c < 3; c++)
453  for (int r = 0; r < 3; r++) Rdes(r, c) = Rsrc.getRow(r)[c];
454  pose.setRotationMatrix(Rdes);
455  laser_poses_[_frame_id] = pose;
456  beacon_poses_[_frame_id] = pose;
457  }
458  catch (tf::TransformException& ex)
459  {
460  ROS_ERROR("%s", ex.what());
461  ros::Duration(1.0).sleep();
462  }
463 }
464 
466  const geometry_msgs::PoseWithCovarianceStamped& _msg)
467 {
468  const geometry_msgs::PoseWithCovariance& pose = _msg.pose;
470  update_counter_ = 0;
471  state_ = INIT;
472 }
473 
474 void PFLocalizationNode::callbackOdometry(const nav_msgs::Odometry& _msg)
475 {
476  // We always update the filter if update_while_stopped is true, regardless
477  // robot is moving or
478  // not; otherwise, update filter if we are moving or at initialization (100
479  // first iterations)
480  bool moving = std::abs(_msg.twist.twist.linear.x) > 1e-3 ||
481  std::abs(_msg.twist.twist.linear.y) > 1e-3 ||
482  std::abs(_msg.twist.twist.linear.z) > 1e-3 ||
483  std::abs(_msg.twist.twist.angular.x) > 1e-3 ||
484  std::abs(_msg.twist.twist.angular.y) > 1e-3 ||
485  std::abs(_msg.twist.twist.angular.z) > 1e-3;
486  if (param()->update_while_stopped || moving)
487  {
488  if (state_ == IDLE)
489  {
490  state_ = RUN;
491  }
492  }
493  else if (state_ == RUN && update_counter_ >= 100)
494  {
495  state_ = IDLE;
496  }
497 }
498 
500 {
501 #if MRPT_VERSION >= 0x199
502  ASSERT_(metric_map_.countMapsByClass<COccupancyGridMap2D>());
504 #else
507 #endif
508 }
509 
511  nav_msgs::GetMap::Request& req, nav_msgs::GetMap::Response& res)
512 {
513  ROS_INFO("mapCallback: service requested!\n");
514  res = resp_;
515  return true;
516 }
517 
519 {
520  resp_.map.header.stamp = ros::Time::now();
521  resp_.map.header.frame_id =
522  tf::resolve(param()->tf_prefix, param()->global_frame_id);
523  resp_.map.header.seq = loop_count_;
524  if (pub_map_.getNumSubscribers() > 0)
525  {
526  pub_map_.publish(resp_.map);
527  }
529  {
530  pub_metadata_.publish(resp_.map.info);
531  }
532 }
533 
535 {
537  {
538  geometry_msgs::PoseArray poseArray;
539  poseArray.header.frame_id =
540  tf::resolve(param()->tf_prefix, param()->global_frame_id);
541  poseArray.header.stamp = ros::Time::now();
542  poseArray.header.seq = loop_count_;
543  poseArray.poses.resize(pdf_.particlesCount());
544  for (size_t i = 0; i < pdf_.particlesCount(); i++)
545  {
547  mrpt_bridge::convert(p, poseArray.poses[i]);
548  }
550  pub_particles_.publish(poseArray);
551  }
552 }
553 
559 {
560  static std::string base_frame_id =
561  tf::resolve(param()->tf_prefix, param()->base_frame_id);
562  static std::string odom_frame_id =
563  tf::resolve(param()->tf_prefix, param()->odom_frame_id);
564  static std::string global_frame_id =
565  tf::resolve(param()->tf_prefix, param()->global_frame_id);
566 
567  mrpt::poses::CPose2D robot_pose;
568  pdf_.getMean(robot_pose);
569  tf::StampedTransform base_on_map_tf, odom_on_base_tf;
570  mrpt_bridge::convert(robot_pose, base_on_map_tf);
571  ros::Time time_last_update(0.0);
572  if (state_ == RUN)
573  {
574  mrpt_bridge::convert(time_last_update_, time_last_update);
575 
576  // Last update time can be too far in the past if we where not updating
577  // filter, due to robot stopped or no
578  // observations for a while (we optionally show a warning in the second
579  // case)
580  // We use time zero if so when getting base -> odom tf to prevent an
581  // extrapolation into the past exception
582  if ((ros::Time::now() - time_last_update).toSec() >
583  param()->no_update_tolerance)
584  {
585  if ((ros::Time::now() - time_last_input_).toSec() >
586  param()->no_inputs_tolerance)
587  {
589  2.0,
590  "No observations received for %.2fs (tolerance %.2fs); are "
591  "robot sensors working?",
592  (ros::Time::now() - time_last_input_).toSec(),
593  param()->no_inputs_tolerance);
594  }
595  else
596  {
598  2.0,
599  "No filter updates for %.2fs (tolerance %.2fs); probably "
600  "robot stopped for a while",
601  (ros::Time::now() - time_last_update).toSec(),
602  param()->no_update_tolerance);
603  }
604 
605  time_last_update = ros::Time(0.0);
606  }
607  }
608 
609  try
610  {
611  // Get base -> odom transform
613  base_frame_id, odom_frame_id, time_last_update, ros::Duration(0.1));
615  base_frame_id, odom_frame_id, time_last_update, odom_on_base_tf);
616  }
617  catch (tf::TransformException& e)
618  {
620  2.0, "Transform from base frame (%s) to odom frame (%s) failed: %s",
621  base_frame_id.c_str(), odom_frame_id.c_str(), e.what());
623  2.0,
624  "Ensure that your mobile base driver is broadcasting %s -> %s tf",
625  odom_frame_id.c_str(), base_frame_id.c_str());
626  return;
627  }
628 
629  // We want to send a transform that is good up until a tolerance time so
630  // that odom can be used
631  ros::Time transform_expiration =
632  (time_last_update.isZero() ? ros::Time::now() : time_last_update) +
634  tf::StampedTransform tmp_tf_stamped(
635  base_on_map_tf * odom_on_base_tf, transform_expiration, global_frame_id,
636  odom_frame_id);
637  tf_broadcaster_.sendTransform(tmp_tf_stamped);
638 }
639 
644 {
645  // cov for x, y, phi (meter, meter, radian)
646 #if MRPT_VERSION >= 0x199
647  const auto [cov, mean] = pdf_.getCovarianceAndMean();
648 #else
651  pdf_.getCovarianceAndMean(cov, mean);
652 #endif
653 
654  geometry_msgs::PoseWithCovarianceStamped p;
655 
656  // Fill in the header
657  p.header.frame_id =
658  tf::resolve(param()->tf_prefix, param()->global_frame_id);
659  if (loop_count_ < 10 || state_ == IDLE)
660  p.header.stamp = ros::Time::now(); // on first iterations timestamp
661  // differs a lot from ROS time
662  else
663  mrpt_bridge::convert(time_last_update_, p.header.stamp);
664 
665  // Copy in the pose
666  mrpt_bridge::convert(mean, p.pose.pose);
667 
668  // Copy in the covariance, converting from 3-D to 6-D
669  for (int i = 0; i < 3; i++)
670  {
671  for (int j = 0; j < 3; j++)
672  {
673  int ros_i = i;
674  int ros_j = j;
675  if (i == 2 || j == 2)
676  {
677  ros_i = i == 2 ? 5 : i;
678  ros_j = j == 2 ? 5 : j;
679  }
680  p.pose.covariance[ros_i * 6 + ros_j] = cov(i, j);
681  }
682  }
683 
684  pub_pose_.publish(p);
685 }
686 
688 {
689  // Set ROS log level also on MRPT internal log system; level enums are fully
690  // compatible
691  std::map<std::string, ros::console::levels::Level> loggers;
692  ros::console::get_loggers(loggers);
693  if (loggers.find("ros.roscpp") != loggers.end())
694  pdf_.setVerbosityLevel(
695  static_cast<VerbosityLevel>(loggers["ros.roscpp"]));
696  if (loggers.find("ros.mrpt_localization") != loggers.end())
697  pdf_.setVerbosityLevel(
698  static_cast<VerbosityLevel>(loggers["ros.mrpt_localization"]));
699 }
map_file
ServiceClient serviceClient(const std::string &service_name, bool persistent=false, const M_string &header_values=M_string())
CMultiMetricMap metric_map_
map
void callbackRobotPose(const geometry_msgs::PoseWithCovarianceStamped &)
#define ROS_WARN_THROTTLE(rate,...)
ros::ServiceClient client_map_
void publish(const boost::shared_ptr< M > &message) const
void compose(const geometry_msgs::Pose &a, const geometry_msgs::Pose &b, geometry_msgs::Pose &out)
void publishTF()
Publish map -> odom tf; as the filter provides map -> base, we multiply it by base -> odom...
#define ROS_DEBUG_THROTTLE(rate,...)
Subscriber subscribe(const std::string &topic, uint32_t queue_size, void(T::*fp)(M), T *obj, const TransportHints &transport_hints=TransportHints())
const GLfloat * c
ros::Subscriber sub_init_pose_
bool sleep() const
ROSCPP_DECL void init(int &argc, char **argv, const std::string &name, uint32_t options=0)
bool call(MReq &req, MRes &res)
ROSCONSOLE_DECL bool get_loggers(std::map< std::string, levels::Level > &loggers)
ServiceServer advertiseService(const std::string &service, bool(T::*srv_func)(MReq &, MRes &), T *obj)
#define ROS_WARN(...)
void publishPose()
Publish the current pose of the robot.
GLuint GLenum GLenum transform
void observation(CSensoryFrame::Ptr _sf, CObservationOdometry::Ptr _odometry)
void getMean(CPose2D &mean_pose) const MRPT_OVERRIDE
TFSIMD_FORCE_INLINE const Vector3 & getRow(int i) const
bool waitForTransform(const std::string &target_frame, const std::string &source_frame, const ros::Time &time, const ros::Duration &timeout, const ros::Duration &polling_sleep_duration=ros::Duration(0.01), std::string *error_msg=NULL) const
cov
std::string resolve(const std::string &prefix, const std::string &frame_name)
GLsizei n
TFSIMD_FORCE_INLINE const tfScalar & x() const
void updateSensorPose(std::string frame_id)
obs
TFSIMD_FORCE_INLINE const tfScalar & z() const
double yaw() const
mean
CPose2D getParticlePose(size_t i) const
std::map< std::string, mrpt::poses::CPose3D > beacon_poses_
void odometryForCallback(CObservationOdometry::Ptr &, const std_msgs::Header &)
void callbackOdometry(const nav_msgs::Odometry &)
#define ROS_INFO(...)
#define ROS_ASSERT_MSG(cond,...)
mrpt::slam::CMonteCarloLocalization2D pdf_
the filter
static void quaternionTFToMsg(const Quaternion &bt, geometry_msgs::Quaternion &msg)
GLfloat GLfloat p
mrpt::poses::CPosePDFGaussian initial_pose_
initial posed used in initializeFilter()
ROSCPP_DECL bool ok()
TFSIMD_FORCE_INLINE const tfScalar & y() const
void sendTransform(const StampedTransform &transform)
tf::TransformListener tf_listener_
bool waitForTransform(mrpt::poses::CPose3D &des, const std::string &target_frame, const std::string &source_frame, const ros::Time &time, const ros::Duration &timeout, const ros::Duration &polling_sleep_duration=ros::Duration(0.01))
std::vector< ros::Subscriber > sub_sensors_
ros::Subscriber sub_odometry_
Publisher advertise(const std::string &topic, uint32_t queue_size, bool latch=false)
GLuint res
void getCovarianceAndMean(mrpt::math::CMatrixDouble33 &cov, CPose2D &mean_point) const MRPT_OVERRIDE
PFLocalizationNode(ros::NodeHandle &n)
#define ROS_WARN_STREAM(args)
void callbackLaser(const sensor_msgs::LaserScan &)
TFSIMD_FORCE_INLINE Vector3 & getOrigin()
void lookupTransform(const std::string &target_frame, const std::string &source_frame, const ros::Time &time, StampedTransform &transform) const
void callbackBeacon(const mrpt_msgs::ObservationRangeBeacon &)
void convert(const ros::Time &src, mrpt::system::TTimeStamp &des)
bool mapCallback(nav_msgs::GetMap::Request &req, nav_msgs::GetMap::Response &res)
tf::TransformBroadcaster tf_broadcaster_
const_iterator find(const KEY &key) const
unsigned long long loop_count_
uint32_t getNumSubscribers() const
#define ROS_INFO_STREAM(args)
int main(int argc, char **argv)
Quaternion getRotation() const
void show3DDebug(CSensoryFrame::Ptr _observations)
nav_msgs::GetMap::Response resp_
void update(const unsigned long &loop_count)
GLdouble GLdouble GLdouble r
#define ASSERT_(f)
ros::ServiceServer service_map_
static Time now()
std::map< std::string, mrpt::poses::CPose3D > laser_poses_
ProxyFilterContainerByClass< mrpt::maps::COccupancyGridMap2DPtr, TListMaps > m_gridMaps
void updateMap(const nav_msgs::OccupancyGrid &)
mrpt::system::TTimeStamp time_last_update_
time of the last update
void callbackInitialpose(const geometry_msgs::PoseWithCovarianceStamped &)
ROSCPP_DECL void spinOnce()
Parameters * param_
void BASE_IMPEXP tokenize(const std::string &inString, const std::string &inDelimiters, std::deque< std::string > &outTokens, bool skipBlankTokens=true) MRPT_NO_THROWS
void callbackMap(const nav_msgs::OccupancyGrid &)
#define ROS_ERROR(...)
void setRotationMatrix(const mrpt::math::CMatrixDouble33 &ROT)
static void pointTFToMsg(const Point &bt_v, geometry_msgs::Point &msg_v)


mrpt_localization
Author(s): Markus Bader, Raphael Zack
autogenerated on Thu Mar 12 2020 03:21:48