We have seen that our robot is now able to move in the simulation.
We can drive it using tell your keyboard.
What we want to do now is to drive it through a Python script because when we are going to move forward,
our computer vision game is just going to send us command velocities and for command velocity.
Interpretation into robot motion is very essential.
For that we are going to create a node and I can write the code right away.
But what I am going to do is to just create a file here and that is going to be named as driving dot
by or I should say driving node.
Okay.
Kind of.
But the interesting thing is I am going to get all of its code from Ros Vicky Ros to Subs Publisher
in in this specific case, we need a publisher in Python.
Right, a simple publisher and subscriber.
And we are going to follow a simple structure.
I'm showing you this because the very first time I learned from this was this last week.
So coming to the point that we have our package, writing the publisher load, you can download it to
the minimum publisher or you can get the code from here.
So if I paste all of the available code here, the risk line library standard messages, string.
Okay.
There in basic format, there is a publisher of which is defined in this class and there is a timer
callback back for that.
Now the point is it is publishing a string message, but what we would be requiring is a different thing.
How do I know that?
Let me show you.
If we have this terminal here and I bring my robot into that simulation that we want to, I perform
ROS to topic list to get all of the available topics we have command velocity.
That is the main topic that we were utilizing.
So rice top rice to topic, get rice to info, rice to topic in full.
I think that was the command to geometric message twist and there is no publisher.
There is one subscriber available which is this robot.
So geometric message twist.
This is the main thing coming to the point that in our room what is the node?
We want geometric message here.
So if I bring it here and bring the code and decide.
So we want to make tree message.
Let me copy pasted geometric message start message and I want twist inside of and this is the message
type we want.
You can get information about this topic as well.
So the topic is not topic, it is command velocity.
I'm just adjusting the mean publisher of node that is available in rice Vicky and I want it to work
for my requirements so the message it is going to be communicating is stressed.
The topic is command velocity and you can call it every second.
We are going to send not minimal publisher command and let's see just the velocity publisher.
It is going to be publishing velocities, linear and angular.
Now in timer callback, you are going to create a message of twist.
And here comes the reality, which I am going to perform in a moment.
First, I need to get information about the message type, cross to interface show and the message we
want to get information about.
Two.
Previously we were using the standard message.
Let's first get information about that standard message.
And that was standard message string.
Yes, this was the message that was in our node.
It says there is only one entry and that is string data entry.
You can pass the string.
Okay, now we are going to be using the same no practice to get information about our geometric message
twist, which is the most common velocity message utilized.
This contains a linear and an angular vector, so we need to get information about the interface of
vector.
Let's get into it.
Vector does vector contains its own type or is it something else or is a geometric message vector?
I'm showing you just to give you an idea how you can search about things.
So it is also a geometric message to geometric message.
Vector contains X-Y-Z three different values of load for linear and three different values for Angular.
In our case, what we are going to be only interested in is linear X and angular z.
So let's start writing about it.
Message dot linear dot x is equal to 0.5 and message start angular z is equal to 0.3.
Just to give a rotational angle.
I will not be giving both at the same time.
I'm just going to give linear for now and you are going to publish the message and do not log the data.
We just need we don't need to integrate that as we'll just publish the data and the report is going
to move in linear X with 0.5 velocity.
That's it.
We.
You need to make this run on our system.
For that we need to open setup by file in setup by file.
If we open up the Google Chrome page of Wikipedia for Ros, you can see it entered and we need to add
this specific line into our setup dot by file of our package so it knows where this executable node
is sort of path setting.
So we have this of package of maze board and the name of our node that I want to execute is Driving
Node.
What is going to be the name of an executable it will generate?
I want it to be driving a driving maze board that is that is going to be available to us.
Now all of the things are set up.
Let's compile it and see how does it performs.
Let's open up this as well.
Now it is this.
Yes.
So let's go into our directory of ROS to part planning workspace.
Now we are inside of our workspace.
Perform call can be and I will perform allow overriding and the package name is Ms. bought.
It's me and the scoreboard.
Have I had it in the same name in the set of the world?
Nope.
It would not have appeared.
You don't have to make such mistakes.
Things are not going to want rice to run maize board and the name of the node was driving.
Is it coming?
Driving mes.
But I'm pressing dab and it automatically completes.
Let's see if our robot is moving in linear x or not.
So you can see a robot is moving in linear x and basically what our achievement is, our node is publishing
velocity that is controlling the robot.
We are not driving it through our keyboard.
Now let's send these velocity, which is some strong angular rotation, very less linear rotation.
I am going to again perform at the stop this node first and give this up.
Build it again and hold this robot and bring it back to this specific point.
And now I am going to.
Yes, run this node again and see if the robot starts to make anticlockwise rotation or not.
Yes, it is making anticlockwise rotation because the linear, the angular velocity is positive.
So it is counterclockwise when it is positive and the linear velocity is also sent.
If I only send the angular velocity, the robot is just going to stop at 1.2 and rotate.
But as the linear velocity is, there it is.
Are they making a circle?
Sort of.
So that was it.
I'm driving.
Node is ready.
What else do we need to do?
We have to look further.
What are the what are the important nodes we need to build?
We talk about that and we will build them.