Let's experiment a bit more with topics using the total SIM package and the 2D robot simulation.
So let's start by running total sim.
So we use Ros to run total sim and total sim node okay.
So this we have done already in the previous section that's going to start this window.
Let's actually re size here so we can put the window on the side.
Okay.
And I'm going to start here Ros to run total SIM with total Teleop key okay.
So we can you can see we can control the robot here.
And so what we have guessed previously we could only guess that is that this node here is going to communicate
with that one.
Because if we press the keyboard here and the robot is moving, it means that this node must receive
something from that node.
Let's just run.
our cute graph and you can see.
So we have nodes and topics all here that yes the Teleop turtle is you see sending a command velocity
topic here.
Turtle one Cmdvel.
So that's a topic.
And this one is sending data to that topic.
And then this one is a subscriber.
We have more stuff here that we don't need to worry about that for now.
But you can see this is what's interesting for us.
That topic here.
And that's how the two nodes communicate.
So I can close that.
And I can find the same information using the command line.
So Ros2 node list I have my two nodes and then ros2 node info for example with the turtle sim.
And you can see you can see here in the subscribers we have turtle one Cmdvel plus the type okay.
So geometry message.
Twist.
So that's yet another package with messages okay.
And if I do Ross to node info with Teleop turtle, then you can see for that one we have a publisher
that's turtle one Cmdvel with the same data type, so we can find the publisher and the subscriber.
Now I can also do Ross two topic list.
You see we still have the parameter events and the Ross out.
I told you we will always have those and we have three more topics.
But the one that's interesting for us here is that one.
Ross two topic info with Cmdvel.
You see, we have one publisher, one subscriber, so it's the publisher and the subscriber here.
And we also have the type if you want to see the exact data type of that interface, you do Ross two
interface show and you just provide this and you can see here.
So we have this comment, but it's a bit more complex because we have a vector three.
So that's a linear.
And inside this linear field we have x y and z field which are float numbers.
Okay.
So we have linear x linear y linear z and then angular dot x y and z.
Great.
And you can see that we just run those two nodes.
And with our graph you could already get a good idea of what's going on.
And then with the command line tools, we wrote to node and wrote to topic and also wrote to interface.
You can get all the information you need so that you can then create any publisher or subscriber to
that topic.
Okay, you have the name, you have the interface, and you know what's inside the interface.
Just as an additional as a bonus step here, I'm going to also try to publish because now we know what
we have.
So I'm going to publish using Ros2 topic pub.
Let's say I want to publish.
So Dash r I want to publish twice per second.
What's the topic.
The topic is Turtle one Cmdvel.
What is the interface?
The interface is geometry.
Message twist okay, so that's all the information that we found.
And then then what do we need to provide.
So I'm just going to what I'm going to stop that one.
And I'm just going to do this again Ros2 interface show with geometry messages and twist.
Okay.
So this time it's a bit more complex.
So we have the double quotes and then curly brackets.
And we're going to provide for example linear like this.
And we need to put a colon and then another set of curly brackets okay.
Because it's the linear field.
But inside the linear field we have more stuff.
And then I can do x and provide a value for example 1.0.
So here I'm going to send the command so that the turtle can just do a circle.
To do a circle we just need to send a Uh, linear x command and angular z command that are constant.
Okay.
Because here we are in 2D.
So this is a 3D vector okay.
And just to keep things simple here, well x just means that we are going to go forward and backward.
So we only need to go forward and backward and then to make it rotate on itself.
Okay.
We are not going to flip the turtle on the y axis in 3D because what here doesn't exist.
And we cannot also elevate the turtle here.
So the y and z axis don't exist.
And for the angular rotation the x and y rotation also don't exist.
It's only the z rotation.
Okay I'm going to come back to this in the final project.
I'm going to explain also the right hand rule if you don't know that.
So there will be more explanation in the final project.
For now you just have to know that if you want to to move the turtle, you just need to provide the
linear X and the angular Z.
And if you omit some fields, it's okay because the default value is simply going to be zero.
So I can just put x x1 and then after this one.
So I have linear x1 I'm going to put angular and then like that.
So you see it starts to be a bit more complicated as you have a more complex interface.
And I'm going to put Z.
So actually inside the if I change the side here like that okay.
So Z let's say 1.0.
All right.
So make sure you correctly open and close all the curly brackets because it can be a bit tricky.
And with this we should press enter.
And it should work.
You see now the turtle is moving.
It should move in a circle okay.
And if I press ctrl C it's going to stop.
All right.
And so what happened here is that I created a publisher directly from the terminal.
And because I have a subscriber already here, then this node with the subscriber is going to receive
the data from the publisher.
And then here it's going to make the turtle move.
And we can easily see that it's working.