28 #include <cv_bridge/cv_bridge.h> 32 #include <sensor_msgs/PointCloud2.h> 35 #include <sensor_msgs/CameraInfo.h> 36 #include <sensor_msgs/Image.h> 41 #include "geometry_msgs/PoseStamped.h" 42 #include "geometry_msgs/PoseArray.h" 43 #include "sensor_msgs/PointCloud2.h" 45 #include <image_transport/image_transport.h> 46 #include <image_transport/subscriber_filter.h> 49 #include <pcl/point_cloud.h> 50 #include <pcl/point_types.h> 51 #include <pcl/io/pcd_io.h> 52 #include <pcl_conversions/pcl_conversions.h> 53 #include<pcl/filters/voxel_grid.h> 54 #include<pcl/filters/passthrough.h> 56 #include<opencv2/core/core.hpp> 71 void GrabImage(
const sensor_msgs::ImageConstPtr& msgRGB,
const sensor_msgs::ImageConstPtr& msgD);
77 int main(
int argc,
char **argv)
84 cerr << endl <<
"Usage: rosrun ORB_SLAM2 RGBD path_to_vocabulary path_to_settings" << endl;
90 cout <<
"配置文件路径:"<<argv[2] << endl;
91 cv::FileStorage fsSettings(argv[2], cv::FileStorage::READ);
92 if (!fsSettings.isOpened())
94 cerr <<
"Failed to open settings file at: " << argv[2] << endl;
99 string rgbTopic = fsSettings[
"Image.RGB"];
100 string depthTopic = fsSettings[
"Image.Depth"];
103 string mapsavepath = fsSettings[
"Map.SavePath"];
111 if(access(mapsavepath.c_str(),0) == 0)
113 SLAM.LoadMap(mapsavepath);
132 cout<<
"开始进入保存地图"<<endl;
133 SLAM.SaveMap(mapsavepath);
144 cv_bridge::CvImageConstPtr cv_ptrRGB;
147 cv_ptrRGB = cv_bridge::toCvShare(msgRGB);
149 catch (cv_bridge::Exception& e)
151 ROS_ERROR(
"cv_bridge exception: %s", e.what());
155 cv_bridge::CvImageConstPtr cv_ptrD;
158 cv_ptrD = cv_bridge::toCvShare(msgD);
160 catch (cv_bridge::Exception& e)
162 ROS_ERROR(
"cv_bridge exception: %s", e.what());
166 SLAM.TrackRGBD(cv_ptrRGB->image,cv_ptrD->image,cv_ptrRGB->header.stamp.toSec());
ImageGrabber(ORB_SLAM2::System &_SLAM)
ROSCPP_DECL void init(int &argc, char **argv, const std::string &name, uint32_t options=0)
ROSCPP_DECL void spin(Spinner &spinner)
Connection registerCallback(C &callback)
int main(int argc, char **argv)
void GrabImage(const sensor_msgs::ImageConstPtr &msgRGB, const sensor_msgs::ImageConstPtr &msgD)
ROSCPP_DECL void shutdown()
void SaveKeyFrameTrajectoryTUM(const string &filename)