ROS ๊ธฐ๋ณธ์ค์ต
- -
roscore๋ฅผ ์คํํด ๋ด ์๋ค
ํฐ๋ฏธ๋์ ์คํํ๊ณ , roscore๋ฅผ ์คํํด ๋ด ์๋ค.
์ด์ ๊ฐ๋ ์ค๋ช ์์ ๋ ธ๋๋ฅผ ์คํํ๊ธฐ ์ํด์ ๋ฐ๋์ master๊ฐ ํ์ํ๋ค๊ณ ํ์์ต๋๋ค. roscore๋ master, rosout, parameter server๋ฅผ ๋์์ ์คํํด ์ค๋๋ค.
$ roscore
... logging to /home/byeongkyu/.ros/log/21fb620a-a800-11ea-9d0f-00e18c79612a/roslaunch-byeongkyu-XPS-15-9570-12628.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://byeongkyu-XPS-15-9570:39705/
ros_comm version 1.14.5
SUMMARY
========
PARAMETERS
* /rosdistro: melodic
* /rosversion: 1.14.5
NODES
auto-starting new master
process[master]: started with pid [12648]
ROS_MASTER_URI=http://byeongkyu-XPS-15-9570:11311/
setting /run_id to 21fb620a-a800-11ea-9d0f-00e18c79612a
process[rosout-1]: started with pid [12659]
started core service [/rosout]
์๋๋ ๊ฐ ์ธ์ด๋ณ tutorial์ฉ ํจํค์ง๋ฅผ ์ค์นํด์ผ ํ์ง๋ง, ros-melodic-desktop-full์ ์ค์นํ๋ฉด ์ด๋ฏธ ์ค์น๋์ด ์์๊ฒ๋๋ค.
Node๋ฅผ ์คํํด ๋ด ์๋ค.
roscore๋ฅผ ์คํํ ์ํ์์, ํฐ๋ฏธ๋์ ํ๋ ๋ ์คํํ๊ณ ๋ค์๊ณผ ๊ฐ์ด ์ ๋ ฅํฉ๋๋ค.
$ rosrun roscpp_tutorials talker
[ INFO] [1591453178.734187896]: hello world 0
[ INFO] [1591453178.834246343]: hello world 1
[ INFO] [1591453178.934399239]: hello world 2
[ INFO] [1591453179.034471362]: hello world 3
[ INFO] [1591453179.134447388]: hello world 4
[ INFO] [1591453179.234447849]: hello world 5
ํ์ฌ talker๋ผ๋ ์คํ ํ์ผ์ด ์คํ๋์์ต๋๋ค. ์ด์ ๋ ธ๋ ํ๋๊ฐ ์คํ๋๊ณ ์๋ ์ํ์ ๋๋ค.
๋ ธ๋๋ฅผ ์คํํ๊ธฐ ์ํด์ rosrun์ด๋ผ๋ ๋ช ๋ น์ ์ฌ์ฉํ์ต๋๋ค.
$ rosrun -h
Usage: rosrun [--prefix cmd] [--debug] PACKAGE EXECUTABLE [ARGS]
rosrun will locate PACKAGE and try to find
an executable named EXECUTABLE in the PACKAGE tree.
If it finds it, it will run it with ARGS.
์คํ๋๊ณ ์๋ ๋ ธ๋๋ฅผ ์ข ๋ฃํ๋ ค๋ฉด? โ ํด๋น ํฐ๋ฏธ๋์์ ctrl+c๋ฅผ ๋๋ฌ์ค๋๋ค.
Command tools related with nodes
๋ ธ๋์ ๊ด๋ จํ ์ฌ๋ฌ๊ฐ์ง ๋๊ตฌ๋ค์ด ์กด์ฌํฉ๋๋ค. ๋ ธ๋๊ฐ ์คํ๋ ์ํ์์, ํฐ๋ฏธ๋์ ํ๋ ๋ ์ด๊ณ ๋ค์์ ๋ช ๋ น์ด๋ค์ ์คํํด๋ด ์๋ค.
$ rosnode list
/rosout
/talker
$ rosnode info talker
--------------------------------------------------------------------------------
Node [/talker]
Publications:
* /chatter [std_msgs/String]
* /rosout [rosgraph_msgs/Log]
Subscriptions: None
Services:
* /talker/get_loggers
* /talker/set_logger_level
contacting node http://byeongkyu-XPS-15-9570:34539/ ...
Pid: 13188
Connections:
* topic: /rosout
* to: /rosout
* direction: outbound (45503 - 127.0.0.1:44826) [11]
* transport: TCPROS
node์ ๊ด๋ จํด์ rosnode๋ผ๋ ๋๊ตฌ๋ฅผ ์ฌ์ฉํฉ๋๋ค. ์ฌ๋ฌ๊ฐ์ง ๊ธฐ๋ฅ์ ์ํํ ์ ์์ต๋๋ค.
$ rosnode -h
rosnode is a command-line tool for printing information about ROS Nodes.
Commands:
rosnode ping test connectivity to node
rosnode list list active nodes
rosnode info print information about node
rosnode machine list nodes running on a particular machine or list machines
rosnode kill kill a running node
rosnode cleanup purge registration information of unreachable nodes
Type rosnode <command> -h for more detailed usage, e.g. 'rosnode ping -h'
Understanding ROS Nodes
- ๋ ธ๋์ ์ด๋ฆ์ ์ ์ผํด์ผํจ, ๋์ผํ ๋ ธ๋ ์ด๋ฆ์ผ๋ก ์คํํ๋ฉด ์ด์ ์ ์คํ๋์๋ ๋ ธ๋๊ฐ ์๋์ผ๋ก ์คํ ์ข ๋ฃ
- ์คํํ์ผ๋ช ์ด ์๋๋ผ, ๋ ธ๋์ ์ด๋ฆ์ด๋ผ๋ ๊ฒ์ ์ ์!
- talker ๋ ธ๋ ์ด๋ฆ ๊ธฐ๋ณธ๊ฐ์ talker
- ์คํ ์ ๋ ธ๋์ ์ด๋ฆ์ ๋ฐ๊พธ๋ ค๋ฉด? โ __name ์ ์ฌ์ฉ
$ rosrun roscpp_tutorials talker __name:=another_talker
๋ ธ๋๋ค์ด ์คํ๋์ด ์๋ ์ํ๋ฅผ ๋ณด๊ณ ์ถ์ ๋, rosnode๋ฅผ ์ฌ์ฉํ์ง๋ง, GUI ๋๊ตฌ๋ ์กด์ฌํฉ๋๋ค.
$ rqt_graph

