假设
机器人的IP: 192.168.0.11 // remote computer (robot)
本地PC的IP: 192.168.0.111 // local computer Ubuntu (host)
查看IP地址的方法: 参考1,参考2
本地PC通过ssh链接远端机器人,如利用Mobaxterm或VSCode
在远端的命令行终端内输入如下命令:
export ROS_MASTER_URI=http://192.168.0.11:11311 //this ensures that we do not use localhost, but the real IP address as master node
export ROS_IP=192.168.0.11 //this ensures that ROS knows that we cannot use hostname directly (due to DHCP firewall issues)
然后
roscore
远端插上usb摄像头,参考ROS调用USB双目摄像头模组调用usb_cam,跑通后会有如下一堆topic:

然后打开本地PC的终端,输入如下命令:
export ROS_MASTER_URI=http://192.168.0.11:11311 //tells local computer to look for the remote here
export ROS_IP=192.168.0.111 //this ensures that ROS knows that we cannot use hostname directly (due to DHCP firewall issues)
“11311”代表啥目前我还不清除…… 知道的大佬感谢您在评论区告诉我!
然后
rosrun rviz rviz // fires up rviz on local computer. It will attach to the master node of the remote computer

使用上面export的方式每次打开一个终端都要输入一遍。
如果用的比较多,为了方便,也可以直接修改环境变量:
sudo gedit ~/.bashrc //add the two export commands at the end of the file.
source ~/.bashrc //and restart terminal
但是记得不需要的时候去掉上面export的命令!
ROS之旅(六)远端rviz监控
rviz远程桌面启动问题解决,多机器分布式本地运行rviz
Ubuntu查看IP地址
ubuntu查看ip地址命令(如何在 Ubuntu 中检查你的 IP 地址)