[ROS 프로그래밍] 4. ROS 원격 노드 통신(1)

YH·2023년 9월 4일
0

4. ROS 원격 노드 통신(1)

1) ROS 원격통신

  • Publisher 노드의 정보(turtle_teleop_key)

    /teleop_turtle
    /turtle1/cmd_vel
    geometry_msgs/Twist
    http://192.168.1.25

  • Subscriber 노드의 정보(turtlesim_node)

    /turtlesim
    /turtle1/cmd_vel
    geometry_msgs/Twist
    http://192.168.1.12

  • 마스터 Core가 노드 정보를 관리하며, 노드1(turtle_teleop_key)에서 노드2(turtlesim_node)로 /turtle1/cmd_vel 토픽을 전송

2) ROS 원격통신을 위한 환경 설정

  • IP 주소 설정
    • $ sudo gedit ~/.bashrc
      • ROS_MASTER_URI = roscore가 구동되는 장치(Xycar)의 IP 주소
      • ROS_HOSTNAME = 내 PC/노트북의 IP 주소
    • $ source .bashrc (수정한 내용을 시스템에 반영)
...
alias cm='cd ~/xycar_ws && catkin_make'
source /opt/ros/kinetic/setup.bash
source ~/xycar_ws/devel/setup.bash
export ROS_MASTER_URI=http://192.168.0.5:11311
export ROS_HOSTNAME=192.168.0.11

3) ROS 원격통신 실습

  • 원격통신 실행
    • $ rosrun turtlesim turtle_teleop_key
  • 노드간 메시지 흐름 확인
    • 새로운 터미널 창을 열어서 작업
    • $ rostopic list
    • $ rosnode info /turtlesim
    • $ rostopic echo /turtle1/cmd_vel
    • $ rqt_graph
profile
Keep Recycling Your Dreams

0개의 댓글

관련 채용 정보