牟平网站建设,海外社交媒体平台,wordpress template_redirect,做墙报的网站1. 简介
多个 ros 系统之间可以通过配置 ros 主从机实现互相通信#xff0c;但有的场景每个 ros 系统都需要运行 rosmaster/roscore #xff0c;这种情况下就需要使用 multimaster_fkie 库来实现 ros 通信。 Github#xff1a;https://github.com/fkie/multimaster_fkie RO…1. 简介
多个 ros 系统之间可以通过配置 ros 主从机实现互相通信但有的场景每个 ros 系统都需要运行 rosmaster/roscore 这种情况下就需要使用 multimaster_fkie 库来实现 ros 通信。 Githubhttps://github.com/fkie/multimaster_fkie ROS wikihttp://wiki.ros.org/multimaster_fkie/Tutorials/Setup a ROS master synchronization
2. 安装 multimaster_fkie
多个 ros 系统中都要进行以下安装步骤
2.1. 安装 python grpc 工具
# # 比 ubuntu-18.04 更早的系统
# pip install grpcio-tools # 如果 ros 适配的是 python3 (viobot)# ubuntu-18.04
sudo add-apt-repository ppa:roehling/grpc
sudo apt update
sudo apt install python-grpcio python-grpc-tools# # ubuntu-18.10 以及更新的系统
# sudo apt install python-grpcio python-grpc-tools2.2. 安装 fkie_multimaster
# 新建一个空的 catkin_ws
mkdir -p ~/catkin_ws_for_build/src
cd ~/catkin_ws_for_build/src
git clone https://github.com/fkie/multimaster_fkie.git multimasterrosdep update
rosdep install -i --as-root pip:false --reinstall --from-paths multimastercd ..
catkin build fkie_multimaster如果最后的 catkin build 报错 catkin未找到命令 运行以下指令
sudo apt install python-catkin-tools2.3. 将安装好的库添加到 ros 环境和 python 环境中
在 ~/.bashrc 内添加以下 ros 环境变量
export ROS_PACKAGE_PATH$ROS_PACKAGE_PATH:~/catkin_ws_for_build/src将 catkin build 生成的 python 包移到 python 环境中
# 如果 ros 是 python2
sudo cp -r ~/catkin_ws_for_build/devel/lib/python2.x/dist-packages/* /usr/local/lib/python2.x/dist-packages/# # 如果 ros 是 python3
# sudo cp -r ~/catkin_ws_for_build/devel/lib/python3.x/dist-packages/* /usr/local/lib/python3.x/dist-packages/2.4. 设置网络 多个 ros 系统之间需要可以直接互相访问 ip 和全部端口即之间没有防火墙互相有线连接最佳。 在 /etc/hosts 文件中添加行 本机在网络中的 ip 本机 hostname分别可以用 hostname -I 和 hostname 命令查询得。 在 /etc/sysctl.conf 加入以下内容
net.ipv4.ip_forward1
net.ipv4.icmp_echo_ignore_broadcasts0使以上网络设置生效sudo service procps restart 测试能否 multicast 连通其他主机ping 224.0.0.1出现本机和他机的 ping 结果即为成功
3. 测试多 ros master 通信
多个 ros 系统中都在含有 fkie_master_xxx packages 的 python 环境中运行 multimaster_fkie
rosrun fkie_master_discovery master_discovery /dev/null 21
rosrun fkie_master_sync master_sync /dev/null 21 然后使用命令 rostopic list --host 查看可以访问的 rostopic出现本机以及他机的 rostopic 即为成功。