https://blog.csdn.net/plejahhshsh/article/details/126002268
1 确保ros cvbriage使用的版本和openvslam 以及dow2库使用的 opencv一样
(ros 直接装的指令 默认怎装了opencv4.2 导致和自己编译的openvslam3.4.9不匹配,虽然编译通过但是后面可视化段错误)
1-1 如何修改cv_briage的opencv依赖版本
https://i.cnblogs.com/posts/edit;postId=18394497
1-2 修改ros工程
opencv修改为这个这里统一使用 opencv3.4.9
2 编译带指令
编译
#ros版本编译指令 cd /home/dongdong/2project/1salm/GNSS_openvslam/ros catkin_make \ -DBUILD_WITH_MARCH_NATIVE=ON \ -DUSE_PANGOLIN_VIEWER=ON \ -DUSE_SOCKET_PUBLISHER=OFF \ -DUSE_STACK_TRACE_LOGGER=ON \ -DBOW_FRAMEWORK=DBoW2 \ -DBUILD_TESTS=OFF
2 指令运行
首先
roscore
然后
source devel/setup.bash
定位节点
rosrun openvslam run_localization \ -v /home/dongdong/2project/0data/NWPU/FHY_config/orb_vocab.dbow2 \ -i /home/dongdong/2project/0data/NWPU/images \ -c /home/dongdong/2project/0data/NWPU/FHY_config/GNSS_config.yaml \ --map-db /home/dongdong/2project/0data/NWPU/Map_GNSS.msg
编写脚本执行 参考
#!/bin/bash #外部给与执行权限 #sudo chmod +x run_ros_nodes.sh # conda activate gaussian_splatting WORKSPACE_DIR="/home/dongdong/2project/1salm/GNSS_openvslam/ros" # 修改1-1 自己创建的ros节点工程catkin_make根目录 python_DIR="/home/dongdong/2project/1salm/GNSS_openvslam/ros/src/image_gaosi/src" # 修改1-2 自己创建的python脚本位置 config_DIR="/home/dongdong/2project/0data/NWPU/FHY_config/GNSS_config.yaml" # 修改1-3 数据集 conda_envs="/home/dongdong/1sorftware/1work/yes" # 修改2-1 自己的conda 安装路径 ROS_cv_briage_dir = "/home/dongdong/1sorftware/1work/opencv/catkin_ws_cv_bridge/devel/setup.bash" # 修改2-2 自己编译的cv_briage包节点,貌似不用也行 制定了依赖opencv3.4.9 而非自带4.2 echo $ROS_cv_briage_dir conda_envs_int=$conda_envs"/etc/profile.d/conda.sh" # 不用改 conda自带初始化文件 echo $conda_envs_int conda_envs_bin=$conda_envs"/envs/gaussian_splatting/bin" # 不用改 conda自带python安装位置 脚本中需要指定是conda特定的环境python而不是系统默认的 echo $conda_envs_bin ROS_SETUP="/opt/ros/noetic/setup.bash" #不用改 安装时候添加到系统路径了 不需要每次都source 这里留着 #指定目录 # 启动 ROS Master 不用改 echo "Starting ROS 总结点..." gnome-terminal -- bash -c "\ cd $WORKSPACE_DIR; source devel/setup.bash; \ roscore; \ exec bash" # 等待 ROS Master 启动 sleep 3 # 运行 C++ 发布节点 # echo "Running C++ 发布节点..." # gnome-terminal -- bash -c "\ # cd $WORKSPACE_DIR; source devel/setup.bash; \ # rosrun openvslam run_slam \ #-v /home/dongdong/2project/0data/NWPU/FHY_config/orb_vocab.dbow2 \ #-i /home/dongdong/2project/0data/NWPU/images \ #-c /home/dongdong/2project/0data/NWPU/FHY_config/GNSS_config.yaml \ #--map-db /home/dongdong/2project/0data/NWPU/Map_GNSS.msg ; \ # exec bash" # 运行 C++ 接收节点 echo "Running C++ 接收节点..." gnome-terminal -- bash -c "\ cd $WORKSPACE_DIR; source devel/setup.bash; \ source $ROS_cv_briage_dir; \ rosrun openvslam run_localization \ -v /home/dongdong/2project/0data/NWPU/FHY_config/orb_vocab.dbow2 \ -i /home/dongdong/2project/0data/NWPU/images \ -c /home/dongdong/2project/0data/NWPU/FHY_config/GNSS_config.yaml \ --map-db /home/dongdong/2project/0data/NWPU/Map_GNSS.msg ; \ exec bash" # 运行 python 渲染图节点 # source conda_envs_int 和 source ROS_cv_briage_dir 非必要,但是考虑到脚本经常因为系统环境默认变量找不到导致的路径问题,这里还是强制给了也便于学习了解执行流程。 echo "Running python 订阅节点..." echo "1 激活conda本身(脚本执行需要) 2 激活conda环境 3运行python 节点 并跟上输入参数[训练模型保存根目录,指定要使用的模型训练次数,要测试的模型精度模式]" gnome-terminal -- bash -c "\ source $conda_envs_int; \ source $ROS_cv_briage_dir; \ conda activate gaussian_splatting ; \ cd $python_DIR; \ python3 v1_image_pose_subscriber.py \ -m /home/dongdong/2project/0data/NWPU/gs_out/train1_out_sh0_num30000 \ --iteration 30000 \ --models baseline ;\ exec bash" #$conda_envs_bin/python3 image_gps_subscriber.py \
其他指令参考
1)将图像更改为话题发布出去 roscore rosrun image_publisher image_publisher /opt/ros/melodic/share/rviz/images/splash.png 2)播放bag包,将指定的话题进行新话题名的映射 rosbag play 2023-03-15-19-28-26.bag /camera/infra1/image_rect_raw:=/camera/image_raw 3)显示图像的话题 rosrun image_view image_view image:=/image_publisher_1603025741590002479/image_raw 4)读取视频 rosrun image_publisher image_publisher /xxx/1.mp4 5)读取摄像头数据,将参数改为摄像头设备号或者设备文件,执行以下指令: rosrun image_publisher image_publisher 0 与以下指令等价: rosrun image_publisher image_publisher /dev/video0
stella_vslam_ros是单独的代码,这里没用到
1)发布数据基于视频的方法 rosrun image_publisher image_publisher ./aist_living_lab_1/video.mp4 /image_raw:=/camera/image_raw 2)发布数据基于一般摄像头的 apt install ros-${ROS_DISTRO}-usb-cam rosparam set usb_cam/pixel_format yuyv rosrun usb_cam usb_cam_node rosrun image_transport republish \ raw in:=/usb_cam/image_raw raw out:=/camera/image_raw 3)运行(Tracking and Mapping 源码位置:stella_vslam_ros/src/run_slam.cc) source ~/catkin_ws/devel/setup.bash rosrun stella_vslam_ros run_slam \ -v /path/to/orb_vocab.fbow \ -c /path/to/config.yaml \ --map-db-out /path/to/map.msg 4)运行(Localization 源码位置:stella_vslam_ros/src/run_slam.cc) source ~/catkin_ws/devel/setup.bash rosrun stella_vslam_ros run_slam \ --disable-mapping \ -v /path/to/orb_vocab.fbow \ -c /path/to/config.yaml \ --map-db-in /path/to/map.msg