talker ๋ ธ๋๋ฅผ ์ข ๋ฃํฉ๋๋ค. roscore๋ ๋๋์ธ์~
Understanding ROS Topics
์ด์ ํฐ๋ฏธ๋์ ๋๊ฐ ์คํํ๊ณ , ๊ฐ๊ฐ์ ํฐ๋ฏธ๋์์ ๋ค์๊ณผ ๊ฐ์ด ์คํํด ์ค๋๋ค.
$ rosrun roscpp_tutorials talker
$ rosrun roscpp_tutorials listener
ํฐ๋ฏธ๋์ ํ๋ ๋ ์คํํ๊ณ , ์๊น ๋ฐฐ์ ๋ rosnode๋ฅผ ์ฌ์ฉํด๋ด ์๋ค.
$ rosnode list
/listener
/rosout
/talker
๋ ๊ฐ์ ๋ ธ๋๊ฐ ์คํ๋๊ณ ์์ต๋๋ค. rqt_graph๋ฅผ ์คํํด ๋ณผ๊น์?

talker, listener ๋ ธ๋๊ฐ ์คํ๋์ด ์๊ณ , chatter๋ผ๋ ํ ํฝ์ ์ด์ฉํด ์ฐ๊ฒฐ์ด ๋์ด ์์ต๋๋ค. ํฐ๋ฏธ๋์์๋ ๋ณผ ์ ์๋ค์ํผ, talker ๋ ธ๋๊ฐ listener ๋ ธ๋์๊ฒ ๋ฐ์ดํฐ๋ฅผ ์ ๋ฌํด ์ฃผ๊ณ ์๋ ๊ฒ์ ํ์ธํ ์ ์์ต๋๋ค.
Command tools related with topics
rostopic ๋๊ตฌ๋ฅผ ์ด์ฉํด์ ํ ํฝ์ ๊ด๋ จํ ๋ค์ํ ๊ธฐ๋ฅ์ ์ํํ ์ ์์ต๋๋ค. (์ถํ ์์ฃผ ๋ง์ด ์ฌ์ฉ๋ฉ๋๋ค.)
$ rostopic list
/chatter
/rosout
/rosout_agg
$ rostopic -h
rostopic is a command-line tool for printing information about ROS Topics.
Commands:
rostopic bw display bandwidth used by topic
rostopic delay display delay of topic from timestamp in header
rostopic echo print messages to screen
rostopic find find topics by type
rostopic hz display publishing rate of topic
rostopic info print information about active topic
rostopic list list active topics
rostopic pub publish data to topic
rostopic type print topic or field type
Type rostopic <command> -h for more detailed usage, e.g. 'rostopic echo -h'
ํ ํฝ์ ์ ๋ณด ํ์ธ
$ rostopic info /chatter
Type: std_msgs/String
Publishers:
* /talker (http://byeongkyu-XPS-15-9570:37369/)
Subscribers:
* /listener (http://byeongkyu-XPS-15-9570:43897/)
ํ ํฝ์ ๋ด์ฉ ํ์ธ
$ rostopic echo /chatter
data: "hello world 326"
---
data: "hello world 327"
---
data: "hello world 328"
---
data: "hello world 329"
---
data: "hello world 330"
---
ํ ํฝ์ ํ์ ํ์ธ
$ rostopic type /chatter
std_msgs/String
ํ ํฝ์ด ์ผ๋ง๋ ์์ฃผ publish๋๊ณ ์๋๊ฐ?
$ rostopic hz /chatter
subscribed to [/chatter]
average rate: 9.994
min: 0.099s max: 0.101s std dev: 0.00042s window: 9
average rate: 10.000
min: 0.099s max: 0.101s std dev: 0.00047s window: 19
๋ฌผ๋ก GUI ๋๊ตฌ๋ ์กด์ฌํฉ๋๋ค.
$ rosrun rqt_topic rqt_topic

Remapping Topics
- โtalkerโ ๋ ธ๋๋ โchatterโ๋ ํ ํฝ ์ด๋ฆ์ผ๋ก publish ํ๊ณ ์๊ณ , โlistenerโ ๋ ธ๋๋ โchatterโ๋ ํ ํฝ ์ด๋ฆ์ subscribe ํ๊ณ ์๋ค.
- ํ ํฝ ์ด๋ฆ์ ๋ฐ๊พธ๋ ค๋ฉด?
- ์ฝ๋๋ฅผ ๋ฐ๊พผ๋ค โ ํ์ํ ๋๋ง๋ค ์ฝ๋๋ฅผ ๋ฐ๊พธ๊ณ ๋น๋ฉํ๊ณ ... โ ๋ฒ๊ฑฐ๋กญ๋ค
- ์ด๋ด๋ remapping ๊ธฐ๋ฅ ์ฌ์ฉ :=
$ rosrun roscpp_tutorials talker chatter:=another_chatter
rostopic์ผ๋ก ํ์ธํด ๋ด ์๋ค.
$ rostopic list
/another_chatter
/rosout
/rosout_agg
roslaunch ํ์ฉํ๊ธฐ







๋งค๋ฒ ๋ ธ๋๋ฅผ ์คํํ ๋๋ง๋ค rosrun์ ์ด์ฉํ๋ฉด ๋งค์ฐ ๋ถํธํฉ๋๋ค. ํ๊บผ๋ฒ์ ์คํํ ์ ์๋, ๋ remapping์ด๋ ๋ ธ๋์ ์ด๋ฆ์ ์ฝ๊ฒ ์ค์ ํ ์ ์๋ ๋ฐฉ๋ฒ์ด ์์ด์ผ ํ๊ฒ ์ฃ ?
์ด๋ด๋ roslaunch๋ฅผ ์ฌ์ฉํฉ๋๋ค.
$ roslaunch -h
Usage: roslaunch [options] [package] <filename> [arg_name:=value...]
roslaunch [options] <filename> [<filename>...] [arg_name:=value...]
If <filename> is a single dash ('-'), launch XML is read from standard input.
roslaunch (http://wiki.ros.org/roslaunch)๋ฅผ ๊ฐ๋จํ๊ฒ ์๊ฐํ๋ฉด,8
- XML ํฌ๋ฉง์ผ๋ก ์์ฑ
- ํจํค์ง ๋ด์ launch ๋๋ ํ ๋ฆฌ ๋ด์ ๋ง๋๋ ๊ฒ์ด ํต์์ ์
- ํ์ฅ์๋ .launch
- roslaunch ๋ด์ ์คํ๋๋ node ๋ค์ ๋ํด ์คํ ์ฐ์ ์์๋, ๋๊ธฐ ํ ์คํ ๊ธฐ๋ฅ์ ์์
- roslaunch๋ฅผ ์ด์ฉํ์ฌ ์คํํ๋ ๊ฒฝ์ฐ, roscore๊ฐ ์คํ๋์ด ์์ง ์์ ๊ฒฝ์ฐ์ ์๋์ผ๋ก ์คํ
$ roslaunch roscpp_tutorials talker_listener.launch
์ ํ์ผ ๋ด์ฉ์ ์ดํด๋ณผ๊น์?
$ rosed roscpp_tutorials talker_listener.launch
<launch>
<node name="listener" pkg="roscpp_tutorials" type="listener" output="screen"/>
<node name="talker" pkg="roscpp_tutorials" type="talker" output="screen"/>
</launch>
- ๋ ธ๋์ ์ด๋ฆ, ํจํค์ง, ์คํํ์ผ๋ช ์ ์ ์ด์ค๋ค
- output์ sysout์ ์ถ๋ ฅ ๋ฐฉํฅ. screen์ ๋ณด๊ณ ์๋ ํ๋ฉด์ผ๋ก, log๋ log๋ก...
- roslaunch์ ๋ด๋ถ ์ต์ ์ ์ด๊ฒ๋ณด๋ค ํจ์ฌ ๋ง๊ณ ๋ ๋ณต์กํจ, ์ฐจ์ธฐ ๋ฐฐ์๋ด๊ฐ์๋ค.
- ๋ค ์์ธํ ๋ด์ฉ์ ์ํค ์ฐธ๊ณ : http://wiki.ros.org/roslaunch/Tutorials/Roslaunch tips for larger projects
๋ค์ ์ค์ต์ ์ํด roscore๋ฅผ ์ ์ธํ ๋๋จธ์ง๋ ์ ๋ถ ์ข ๋ฃํฉ๋๋ค.
Understanding ROS Services
ํฐ๋ฏธ๋์ ์ด๊ณ ์๋น์ค๋ฅผ ์ ๊ณตํ๋ ๋ ธ๋๋ฅผ ์คํํด ๋ด ์๋ค.
$ rosrun roscpp_tutorials add_two_ints_server
Command tools related with service
$ rosservice -h
Commands:
rosservice args print service arguments
rosservice call call the service with the provided args
rosservice find find services by service type
rosservice info print information about service
rosservice list list active services
rosservice type print service type
rosservice uri print service ROSRPC uri
Type rosservice <command> -h for more detailed usage, e.g. 'rosservice call -h'
$ rosservice list
/add_two_ints
/add_two_ints_server/get_loggers
/add_two_ints_server/set_logger_level
/rosout/get_loggers
/rosout/set_logger_level
- โadd_two_ints_serverโ ๋ ธ๋๋ โ/add_two_intsโ ์๋น์ค๋ฅผ ์ ๊ณต ์ค
- ์ด๋ป๊ฒ ์ฌ์ฉํ์ง?
- ์๋น์ค๋ฅผ ํธ์ถ(call)ํ๊ธฐ ์ํ ํด๋ผ์ด์ธํธ ๋ ธ๋๋ฅผ ๋ง๋ ๋ค
- rosservice๋ฅผ ์ด์ฉํด์ ํธ์ถ
$ rosrun roscpp_tutorials add_two_ints_client 1 2
[ INFO] [1571110622.533042405]: Sum: 3
$ rosservice call /add_two_ints "{a: 1, b: 3}"
sum: 4
๋ค์ ์ค์ต์ ์ํด roscore๋ฅผ ์ ์ธํ ๋๋จธ์ง์ ๋ํด ์คํ์ ์ข ๋ฃํฉ๋๋ค.
Understanding ROS Parameters
ํ๋ผ๋ฏธํฐ ์๋ฒ๋ roscore๊ฐ ์คํ๋๋ฉด ์๋์ผ๋ก ์คํ๋ฉ๋๋ค.
- Parameter Server์ ๋ฐ์ดํฐ๋ฅผ ์ ์ฅํ๊ฑฐ๋, ๋ถ๋ฌ์ฌ ์ ๋ ์์
- Parameter ๊ด๋ จ ๋ช ๋ น์ rosparam์ผ๋ก...
$ rosparam -h
rosparam is a command-line tool for getting, setting, and deleting parameters from the ROS Parameter Server.
Commands:
rosparam set set parameter
rosparam get get parameter
rosparam load load parameters from file
rosparam dump dump parameters to file
rosparam delete delete parameter
rosparam list list parameter names
$ rosparam get /rosversion
'1.14.5
'
Understanding ROS Actionlib
ํฐ๋ฏธ๋์ ๋ค์์ ๋ ธ๋๋ฅผ ์คํํฉ๋๋ค.
$ rosrun actionlib_tutorials fibonacci_server
๋ ๋ค๋ฅธ ํฐ๋ฏธ๋์ ์ด๊ณ , action client๋ฅผ ์คํํด ์ค๋๋ค.
$ rosrun actionlib_tutorials fibonacci_client
์ ์์ ๋ ํผ๋ณด๋์น ์์ด์ ์์ฑํ๋ action ์๋ฒ๋ฅผ ์คํํ๊ณ , action ํด๋ผ์ด์ธํธ๋ ์ํ๋ ํผ๋ณด๋์น ์์ด์ order๋ฅผ goal๋ก ์ ๋ฌํ๊ณ feedback, result๋ฅผ ๋ฐ์ต๋๋ค.

$ rosrun actionlib_tutorials fibonacci_server
[ INFO] [1591456445.176265355]: fibonacci: Executing, creating fibonacci sequence of order 20 with seeds 0, 1
[ INFO] [1591456465.176437858]: fibonacci: Succeeded
$ rosrun actionlib_tutorials fibonacci_client
[ INFO] [1591456560.593028380]: Waiting for action server to start.
[ INFO] [1591456560.820829838]: Action server started, sending goal.
[ INFO] [1591456580.821435336]: Action finished: SUCCEEDED
fibonacci_client๊ฐ ์คํํ๋ ๋์ค, ์๋ฒ์ feedback ๋ฉ์์ง๊ฐ ์ด๋ค ๋ด์ฉ์ ๋ณด๋ด์ค๋์ง ํ์ธํด ๋ด ์๋ค.
$ rostopic echo /fibonacci/feedback
header:
seq: 40
stamp:
secs: 1591456685
nsecs: 263520350
frame_id: ''
status:
goal_id:
stamp:
secs: 1591456685
nsecs: 263147318
id: "/test_fibonacci-1-1591456685.263147318"
status: 1
text: "This goal has been accepted by the simple action server"
feedback:
sequence: [0, 1, 1]
---
๋ค์ ์งํ์ ์ํด ๋ชจ๋ ํฐ๋ฏธ๋์ ์ข ๋ฃํฉ๋๋ค.
Uploaded by N2T
'python > ROS' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
ROS ๊ฐ์ (0) | 2023.04.06 |
---|---|
ROS ๊ธฐ๋ณธ์ฉ์ด: ๊ทธ๋ํ ๋ ๋ฒจ (0) | 2023.04.06 |
ROS ๊ธฐ๋ณธ์ฉ์ด: ํ์ผ์์คํ ๋ ๋ฒจ (0) | 2023.04.06 |
๋์คํฌ ๊ณต๊ฐ ํ๋ณดํ ์ฐ๋ถํฌ ์ค์น (0) | 2023.04.04 |
ROS ๊ธฐ๋ณธ๋ช ๋ น์ด (0) | 2023.04.04 |
์์คํ ๊ณต๊ฐ ๊ฐ์ฌํฉ๋๋ค