Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007 #pragma once
00008
00009 #include <iostream>
00010 #include <fstream>
00011 #include <string>
00012 #include "mrpt_rbpf_slam/mrpt_rbpf_slam.h"
00013
00014
00015 #include <ros/ros.h>
00016 #include <ros/package.h>
00017 #include <tf/transform_listener.h>
00018 #include <tf/transform_broadcaster.h>
00019
00020 #include <nav_msgs/OccupancyGrid.h>
00021 #include "nav_msgs/MapMetaData.h"
00022 #include <std_msgs/String.h>
00023 #include <std_msgs/Int32.h>
00024 #include <nav_msgs/GetMap.h>
00025 #include <geometry_msgs/PoseArray.h>
00026 #include <geometry_msgs/PoseWithCovarianceStamped.h>
00027 #include <sensor_msgs/LaserScan.h>
00028 #include <visualization_msgs/MarkerArray.h>
00029 #include <visualization_msgs/Marker.h>
00030
00031 #include "mrpt_msgs/ObservationRangeBeacon.h"
00032
00033 #include <mrpt_bridge/pose.h>
00034 #include <mrpt_bridge/map.h>
00035 #include <mrpt_bridge/mrpt_log_macros.h>
00036 #include <mrpt_bridge/laser_scan.h>
00037 #include <mrpt_bridge/beacon.h>
00038 #include <mrpt_bridge/time.h>
00039
00040 #include <mrpt/obs/CObservationBeaconRanges.h>
00041
00042 namespace mrpt_rbpf_slam
00043 {
00049 class PFslamWrapper : public PFslam
00050 {
00051 public:
00052 PFslamWrapper();
00053 ~PFslamWrapper() = default;
00054
00058 bool getParams(const ros::NodeHandle& nh_p);
00059
00063 bool init(ros::NodeHandle& nh);
00064
00070 bool rawlogPlay();
00071
00075 void publishMapPose();
00076
00087 void callbackBeacon(const mrpt_msgs::ObservationRangeBeacon& msg);
00088
00099 void laserCallback(const sensor_msgs::LaserScan& msg);
00100
00113 bool waitForTransform(mrpt::poses::CPose3D& des, const std::string& target_frame, const std::string& source_frame,
00114 const ros::Time& time, const ros::Duration& timeout,
00115 const ros::Duration& polling_sleep_duration = ros::Duration(0.01));
00116
00123 void odometryForCallback(mrpt::obs::CObservationOdometry::Ptr& odometry, const std_msgs::Header& msg_header);
00124
00130 void updateSensorPose(const std::string& frame_id);
00131
00136 void publishTF();
00137
00142 void vizBeacons();
00143
00144 private:
00145 double rawlog_play_delay_;
00146 bool rawlog_play_{ false };
00147
00148 std::string rawlog_filename_;
00149 std::string ini_filename_;
00150 std::string global_frame_id_;
00151 std::string odom_frame_id_;
00152 std::string base_frame_id_;
00153
00154
00155 std::string sensor_source_;
00156
00157 std::map<std::string, mrpt::poses::CPose3D> laser_poses_;
00158 std::map<std::string, mrpt::poses::CPose3D> beacon_poses_;
00159
00160
00161 std::vector<ros::Subscriber> sensorSub_;
00162
00163
00164 std::vector<std::pair<mrpt::obs::CActionCollection, mrpt::obs::CSensoryFrame>> data_;
00165
00166
00167
00168 std::vector<mrpt::opengl::CEllipsoid::Ptr> viz_beacons_;
00169
00170 ros::Publisher pub_map_, pub_metadata_, pub_particles_, pub_particles_beacons_,
00171 beacon_viz_pub_;
00172
00173 tf::TransformListener listenerTF_;
00174 tf::TransformBroadcaster tf_broadcaster_;
00175 #if MRPT_VERSION >= 0x199
00176 mrpt::system::CTicTac tictac_;
00177 #else
00178 mrpt::utils::CTicTac tictac_;
00179 #endif
00180 float t_exec_;
00181 };
00182 }