Ubuntu 16.04
机器配置 :
pc-master 192.168.3.230 本地
pc-slave2 192.168.3.232 远程
前提条件:
两台服务器可以相互免密登录
具体免密登录教程 : https://cloud.tencent.com/developer/article/1744580
这里以pc-slave2服务器为例(因为后面要远程启动的也是pc-slave2上的节点)
talker :
listener :
**接下来, 我们要在pc-master服务区上启动远程服务器pc-slave2的talker节点 **
sudo vim /etc/hosts
在/etc/hosts文件中添加一下内容 :
192.168.3.230 pc-master
192.168.3.232 pc-slave2
sudo vim ~/.bashrc
在~/.bashrc中添加一下内容 :
export ROS_IP="192.168.3.230"
export ROS_HOSTNAME=pc-master
export ROS_MASTER_URI=http://pc-master:11311
export ROSLAUNCH_SSH_UNKNOWN=1
sudo vim /etc/hosts
在/etc/hosts文件中添加一下内容 :
192.168.3.230 pc-master
192.168.3.232 pc-slave2
sudo vim ~/.bashrc
在~/.bashrc中添加一下内容 :
export ROS_HOSTNAME=pc-slave2
export ROS_MASTER_URI=http://pc-master:11311
export ROSLAUNCH_SSH_UNKNOWN=1
sudo vim /opt/ros/kinetic/trunk_evn.sh
新增trunk_evn.sh文件
#!/bin/sh
export ROS_IP=192.168.3.232
export ROS_HOSTNAME=pc-slave2
. /home/trunk/work/test/testworkspace/devel/setup.sh
exec "$@"
sudo chmod 777 trunk_evn.sh
在本地pc-master的package中编写launch脚本
vim /home/trunk/work/test/testworkspace/src/testpackage/launch/test.launch
<launch>
<machine name="pc-slave2" address="192.168.3.232" user="trunk" env-loader="/opt/ros/kinetic/trunk_evn.sh"></machine>
<node machine="pc-slave2" name="talker" pkg="testpackage" type="talker.py" output="screen" ></node>
</launch>
roslaunch testpackage test.launch
... logging to /home/trunk/.ros/log/84cf4482-b84f-11ea-9d63-000c297ff566/roslaunch-pc-master-3868.log
Checking log directory for disk usage. This may take awhile.
Press Ctrl-C to interrupt
Done checking log file disk usage. Usage is <1GB.
started roslaunch server http://pc-master:32881/
remote[192.168.3.232-0] starting roslaunch
remote[192.168.3.232-0]: creating ssh connection to 192.168.3.232:22, user[trunk]
/usr/lib/python2.7/dist-packages/Crypto/Cipher/blockalgo.py:141: FutureWarning: CTR mode needs counter parameter, not IV
self._cipher = factory.new(key, *args, **kwargs)
remote[192.168.3.232-0]: failed to launch on pc-slave2:
Unable to establish ssh connection to [trunk@192.168.3.232:22]: Server u'192.168.3.232' not found in known_hosts
解决思路 :
根据日志报错的提示来修改python底层源码,没有效果,日志显示, ros依然是运行在python2.7上,试着将ros运行在Python3上
sudo rm -rf /usr/bin/python
sudo ln -s /usr/bin/python3 /usr/bin/python
sudo apt-get install python3-rosdep python3-rosinstall-generator python3-wstool python3-rosinstall build-essential
sudo pip3 install catkin_pkg
rosdep install --from-paths src --ignore-src --rosdistro kinetic -y
sudo apt-get install libtbb-dev python3-pyqt5
sudo pip3 install empy numpy defusedxml netifaces
# 修复 16.04 libboost_python3找不到的问题
sudo ln -s /usr/lib/x86_64-linux-gnu/libboost_python-py35.so /usr/lib/x86_64-linux-gnu/libboost_python3.so
修改Python底层代码