ubuntu 18.04 melodic roslaunch :七步使用roslaunch控制两个终端机器人

时间:2024-05-19 10:31:40

1,切换目录:

$ roscd beginner_tutorials

2,新建launch子目录:

$ mkdir launch

3,进入子目录:

$  cd launch

4,新建launch文件

$ gedit turtlemimic.launch

5,复制下面源码到turtlemimic.launch,然后保存并退出:

<launch>

  <group ns="turtlesim1">
    <node pkg="turtlesim" name="sim" type="turtlesim_node"/>
  </group>

  <group ns="turtlesim2">
    <node pkg="turtlesim" name="sim" type="turtlesim_node"/>
  </group>

  <node pkg="turtlesim" name="mimic" type="mimic">
    <remap from="input" to="turtlesim1/turtle1"/>
    <remap from="output" to="turtlesim2/turtle1"/>
  </node>

</launch>

6,运行roslaunch:

$ roslaunch beginner_tutorials turtlemimic.launch

ubuntu 18.04 melodic roslaunch :七步使用roslaunch控制两个终端机器人

[email protected]:~$ roscd beginner_tutorials
[email protected]:~/catkin_ws/src/beginner_tutorials$ mkdir launch
[email protected]:~/catkin_ws/src/beginner_tutorials$ ls
CMakeLists.txt  include  launch  package.xml  src
[email protected]:~/catkin_ws/src/beginner_tutorials$  cd launch
[email protected]:~/catkin_ws/src/beginner_tutorials/launch$

[email protected]:~/catkin_ws/src/beginner_tutorials/launch$ gedit turtlemimic.launch

[email protected]:~/catkin_ws/src/beginner_tutorials/launch$ [email protected]:~/catkin_ws/src/beginner_tutorials/launch$ roslaunch beginner_tutorials turtlemimic.launch
... logging to /home/uu/.ros/log/f0cf7f2e-a2cd-11e8-90ab-00216a949182/roslaunch-uu-HP-EliteBook-6930P-Notebook-PC-7213.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://uu-HP-EliteBook-6930P-Notebook-PC:33327/

SUMMARY
========

PARAMETERS
 * /rosdistro: melodic
 * /rosversion: 1.14.2

NODES
  /
    mimic (turtlesim/mimic)
  /turtlesim1/
    sim (turtlesim/turtlesim_node)
  /turtlesim2/
    sim (turtlesim/turtlesim_node)

auto-starting new master
process[master]: started with pid [7223]
ROS_MASTER_URI=http://localhost:11311

setting /run_id to f0cf7f2e-a2cd-11e8-90ab-00216a949182
process[rosout-1]: started with pid [7234]
started core service [/rosout]
process[turtlesim1/sim-2]: started with pid [7241]
process[turtlesim2/sim-3]: started with pid [7242]
process[mimic-4]: started with pid [7243]


7,打开新终端,发布运动会话:

$  rostopic pub /turtlesim1/turtle1/cmd_vel geometry_msgs/Twist -r 1 -- '[2.0, 0.0, 0.0]' '[0.0, 0.0, -1.8]'

 

ubuntu 18.04 melodic roslaunch :七步使用roslaunch控制两个终端机器人