首先将工作站(主机)和无人机(从机)连接到同一个路由器上,并保证他们的IP地址在同一个网段。
主机(工作站)IP
192.168.1.201
从机(无人机)IP
192.168.1.211
连接成功后在主机端测试是否能连上从机:输入
lilabws01@lilabws01:~$ ping 192.168.1.211
如下结果为连接成功
PING 192.168.1.211 (192.168.1.211) 56(84) bytes of data.
64 字节,来自 192.168.1.211: icmp_seq=1 ttl=64 时间=44.7 毫秒
64 字节,来自 192.168.1.211: icmp_seq=2 ttl=64 时间=66.0 毫秒
64 字节,来自 192.168.1.211: icmp_seq=3 ttl=64 时间=89.2 毫秒
64 字节,来自 192.168.1.211: icmp_seq=4 ttl=64 时间=111 毫秒
64 字节,来自 192.168.1.211: icmp_seq=5 ttl=64 时间=31.4 毫秒
接下来在从机中命令行输入 ssh -X 主机账号@主机IP地址,然后输入主机密码进入主机终端
lilabws01@lilabws01:~/桌面$ ssh -X nvidia@192.168.1.211
nvidia@192.168.1.211's password:
Welcome to Ubuntu 18.04.4 LTS (GNU/Linux 4.9.140-tegra aarch64)
* Documentation: https://help.ubuntu.com
* Management: https://landscape.canonical.com
* Support: https://ubuntu.com/advantage
* Strictly confined Kubernetes makes edge and IoT secure. Learn how MicroK8s
just raised the bar for easy, resilient and secure K8s cluster deployment.
https://ubuntu.com/engage/secure-kubernetes-at-the-edge
This system has been minimized by removing packages and content that are
not required on a system that users do not log into.
To restore this content, you can run the 'unminimize' command.
709 packages can be updated.
509 updates are security updates.
Last login: Mon Jun 26 20:47:29 2023 from 192.168.1.201
Xlib: extension "NV-GLX" missing on display "localhost:10.0".
Xlib: extension "NV-GLX" missing on display "localhost:10.0".
Xlib: extension "NV-GLX" missing on display "localhost:10.0".
分别设置主机和从机的ROS_MASTER_URI(用于主机和从机的ROS通信)
设置主机 ROS_MASTER_URI
首先进入~/.bashrc界面
lilabws01@lilabws01:~$ sudo gedit ~/.bashrc
在文本最后加入(如果已有则修改),并保存
export ROS_MASTER_URI=http://192.168.1.201:11311 # 主机IP
export ROS_HOSTNAME=192.168.1.201 # 本地IP
export ROS_IP=192.168.1.201 # 本地IP
source 当前该文件
lilabws01@lilabws01:~$ source ~/.bashrc
设置从机 ROS_MASTER_URI
首先进入~/.bashrc界面
nvidia@NXX-02:~$ sudo gedit ~/.bashrc
在文本最后加入(如果已有则修改),并保存
export ROS_MASTER_URI=http://192.168.1.201:11311 # 主机IP
export ROS_HOSTNAME=192.168.1.211 # 本地IP
export ROS_IP=192.168.1.211 # 本地IP
source 当前该文件
nvidia@NXX-02:~$ source ~/.bashrc
在从机终端启动相机(二选一)
nvidia@NXX-02:~$ roslaunch realsense2_camera rs_camera.launch
nvidia@NXX-02:~$ roslaunch realsense2_camera rs_camera_vinsgpu.launch
在主机终端查看是否能够搜到 ROS 话题
lilabws01@lilabws01:~$ rostopic list
可以从机已经接受到从机传过来的话题了
lilabws01@lilabws01:~$ rostopic list
/camera/accel/imu_info
/camera/color/camera_info
/camera/color/image_raw
/camera/color/metadata
/camera/depth/camera_info
/camera/depth/image_rect_raw
/camera/depth/metadata
/camera/extrinsics/depth_to_color
/camera/extrinsics/depth_to_infra1
/camera/extrinsics/depth_to_infra2
/camera/gyro/imu_info
/camera/imu
/camera/infra1/camera_info
/camera/infra1/image_rect_raw
/camera/infra1/metadata
/camera/infra2/camera_info
/camera/infra2/image_rect_raw
/camera/infra2/metadata
/camera/motion_module/parameter_descriptions
/camera/motion_module/parameter_updates
/camera/realsense2_camera_manager/bond
/camera/rgb_camera/auto_exposure_roi/parameter_descriptions
/camera/rgb_camera/auto_exposure_roi/parameter_updates
/camera/rgb_camera/parameter_descriptions
/camera/rgb_camera/parameter_updates
/camera/stereo_module/auto_exposure_roi/parameter_descriptions
/camera/stereo_module/auto_exposure_roi/parameter_updates
/camera/stereo_module/parameter_descriptions
/camera/stereo_module/parameter_updates
/diagnostics
/rosout
/rosout_agg
/tf
/tf_static
运行 vins-fusion 相关 launch 配置文件,使用vins-fusion算法估计无人机位姿
source ~/catkin_ws/devel/setup.bash
rosrun vins vins_node /root/catkin_ws/src/VINS-Fusion/config/realsense_d435i/realsense_stereo_imu_config.yaml
调用rviz可视化运动轨迹和地图
rviz -d ~/catkin_ws/src/VINS-Fusion/config/vins_rviz_config.rviz