1

00:00:08,140  -->  00:00:10,140
We have learned about ros nodes

2

00:00:10,140  -->  00:00:15,720
so let's see how the ros nodes communicate
among each other and we are going to learn about the ros topics

3

00:00:15,720  -->  00:00:23,280
 ros  topics act as a
bus among the node and that can exchange

4

00:00:23,280  -->  00:00:32,700
or transfer the ros message so open up the
terminal our terminal is already sourced

5

00:00:34,560  -->  00:00:40,620
here you can see how the nodes are communicating
with each other you can see two nodes that are

6

00:00:40,620  -->  00:00:47,160
displayed in circle and they are communicating
over a topic and one node is publishing  the other

7

00:00:47,160  -->  00:00:55,560
one the bottom one is subscribing and they
are communicating a message via topic and here

8

00:00:55,560  -->  00:01:02,760
you can see there are multiple node and they are
communicating over one topic

9

00:01:02,760  -->  00:01:10,620
two of them are Publishers and now two
of them are subscribers so there can be multiple

10

00:01:10,620  -->  00:01:18,780
node that can communicate over one topic any node
can communicate with any other node over  a common

11

00:01:18,780  -->  00:01:27,960
topic so open up your terminal this terminal
is already sourced and drag it here

12

00:01:27,960  -->  00:01:40,200
for the visualization we are going to run again turtlesim node
Ros2 run turtlesim package name  and the node name turtlesim

13

00:01:43,260  -->  00:01:55,200
and now open up another terminal ros2 topic
list so here we have the first two topics will

14

00:01:55,200  -->  00:02:02,400
always appear uh these topic contains information
about the parameters if the parameter changes it

15

00:02:02,400  -->  00:02:09,480
will store the information about it the rosout
contains the logging information we do not need to

16

00:02:09,480  -->  00:02:16,260
spend too much time with them these three topics
are our main concern alright run another

17

00:02:17,220  -->  00:02:28,680
node ros2 run turtlesim teleop key now we have two Nodes and

18

00:02:29,820  -->  00:02:37,500
but the topics are same because the teleop node will be publishing over turtle one

19

00:02:37,500  -->  00:02:45,180
slash cmd vel topic so let's see how we can
monitor a topic we can monitor a data on a

20

00:02:45,180  -->  00:02:58,080
specific topic by using a keyword that is echo
so we'll just all right ros2 topic echo

21

00:03:00,720  -->  00:03:01,260
turtle

22

00:03:02,081  -->  00:03:04,310
cmd vel

23

00:03:04,310  -->  00:03:09,060
and currently it is not showing us
any data because the publisher hasn't

24

00:03:09,060  -->  00:03:14,280
published any data over this topic
so we will just press forward key once

25

00:03:15,480  -->  00:03:20,100
yes we just press it once
so it has displayed of this data

26

00:03:20,820  -->  00:03:27,960
as you can see X is 2 and all other values are
zero if we press a right button once

27

00:03:30,240  -->  00:03:39,060
the Turtle has turned and it has given us
the angular z value so this is how you can monitor

28

00:03:39,060  -->  00:03:46,620
a topic and you can access all the data that is
being published over it and let's see rqt graph

29

00:03:46,620  -->  00:03:58,620
representation rqt_graph
the enter and here it has displayed we will just refresh

30

00:03:59,340  -->  00:04:07,380
and uh do not  communicating with each other
so you see echo we can find out all the data being

31

00:04:07,380  -->  00:04:14,160
published over topic but we can also find out
how many publisher and subscribers are related

32

00:04:14,160  -->  00:04:23,520
to a topic and we can also find out the uh
message type related to that topic so if we write

33

00:04:24,804  -->  00:04:26,660
ros2

34

00:04:27,120  -->  00:04:37,800
topic list minus t so it will display the
type of the message that a particular

35

00:04:37,800  -->  00:04:45,360
topic is using so it has displayed all the
topics and their selected message type in

36

00:04:45,360  -->  00:04:54,660
the list and the turtle1/cmd_vel  has the  geometry massages and twist so

37

00:04:54,660  -->  00:05:00,540
you can also see the turtle one post has the
message type Turtlesim message and post we

38

00:05:00,540  -->  00:05:07,620
will see these messages and future videos but
currently you just have to keep in mind there

39

00:05:07,620  -->  00:05:15,360
are some message type that a particular topic uses
to find out more information about a topic

40

00:05:15,360  -->  00:05:24,180
To know the number of subscribers and publisher on
related to a topic we can just use ros2 topic

41

00:05:25,080  -->  00:05:31,620
info and let's say we
have to learn about this topic

42

00:05:35,340  -->  00:05:42,420
here so it has currently one subscriber and one
publisher so why does it have just one publisher

43

00:05:42,420  -->  00:05:50,065
and one subscriber ? the publisher that is
publishing over this topic is the teleop and the subscriber is

