ROS

ROS Computation Graph

meenyminy 2024. 7. 28. 18:13

노드는 c++또는 파이썬 프로그램일 수 있따.모든 노드는 다른 노드들과 communication될 수 있다.가장 흔한 communication은 publisher와 subscriber 노드이다. 특정 topic을 이용해 publisher가 subscriber에게 communicatikon을 한다. 

두번ㅈ째 ROS SERVICES

CLIENT가 SERVER에게 REQUEST를 보내고 SERVER는 CLIENT에게 RESPONSE를 보냄. 클라이언트가 메시지를 보내면 서버가 응답할 때 까지 기다려야함

세번째 ACTION

SERVER와 비슷하고 다른 점은 완전히 비동기적이라는 점이다. 클라이언트가 특정 GOAL을 SERVER에게 보내서 서버가 실행하는 동안 CLIENT는 병렬적으로 다른 것을 할 수 있따. 그러는 동안 ACTION SERVER는 FEED BACK를 CLIENT에게 보낸다. 그리고 GOAL이 완료되면 결과를 CLIENT에게 보낸다

 

ROS COMPUTATION GRAPH

 1. ROS MASTER에게 난 로봇이고, turtlesim이라고 불려. cmd_vel이라는 메시지를 받을 수 있고 메시지 타입을 Twist로 지정할 수 있음. 

2. 로봇을 작동할 수 있는 다른 노드 또한 ros master에게 contact해 같음 메시지 토픽(cmd_vel)을 공표함.

3. roscore가 subscriber에게 정보를 제공함.

4. 마지막으로 발행자와 구독자 사이에 소통이 이루어짐

 

터미널 1

1. roscore실행

$ roscore

...

 PARAMETERS 
 * /rosdistro: noetic
 * /rosversion: 1.15.8 
 
 NODES
 auto-starting new master
 process[master]: started with pid [4488]
 ROS_MASTER_URI:http://ubuntu:11311/ # 로스 서버가 실행되는 포트 번호
 
 ...

 

cf) 

rosnode list: ROS computation graph에서 실행되는 노드의 리스트 (/rosout: roscore)

rostopic list: ROS computation graph에서 실행되는 토픽들의 리스트

 

터미널 2

1. 노드 실행시키기

$ rosrun turtlesim turtlesim_node

 

rosrun: node를 실행시키는 ros 언어

turtlesim: ROS node가 저장되어있는 ROS package 이름

turtlesim_node: 실행하고자하는 스크립트 혹은 코드

 

이때 $ rostopic list를 보면

/rosout

/rosout_agg

/turtle1/cmd_vel

/turtle1/color_sensor

/turtle1/pose

가 있다. 

 

터미널 3

1. 노드 실행시키기

$ rosrun turtlesim turtle_teleop_key

 

이때 $ rostopic list를 보면

/rosout

/rosout_agg

/turtle1/cmd_vel

/turtle1/color_sensor

/turtle1/pose

그대로다. 그 이유는 teleop도 turtlesim과 동일한 topic을 사용하니까. 

cmd_vel은 teleop turtle이 publish햇고, turtle_sim이 subscribe했다. 

 

rosnode info / turtlesim을 보면

publications:

* /rosout [rosgraph_msgs/Log]

* /turtle1/color_sensor [turtlesim/COlor]

* /turtle1/pose [turtlesim/Pose] : 거북이의 x,y 좌표는 publish 됨

 

Subscriptions:

*/turtle1/cmd_vel [geometry_msgs/Twist] : command velocity 를 다른 노드로 부터 받아 움직임. teleop_key를 통해 명령을 받음

cf) Message Type

geometry_msgs/Twist에서 geometry_msgs: ROS 메시지가 있는 로스 패키지

Twist: ROS 메시지

즉, Twist 메시지가 eometry_msgs에 속해있다는 것!

Vector3는 geometry_msgs에 속한 메시지로 float64 x,y,z를 포함하고 있다. 선형 메시지로 linear number of vecotr3가 있고, 회전하는 각도 vector3 (x,y,z)가 있다. 

 

 

Services:

* /clear

* /kill

rosnode

rostopic info /turtle1/cmd_vel

Publishers:

* /teleop_turtle 

 

Subscribers:

* /turtlesim

 

 

 

ROS 메시지의 내용을 보고 싶다면

rosmsg show geometry_msgs/Twist

rosmsg: 메시지를 위한 ros 명령어

show: show 명령어

geometry_msgs/Twist: 보여주고자하는 메시지

pose에도 두 개의 component가 존재. 1. positoin 2. /Quaternion orientation (ROS에서 방향을 나타내는 표준 방식)

 

Publish a message on a topic (cmd line)

속도 명령어

rostopic pub -r 10 => repeat 10 times 

# topic name /turtle1/cmd_vel

# message type geometry_msgs/Twist

# data               '{linear: {x:0.1, y:0.0, z:0.0}, angular: {x: 0.0, y:0.0, z:0.0}}'

=>  Make robot move for 10 seconds linearyly with a velocity 0.1

 

sumin@sumin-930QCG:~$ rostopic pub -r 10 /turtle1/cmd_vel geometry_msgs/Twist   '{linear: {x: 0.1, y: 0.0, z: 0.0}, angular: {x: 0.0, y: 0.0, z: 0.0}}'

 

 

Show the ROS Computation Graph

rosrun rqt_graph rqt_graph

원: node, /turtle1/cmd_vel: topic

 

 

 

 

 

 

 

sumin@sumin-930QCG:~$ rosnode info /teleop_turtle
^@--------------------------------------------------------------------------------
Node [/teleop_turtle]
Publications: 
 * /rosout [rosgraph_msgs/Log]
 * /turtle1/cmd_vel [geometry_msgs/Twist]

Subscriptions: None

Services: 
 * /teleop_turtle/get_loggers
 * /teleop_turtle/set_logger_level


contacting node http://sumin-930QCG:43907/ ...
Pid: 4661
Connections:
 * topic: /rosout
    * to: /rosout
    * direction: outbound (34091 - 127.0.0.1:60682) [10]
    * transport: TCPROS
 * topic: /turtle1/cmd_vel
    * to: /turtlesim
    * direction: outbound (34091 - 127.0.0.1:60690) [12]
    * transport: TCPROS
 * topic: /turtle1/cmd_vel
    * to: /rostopic_4801_1722156437195
    * direction: outbound (34091 - 127.0.0.1:39696) [11]
    * transport: TCPROS

 

 

'ROS' 카테고리의 다른 글

Overview of ROS1  (4) 2024.07.25