赞
踩
做ROS机器人编队的时候,每次启动总是需要远程连接到机器人端再分别启动节点,属实很麻烦。故需设计功能来实现在电脑主机中远程启动三个ROS机器人中的节点,节点包括底层驱动节点和UWB定位节点。
【robot1IP地址】 【robot1名字】
【robot2IP地址】 【robot2名字】
【robot3IP地址】 【robot3名字】
在三个机器人端分别编辑/etc/hosts文件,添加:
【主机IP地址】 【主机名字】
#!/bin/bash
export ROSLAUNCH_SSH_UNKNOWN=1
export ROS_MASTER_URI=http://【server IP】:11311
source /opt/ros/melodic/setup.bash
source ~/catkin_ws/devel/setup.bash
export ROS_HOSTNAME=【robot1 IP】
exec "$@"
<launch> <machine name="xtark1" user="xtark" password="xtark" address="192.168.1.104" env-loader="/home/xtark/ros_ws/devel/car_env.sh"/> <param name="use_sim_time" value="false"/> <group ns="car1"> <!-- 启动xtark_driver驱动包 --> <node machine="xtark1" pkg="xtark_driver" name="xtark_driver" type="xtark_driver" output="screen" respawn="true" > <rosparam file="$(find car1)/config/xtark1_params.yaml" command="load"/> <param name="publish_odom_transform" value="true"/> <param name="odom_frame" value="/odom"/> </node> <!-- 启动tf --> <node machine="xtark1" pkg="tf" type="static_transform_publisher" name="base_footprint_to_imu" args="0.0 0 0.05 0 0 0 base_footprint base_imu_link 20"/> <!-- 启动nlink_parser驱动包 --> <node machine="xtark1" pkg="nlink_parser" type="linktrack" name="linktrack0" output="screen"> <param name="port_name" value="/dev/ttyUSB0" /> <param name="baud_rate" value="921600" /> </node> <!-- 启动获取UWB位置 --> <node machine="xtark1" name="uwb_position" pkg="uwb_position" type="uwb_position.py" output="screen" respawn="false"/> </group> </launch>
在launch文件中需要先设置<mathine>
tag,其中需要设置name user password address
等属性,之后再<node>
中添加 machine="machine_name"
即可。
<launch> <machine name="xtark2" user="xtark" password="xtark" address="192.168.1.102" env-loader="/home/xtark/ros_ws/devel/car_env.sh"/> <group ns="car2"> <param name="use_sim_time" value="false"/> <!-- 启动xtark_driver驱动包 --> <node machine="xtark2" pkg="xtark_driver" name="xtark_driver" type="xtark_driver" output="screen" respawn="true" > <rosparam file="$(find car1)/config/xtark2_params.yaml" command="load"/> <param name="publish_odom_transform" value="true"/> <param name="odom_frame" value="/odom"/> </node> <node machine="xtark2" pkg="tf" type="static_transform_publisher" name="base_footprint_to_imu" args="0.0 0 0.05 0 0 0 base_footprint base_imu_link 20"/> <!-- 启动nlink_parser驱动包 --> <node machine="xtark2" pkg="nlink_parser" type="linktrack" name="linktrack0" output="screen"> <param name="port_name" value="/dev/ttyUSB0" /> <param name="baud_rate" value="921600" /> </node> <!-- 启动获取UWB位置 --> <node machine="xtark2" name="uwb_position" pkg="uwb_position" type="uwb_position.py" output="screen" respawn="false"/> </group> </launch>
<launch> <machine name="xtark3" user="xtark" password="xtark" address="192.168.1.103" env-loader="/home/xtark/ros_ws/devel/car_env.sh"/> <group ns="car3"> <param name="use_sim_time" value="false"/> <!-- 启动xtark_driver驱动包 --> <node machine="xtark3" pkg="xtark_driver" name="xtark_driver" type="xtark_driver" output="screen" respawn="true" > <rosparam file="$(find car1)/config/xtark3_params.yaml" command="load"/> <param name="publish_odom_transform" value="true"/> <param name="odom_frame" value="/odom"/> </node> <node machine="xtark3" pkg="tf" type="static_transform_publisher" name="base_footprint_to_imu" args="0.0 0 0.05 0 0 0 base_footprint base_imu_link 20"/> <!-- 启动nlink_parser驱动包 --> <node machine="xtark3" pkg="nlink_parser" type="linktrack" name="linktrack0" output="screen"> <param name="port_name" value="/dev/ttyUSB0" /> <param name="baud_rate" value="921600" /> </node> <!-- 启动获取UWB位置 --> <node machine="xtark3" name="uwb_position" pkg="uwb_position" type="uwb_position.py" output="screen" respawn="false"/> </group> </launch>
<launch>
<include file="$(find car1)/launch/car1_driver.launch"/>
<include file="$(find car1)/launch/car2_driver.launch"/>
<include file="$(find car1)/launch/car3_driver.launch"/>
</launch>
rm ~/.ssh/known_hosts
ssh -oHostKeyAlgorithms='ssh-rsa' 【tx2用户名】@【tx2计算机名】
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。