44

00:05:50,065  -->  00:05:56,597
turtlrsim window type of this
topic is displayed here to geometric messages slash

45

00:05:56,100  -->  00:06:05,700
message and twist to find out what is inside this
message we can use a command ros2 interface

46

00:06:07,860  -->  00:06:20,460
show and you can simply paste it here
so it has a vector linear graphical 3

47

00:06:20,460  -->  00:06:28,320
linear and vector 3 angular okay now we
want to publish over a topic let's relaunch

48

00:06:28,320  -->  00:06:33,720
every terminal from the beginning
uh press Ctrl C to kill terminal

49

00:06:34,380  -->  00:06:43,680
and  here and you can press like
Ctrl+L to clear it in every terminal

50

00:06:48,240  -->  00:06:57,300
it enter a window appear and now we have
to know the topic list ros2 topic list

51

00:06:58,680  -->  00:07:03,120
so this is our concerning topic we will ros2 topic

52

00:07:03,720  -->  00:07:12,840
info this topic and we know there is a zero publisher and one subscriber and here is the

53

00:07:12,840  -->  00:07:19,020
message type what we will do we'll just copy
ros we have to publish over this topic and we

54

00:07:19,020  -->  00:07:25,860
will also use this message type how this message
looks like so what we will do ros2 interface

55

00:07:29,040  -->  00:07:37,860
show and this message and it has displayed
us so this message has two vectors the

56

00:07:37,860  -->  00:07:45,780
linear and angular so we want to publish
uh over cmd vel so here is the command  ros2 topic

57

00:07:46,740  -->  00:07:54,060
pub and -- once so it means it will
just publish it once and then it will terminate

58

00:07:54,060  -->  00:08:09,600
and the topic name turtle one cmd vel and the
message type then inverted comma track it linear

59

00:08:10,680  -->  00:08:17,280
colon there are three further values in the
sector so there will be the X colon space

60

00:08:18,060  -->  00:08:35,520
let's say three and then comma and y colon space
zero comma Z colon space zero close this with the

61

00:08:35,520  -->  00:08:44,040
curly bracket and then comma and then there
is the angular Vector as well and children

62

00:08:45,540  -->  00:08:49,200
colon phase bracket X

63

00:08:52,140  -->  00:08:59,220
X value 0 and Y value 0

64

00:09:02,160  -->  00:09:12,240
and Z value should be uh this is the angular
velocity we can give it to uh let's say we give it

65

00:09:12,240  -->  00:09:20,100
uh three and close the curly bracket close the curly bracket
again and close the inverted comma so this

66

00:09:20,100  -->  00:09:28,440
will be the convention to publish over this topic
and each topic will have a different message type

67

00:09:28,440  -->  00:09:37,080
and there will be different parameters as well so
at enter a loop is beginning and tells completed

68

00:09:37,080  -->  00:09:44,160
a semi-circle what what if we want to publish
it for a long time so instead of publishing it

69

00:09:44,160  -->  00:09:51,180
here once we want to publish it at a continuous
frequency so what we will change we'll just change

70

00:09:52,860  -->  00:10:01,980
and this keyword I will mention it rate
and let's say two so it will be publishing

71

00:10:03,480  -->  00:10:11,100
twice a second let's change the value a little
bit preview increase the value of linear X it will

72

00:10:11,820  -->  00:10:14,220
be moving in a bigger Circle hopefully

73

00:10:17,580  -->  00:10:24,540
yes it is moving and if you want to make
this circle smaller then what you will do

74

00:10:24,540  -->  00:10:35,760
we will press Ctrl C and give a high angular
velocity and publish yes see rqt graph

75

00:10:45,600  -->  00:10:50,160
so here you can see it is showing
that a publisher is publishing

76

00:10:50,700  -->  00:11:04,800
so what if we now get the info of this topic
ros2 topic info turtle 1 and cmd

77

00:11:06,840  -->  00:11:14,640
yes here you can see there is one publisher and
one subscriber as well so we can also check the

78

00:11:14,640  -->  00:11:20,940
frequency of a topic so we will check
the frequency of this topic ros2

79

00:11:21,850  -->  00:11:23,350
topic

80

00:11:23,760  -->  00:11:29,700
HZ which is represents
frequency topic so we will see

81

00:11:32,760  -->  00:11:39,060
so here is the real-time value of the frequency
so we have set the frequency to two  now you

82

00:11:39,060  -->  00:11:44,220
have learned all the information that you need
to know about the ros topic you have learned

83

00:11:44,220  -->  00:11:49,800
to publish you have learned to Echo and you have
you can monitor a topic and you can also see

84

00:11:50,340  -->  00:11:56,520
the publisher and subscribe will uh
over related to a topic by just using

85

00:11:56,520  -->  00:12:03,720
a keyword that is input and uh you can
also check the frequency of a topic
