Using rqt consol and roslaunch
Using rqt_consol and roslaunch
If you have not installed the turtle sim and rqt packages do so before continuing:
sudo apt-get install ros-hydro-rqt ros-hydro-rqt-common-plugins ros-hydro-turtlesim
1) In a terminal, start roscore:
roscore
1) In a new terminal (terminal 2), start the ros_console:
rosrun rqt_console rqt_console
A window will pop up.
2) In a new terminal (terminal 3) begin the logger:
rosrun rqt_logger_level rqt_logger_level
A window will pop up.
3) In a new terminal (terminal 4) begin the turtle simulation:
rosrun turtlesim turtlesim_node
4) Change the logger level to Warn by refreshing the nodes in the rqt_logger_level window and selecting Warn.
5) In a new terminal (terminal 5) send a command to the sim:
rostopic pub /turtle1/cmd_vel geometry_msgs/Twist -r 1 -- '[2.0, 0.0, 0.0]' '[0.0, 0.0, 0.0]'
The logger will begin to print several warnings as expected.
6) Kill the simulation. Close terminal 5. Navigate to the beginners_tutorial package:
roscd beginner_tutorials
6b) If roscd says similar to roscd: No such package/stack 'beginner_tutorials' , you will need to source the environment
cd ~/catkin_ws source devel/setup.bash roscd beginner_tutorials
This must be done for each terminal you use
7) Make a launch directory:
mkdir launch cd launch
8) Create a newe file titled turtlemimic.launch and paste in the following:
<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>
9) In terminal 4, use roslaunch [package] [filename.launch] to run launch files that contain nodes:
roslaunch beginner_tutorials turtlemimic.launch
Two turtlesims will appear.
10) In a new terminal (terminal 5) send a command to the first simulation:
rostopic pub /turtlesim1/turtle1/cmd_vel geometry_msgs/Twist -r 1 -- '[2.0, 0.0, 0.0]' '[0.0, 0.0, -1.8]'
The command sent to the first turtle is mimicked by the second.