1. 程式人生 > >ubuntu 18.04 melodic roslaunch :七步使用roslaunch控制兩個終端機器人

ubuntu 18.04 melodic roslaunch :七步使用roslaunch控制兩個終端機器人

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

[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]'