问题描述:用gampping建图的过程中发现无法在my_computer上用rviz去读取雷达数据与map
问题实质:没有实现my_computer与robot_computer之间的通信(光靠ssh是行不通的)
解决办法:参考链接
README on getting RVIS to work over multiple computers
A common task is to SSH into the robot’s computer and run RVIZ to get the laser output and other visualization. Running RVIZ directly on the remote computer will not work due to the way RVIZ is implemented. The workaround is to run RVIZ locally. To do this we need to set the local computer to locate the remote MASTER NODE in order to display the right information.
Assume:
IP: 192.168.1.0 // remote computer (robot)
IP: 192.168.1.1 // local computer (host)
*** ssh into remote computer ***
- ssh -X erratic@192.168.1.0
At the remote terminal:
2. export ROS_MASTER_URI=http://192.168.1.0:11311 //this ensures that we do not use localhost, but the real IP address as master node
-
export ROS_IP=192.168.1.0 //this ensures that ROS knows that we cannot use hostname directly (due to DHCP firewall issues)
-
roscore
At the local terminal:
5. export ROS_MASTER_URI=http://192.168.1.0:11311 //tells local computer to look for the remote here
-
export ROS_IP=192.168.1.1 //this ensures that ROS knows that we cannot use hostname directly (due to DHCP firewall issues)
-
rosrun rviz rviz // fires up rviz on local computer. It will attach to the master node of the remote computer
** Note, everytime a new terminal is open on the local/remote computer, we have to call the 2 exports commands. To make this permanent, edit the ~/.bashrc file:
8. sudo gedit ~/.bashrc //add the two export commands at the end of the file.
9. source ~/.bashrc //and restart terminal
强调下,最好gedit ~/.bashrc
,不然每个终端都要去输入export
会很麻烦