[ROS STUDY] ROS 4강

‍이수빈·2025년 2월 10일

[ROS STUDY]

목록 보기
4/12

출처: YOUTUBE: ROS 1 (04강 of 25강) - Developers and Creators

ROS Basic Process

$ cd ~/gcamp_ws
$ sds

$ roslaunch gcamp_gazebo gazebo_world.launch 

... logging to /home/kimsooyoung/.ros/log/7f9651be-4e53-11eb-b4c9-9cb6d08bf543/roslaunch-kimsooyoung-XPS-13-9370-32277.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.

xacro: in-order processing became default in ROS Melodic. You can drop the option.
started roslaunch server http://localhost:35661/

SUMMARY
========

PARAMETERS
 * /gazebo/enable_ros_network: True
 * /joint_state_publisher/use_gui: False
 * /robot_description: <?xml version="1....
 * /rosdistro: melodic
 * /rosversion: 1.14.10
 * /use_sim_time: True

NODES
  /
    gazebo (gazebo_ros/gzserver)
    gazebo_gui (gazebo_ros/gzclient)
    joint_state_publisher (joint_state_publisher/joint_state_publisher)
    robot_state_publisher (robot_state_publisher/robot_state_publisher)
    rviz (rviz/rviz)
    urdf_spawner (gazebo_ros/spawn_model)

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

위 코드 중 NODE와 master 부분에 집중해 보고자 함.

NODE

ROS는 각 프로세스를 NODE의 단위로 관리함.

노드간 데이터를 공유를 위해서는, 노드 정보 공유가 필요함(노드 생성 정보, id 정보 등)
이걸 관리해주는 것: ROS Master

roscore command

started roslaunch server http://localhost:41409/
ros_comm version 1.14.10


SUMMARY
========

PARAMETERS
 * /rosdistro: melodic
 * /rosversion: 1.14.10

NODES

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

setting /run_id to 6f20f9e2-4e58-11eb-b4c9-9cb6d08bf543
process[rosout-1]: started with pid [3576]
started core service [/rosout]

roscore는 ROS Master를 실행시키는 명령임.

  • ROS Master는 하나만 존재할 수 있으며, 여러번 실행시킬 시 하단과 같은 오류가 발생함.
RLException: roscore cannot run as another roscore/master is already running. 
Please kill other roscore/master processes before relaunching.
The ROS_MASTER_URI is http://localhost:11311/
The traceback for the exception was written to the log file
  • roslaunch를 통해 실행시키면, ROS Master도 자동으로 함께 실행됨.
$ roslaunch gcamp_gazebo gazebo_world.launch 

(...)
auto-starting new master
process[master]: started with pid [32301]
ROS_MASTER_URI=http://localhost:11311

rosnode command

현재 작동 중인 노드 리스트를 확인하고 싶다면 하단 커멘드 사용하면 됨.

앞서 gazebo_world.launch는 launch 파일이기에, 이를 실행시키면 자동으로 ROS Master가 실행된다고 했음.

$ roslaunch gcamp_gazebo gazebo_world.launch

# 새 터미널을 열고 다음 커맨드를 입력합니다.
$ rosnode list
/gazebo
/gazebo_gui
/joint_state_publisher
/robot_state_publisher
/rosout

ROS Master와 관련있는 Node는 /rosout 임.

또한, 나머지 4개의 Node가 실행중인데,
gazebo 관련 Node 2개, gazebo 상에서 로봇을 spawn 시키고, 로봇의 여러 상태를 지속적으로 송신하는 Node가 2개 실행 중임.

추가적으로, 특정 Node에 대한 상세 정보를 얻고 싶다면, 하단 커맨드를 사용하면 됨.


$ rosnode info /joint_state_publisher
Node [/joint_state_publisher]
Publications: 
 * /joint_states [sensor_msgs/JointState]
 * /rosout [rosgraph_msgs/Log]

Subscriptions: 
 * /clock [rosgraph_msgs/Clock]

Services: 
 * /joint_state_publisher/get_loggers
 * /joint_state_publisher/set_logger_level


contacting node http://localhost:42569/ ...
Pid: 4086
Connections:
 * topic: /joint_states
    * to: /robot_state_publisher
    * direction: outbound (40207 - 127.0.0.1:33150) [14]
    * transport: TCPROS
 * topic: /rosout
    * to: /rosout
    * direction: outbound (40207 - 127.0.0.1:33148) [10]
    * transport: TCPROS
 * topic: /clock
    * to: /gazebo (http://localhost:42511/)
    * direction: inbound
    * transport: TCPROS
(...)
  • 해당 Node와 데이터 공유를 하는 다른 Node는 무엇이 있는지, 공유를 통해 오가는 데이터가 무엇인지 확인할 수 있음.
  • 더불어, 해당 Node에서 파생되는 여러 통신들에 대한 정보를 얻을 수 있음.

rqt

좀 더 시각적으로 확인하기 위해 rqt를 사용함.

하단 코맨드를 입력하면, QT window가 뜨게 될 것이고,

$ rqt_graph


상단과 같은 옵션들이 여러가지 보이게 됨.

최종적으로는 하단과 같이 그래프가 배치되게 됨.

이를 통해, 앞서 알아본 각 Node가 어떠한 구조로 구성되어 있는지 확인할 수 있음.
더 편리하고 효율적으로 파악이 가능하고, 이렇게 본 후 더 자세하게 알고 싶은 내용을 rosnode 커맨드를 입력해서 또 검색하면 됨.

그래프 속 화살표의 의미?
: Node 간 통신이 이루어지고 있음(or 이루어졌음)을 의미(→디버깅 시 유용)


하단 코맨드를 사용하면 teleop_twist_keyboard 라는 Node가 추가됨. 또한 /cmd_vel을 통해 /gazebo와 연결됨.

$ rosrun teleop_twist_keyboard teleop_twist_keyboard.py

teleop_twist_keyboard 라는 Node에 대해 더 알아보기 위해 rosnode info입력.

$ rosnode info /teleop_twist_keyboard
--------------------------------------------------------------------------------
Node [/teleop_twist_keyboard]
Publications: 
 * /cmd_vel [geometry_msgs/Twist]
 * /rosout [rosgraph_msgs/Log]

Subscriptions: 
 * /clock [rosgraph_msgs/Clock]

Services: 
 * /teleop_twist_keyboard/get_loggers
 * /teleop_twist_keyboard/set_logger_level


contacting node http://localhost:42905/ ...
Pid: 6480
Connections:
 * topic: /rosout
    * to: /rosout
    * direction: outbound (34171 - 127.0.0.1:45192) [9]
    * transport: TCPROS
 * topic: /cmd_vel
    * to: /gazebo
    * direction: outbound (34171 - 127.0.0.1:45194) [13]
    * transport: TCPROS
 * topic: /clock
    * to: /gazebo (http://localhost:42511/)
    * direction: inbound
    * transport: TCPROS

해당 노드의 추가적인 부분은 다음 강의에서 진행된다고 함.

profile
🏫 Kookmin University, Major in Electrical Engineering (First Major), AI Big Data & Management (Double Major), Smart Car ICT (Interdisciplinary Major)

0개의 댓글