지지난 강의의 마지막 부분에 등장했던 /cmd_vel을 기억하시나요?

https://s3-us-west-2.amazonaws.com/secure.notion-static.com/593cb512-2045-48db-a445-5d5e4a1de818/Untitled.png

이는 command velocity의 약자로, 바퀴가 돌아가는 속도를 지정하여 로봇을 이동시킬 수 있는 topic입니다.

이번 시간에는 topic이 무엇인지와 topic의 주체가 되는 publisher, subscriber에 대해 배워봅니다.

우선, 예제를 먼저 실행시켜보겠습니다.

drive_forward 예제


몇가지 설정을 해줍니다.

$ roscd topic_tutorial
$ cd src && sudo chmod +x *
...
password 요구 시 입력
$ cd ../
$ cd launch && sudo chmod +x *

<aside> 💡 **chmod**를 통해 파일의 권한 설정이 가능합니다. root 권한이 아닌 일반 사용자 권한으로도 파일들을 실행 할 수 있게 하기 위해서 위 작업들을 해줍니다. 🙂

</aside>

이제는 익숙한 gazebo_world

$ roslaunch gcamp_gazebo gazebo_world.launch

새 터미널을 열고 예제를 실행시켜봅니다.

$ roslaunch topic_tutorial example1.launch
... logging to /home/kimsooyoung/.ros/log/4ba42dba-4f1e-11eb-bcd5-9cb6d08bf543/roslaunch-kimsooyoung-XPS-13-9370-26434.log
Checking log directory for disk usage. This may take a while.
Press Ctrl-C to interrupt
Done checking log file disk usage. Usage is <1GB.

started roslaunch server <http://localhost:36011/>

SUMMARY
========

PARAMETERS
 * /rosdistro: melodic
 * /rosversion: 1.14.10

NODES
  /
    DriveForward (topic_tutorial/example_1.py)

ROS_MASTER_URI=http://localhost:11311

process[DriveForward-1]: started with pid [26457]
[INFO] [1609827784.715571, 0.000000]: ==== DriveForward node Started, move forward during 10 seconds ====

[WARN] [1609827794.715846, 770.036000]:  10 seconds left, Stop!! 
[DriveForward-1] process has finished cleanly
log file: /home/kimsooyoung/.ros/log/4ba42dba-4f1e-11eb-bcd5-9cb6d08bf543/DriveForward-1*.log
all processes on machine have died, roslaunch will exit
shutting down processing monitor...
... shutting down processing monitor complete
done