整个配置过程相当地痛苦,而且也很玄学,到目前为止,依然不清楚是哪一个步骤使得配置成功啦!
1. 功能包安装
sudo apt-get install ros-kinetic-multimaster-fkie
2. 实验配置
2.1. 固定IP地址
这一步是可有可无的,只要路由器能够保证,电脑关机重启后,能够分配到同一个IP地址便没有任何问题。如果目标对象是一些嵌入式设备,完全可以将其IP地址给固定下来,但是IP固定之后,貌似无法联网,目前该问题还不清楚如何解决。
# 具体设置可以在Ubuntu的有线连接进行设置,将IPV Settings的Method设置为Automatic(DHCP)
# 然后添加Address、Netmask、Gateway,点击保存即可
# 修改完网络设置,需要重启
- Intel平台设置
Address:192.168.0.100
Netmask:255.255.255.0
Gateway:192.168.0.1
- TX2平台设置
Address:192.168.0.101
Netmask:255.255.255.0
Gateway:192.168.0.1
2.2. 查看和设置主机名【hostname】
其实终端前方的文本为:usrname@hostname
# 查看hostname
$ hostname
# 修改hostname
$ sudo gedit /etc/hostname
# 修改完hostname需要重启才能生效
2.3. 修改/etc/hosts文件
sudo gedit /etc/hosts
# 修改完hosts文件后需要重启网络
sudo /etc/init.d/networking restart
- Intel平台设置
hostname:intel
127.0.0.1 localhost
127.0.1.1 intel
192.168.0.101 tegra
192.168.0.100 intel
# The following lines are desirable for IPv6 capable hosts
::1 ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
- TX2平台设置
hostname:tegra
127.0.0.1 localhost
127.0.1.1 tegra
192.168.0.101 tegra
192.168.0.100 intel
# The following lines are desirable for IPv6 capable hosts
::1 ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
2.4. 修改.bashrc
文件,设置ROS_MASTER_URI
sudo gedit .bashrc
,在.bashrc
文件末尾分别添加如下文本,同时需要重启终端才能生效。
- Intel平台设置
hostname:intel
export ROS_MASTER_URI=http://192.168.0.100:11311
- TX2平台设置
hostname:tegra
export ROS_MASTER_URI=http://192.168.0.101:11311
# 有的项目提示,需要将其中一台电脑的端口修改为11312,没有测试过
export ROS_MASTER_URI=http://192.168.0.101:11312
2.5. 查看multicast是否开启和设置
# 多播组功能使用如下指令查看,如输出为0,则说明开启
# 一般是关闭的,输出为1
cat /proc/sys/net/ipv4/icmp_echo_ignore_broadcasts
--------------------------------
# 暂时设置方法,重启电脑将失效
sudo sh -c "echo 0 >/proc/sys/net/ipv4/icmp_echo_ignore_broadcasts"
--------------------------------
# 永久设置方法
$ sudo gedit /etc/sysctl.conf
# 如果不存在,在文本末尾添加;如存在则将1更改为0
net.ipv4.icmp_echo_ignore_broadcasts=0
# 服务重启
$ sudo service procps restart
2.6. 网络配置是否成功
- 测试多播组是否设置成功
# 说实话该指令没有理解,直接跳过
netstat -g
ping 224.0.0.1
- 网络测试:互相ping和ssh连接测试
测试SSH是由于该功能包是建立在SSH通信的基础上的
# Intel平台测试
# ping IP地址
ping 192.168.0.101
# ping hostname
ping tegra
# ssh username@IP_address,输入密码即可连接成功
ssh [email protected]
# TX2平台测试
# ping IP地址
ping 192.168.0.100
# ping hostname
ping intel
# ssh username@IP_address,输入密码即可连接成功
ssh [email protected]
3. 实验指令
- Intel平台: Ubuntu 16.04 64位版本 ROS-kinetic (先启动)
$ roscore
# 启动多播组发现节点,传递多播组参数【_mcast_group】
$ rosrun master_discovery_fkie master_discovery _mcast_group:=224.0.0.1
# 启动同步节点
$ rosrun master_sync_fkie master_sync
# 查看masters列表服务
$ rosservice call /master_discovery/list_masters
- TX2平台: Ubuntu 16.04 arm版本 ROS-kinetic (后启动)
$ roscore
# 如果上面的IP地址更换,则这里可以设定端口
$ roscore -p 11312
# 启动多播组发现节点,传递多播组参数【_mcast_group】
$ rosrun master_discovery_fkie master_discovery _mcast_group:=224.0.0.1
# 启动同步节点
$ rosrun master_sync_fkie master_sync
# 查看masters列表服务
$ rosservice call /master_discovery/list_masters
- 测试通信话题: Intel ==> TX2
# 在Intel上发布测试话题 /test1
$ rostopic pub -r 1 /test1 std_msgs/Int32 1
# 在TX2上输出话题信息 /test1
$ rostopic echo /test1
- 测试通信话题: TX2 ==> Intel
# 在Intel上发布测试话题 /test2
$ rostopic pub -r 1 /test2 std_msgs/Int32 2
# 在TX2上输出话题信息 /test2
$ rostopic echo /test2
3.1. master_discovery_fkie
节点的相关参数
# 输出更加详细的调试日志
rosrun master_discovery_fkie master_discovery _log_level:=DEBUG
# 设定多播组地址
rosrun master_discovery_fkie master_discovery _mcast_group:=224.0.0.1
# 设定多播组接收和发送端口
rosrun master_discovery_fkie master_discovery _mcast_port:=11512
# 设定RPC端口
rosrun master_discovery_fkie master_discovery _rpc_port:=11612
# 设定需要发现的机器人的IP地址
rosrun master_discovery_fkie master_discovery _robot_hosts:=[137.132.82.147]
rosrun master_discovery_fkie master_discovery _robot_hosts:=[hostname]
# 设定hostname检验无效
rosrun master_sync_fkie master_sync _check_host:=false
# 设定多播组发送无效
rosrun master_sync_fkie master_sync _send_mcast:=false
# 设定多播组接收无效
rosrun master_sync_fkie master_sync _listen_mcast:=false
# 根据netstat -g指令展示的多播组进行选择,也许是这个
rosrun master_discovery_fkie master_discovery _mcast_group:=224.0.0.251
# 在其中一台电脑设定节点名称,其中name前面有两单下划线【_ _】
rosrun master_discovery_fkie master_discovery __name:=master_discovery_ai
3.2. master_sync_fkie
节点的相关参数
$ rosrun master_sync_fkie master_sync __name:=master_sync_ai
$ rosrun master_sync_fkie master_sync _check_host:=false
4. 注意事项
- 多机通信之间的自定义消息一定要格式相同,不然无法实现有效通信
- 借助
roslaunch
实现节点信息同步和参数文件配置设置
# 同步配置:sync_interface.sync
# For ignore/sync nodes, topics or services
# use follow declaration:
#{param name}:
# - {ros name}
# or for selected hosts:
# - {host name}:
# - {ros name}
# you can use follow wildcard: '*'
# A filter list with patterns. If this pattern merges to a node,
# topic or service it will not be synchronized.
do_not_sync:
# The ignore_* lists will be processed first.
ignore_hosts:
sync_hosts:
ignore_nodes:
sync_nodes:
ignore_topics:
ignore_publishers:
ignore_subscribers:
# 同步话题
sync_topics:
- /test
# 忽略服务
ignore_services:
- /*get_loggers
- /*set_logger_level
# 同步服务
sync_services:
# If sync_topics_on_demand is True the local subscribed and published topics
# are synchronized with remote even if they are not in the sync_* list.
sync_topics_on_demand: False
# The nodes which are running not at the same host as the ROS master are not
# synchronized by default. Use sync_remote_nodes to sync these nodes also.
sync_remote_nodes: False
# Performs resync after the host was offline: unregister and register again
# to avoid connection losses to python topic. These does not suppot reconnection!
resync_on_reconnect: True
# A configurable period that controls how long the offline-online period [sec]
# is before the resync kicks in.
resync_on_reconnect_timeout: 0
- 重启电脑
说不上为啥,但是可能会有意想不到的结果
- 重启网络服务
# 也许有好结果
sudo service network-manager restart
- 重启SSH,出现
Failed to start ssh.service: Unit ssh.service not found.
# node_manager提示:connect to host localhost port 22: Connection refused
# 重启SSH
$ sudo service ssh restart
>>> Failed to start ssh.service: Unit ssh.service not found.
# 安装SSH组件
$ sudo apt-get install ssh
# 卸载open-SSH组件
$ sudo apt-get remove openssh-client openssh-server
# 安装open-SSH组件
$ sudo apt-get install openssh-client openssh-server
# 查看相关组件
$ which ssh
$ which sshd
$ ssh localhost
# 远程连接:ssh username@IP_adrr
$ ssh [email protected]
- 注释
.bashrc
要通过SSH使用ROS,在Ubuntu 16系统上,用户必须在其.bashrc文件中注释以下行
- 使用不同的节点名称启动对应节点
# 在其中一台电脑设定节点名称,其中name前面有两单下划线【_ _】
rosrun master_discovery_fkie master_discovery _mcast_group:=224.0.0.1 __name:=master_discovery_ai
rosrun master_sync_fkie master_sync __name:=master_sync_ai
-
node_manager
是GUI调试界面
5. 错误备忘
- 出现
OSError:[Error 98] Address already in use
# 查找对应的进程的PID号
$ netstat -tunlp
# 结束当前进程,615为进程的PID号
$ kill -9 6135
- 出现
Master_discovery node appear not to running. Wait for topic with type 'MasterState
或Error while start RPC-XML server on port 11611: [Errno 98] Address already in use
sudo apt-get install ros-kinetic-multimaster-launch
rosrun master_discovery_fkie master_discovery _send_mcast:=Ture
- 出现
DeserializationError cannot deserialize: unknown error handler name ‘rosmsg‘
sudo apt-get install ros-kinetic-genpy
# 原因ros中的一些pkg的依赖pkg没有相对应的更新(虽然有但版本旧)
# 使用如下指令查看版本号
dpkg -l | grep genpy
-
rosdep update
出现ERROR: unable to process source
reading in sources list data from /etc/ros/rosdep/sources.list.d
ERROR: unable to process source [https://raw.githubusercontent.com/ros/rosdistro/master/rosdep/osx-homebrew.yaml]:
(https://raw.githubusercontent.com/ros/rosdistro/master/rosdep/osx-homebrew.yaml)
ERROR: unable to process source [https://raw.githubusercontent.com/ros/rosdistro/master/rosdep/base.yaml]:
(https://raw.githubusercontent.com/ros/rosdistro/master/rosdep/base.yaml)
ERROR: unable to process source [https://raw.githubusercontent.com/ros/rosdistro/master/rosdep/python.yaml]:
(https://raw.githubusercontent.com/ros/rosdistro/master/rosdep/python.yaml)
ERROR: unable to process source [https://raw.githubusercontent.com/ros/rosdistro/master/rosdep/ruby.yaml]:
(https://raw.githubusercontent.com/ros/rosdistro/master/rosdep/ruby.yaml)
ERROR: unable to process source [https://raw.githubusercontent.com/ros/rosdistro/master/releases/fuerte.yaml]:
Failed to download target platform data for gbpdistro:
Query rosdistro index https://raw.githubusercontent.com/ros/rosdistro/master/index-v4.yaml
ERROR: error loading sources list:
(https://raw.githubusercontent.com/ros/rosdistro/master/index-v4.yaml)>
- 系统设置没法点开
$ sudo apt-get install unity-control-center
# 需要重启,才能生效
- 终端编辑框没有颜色提示
# 修改 ~/.bashrc,
# 将里面的force_color_prompt=yes前面的注释‘#’去掉
- 防火墙阻挡
sudo apt-get install ufw
# 防火墙状态检查
sudo ufw status
# 关闭防火墙
sudo ufw disable
# 激活防火墙
sudo ufw enable
参考链接
1. Yaoyu Hu博客:Multimaster ROS configuration and multimaster_fkie
2. Yaoyu Hu博客:使用测试程序
3. multimaster_fkie配置中文翻译
4. ROS官网教程
5. Gazebo官网教程
6. node_manager教程
7. multi-master ROS systems
8. 官方项目地址
9. 从源码安装ROS包
10. sudo rosdep init出错