now we will create a ros package our first customized Ros package now what is a Ros package? Ros package is 2
an organized unit that will contain your code if you want your code to be installed and you 3
want to utilize it execute it then you need to specify in organize manner in inside of package 4
we previously have one package in our SRC we will delete it we downloaded that package and now we 5
are going to create our own package so here is a package structure the package contains cmake list 6
and include a slash package and package.xml and SRC and the loss package can have one of the two 7
build type it can be either ament python or ament C make so we are going to use the cmake build 8
type we are not going to use the python and where we need to use this cmake because we want 9
C plus plus nodes in our package if we if you want to use python in our package we 10
will consider the python build but now we are going to use the cmake as 11
the robot that we are going to make will be using a lot of C plus plus nodes okay 12
C make list dot txt that file will be describing that how to build the code 13
inside the package and there will be include and slash package name this will be containing the 14
header files and the package.xml will be meta information about the package and the 15
SRC will be containing our source code and in the main workspace there can be 16
several packages inside the SRC as you can see it in the SRC folder there are C plus plus package 17
package and C plus plus n package so they can be there is no limit but remember 18
one package cannot be nested it means it cannot be dependent on the ament cmake or ament python it cannot 19
be dependent on the both build types okay let's create our package I will go inside the ros2 20
workspace SRC hit enter and here is the command to create your own customized package ros2 package 21
create minus minus build Type ament cmake and then the package name but there is an optional 22
argument as well that will be creating our node consider this command ros2 package create 23
minus minus build Type ament cmake and then the node name this is the Node name and then this is 24
the package we will configure this command Okay copy that and paste it here so what we are going 25
to name our package and this is going to be the turtlesimbot the node should be like a mynode 26
it's fine and we will hit enter and there we go it has created this package right here Turtlesimbot 27
and this is going to be our package on which we will be working on and if you want to build this 28
package then we will have to use colcon build or colcon build minus minus symlink install 29
if we use this command this will be building all the packages that are residing inside the SRC 30
currently we have one but if we have multiple packages in our workspace and we want to just 31
build one then there is also a command exists and the this command name colcon build minus minus 32
package Select and my package can go back and colcon build minus minus SymLink minus install 33
okay it is installed source and so on setup dot Bash 34
ros2 run Turtlesimbot and then there was a node that was my node 35
hit enter and there you can see Hello World Turtle Sim bot package so the Node 36
has printed this line it means our Node is working and if we open up this there are some 37
bdirectories include that will contain header files currently does not have any and inside or 38
SRC it is our node and these are the cmake list and package.xml no if we want to open up these 39
files we will need an editor so I recommend you to go to your Ubuntu store and download vs code 40
that is a lot helpful if you want to use it with ros uh code there will be some here here 41
okay this is the code that you will install from here there will be an option in my case this is 42
already installed if I want to open this package completely with the vs code what will I do I will 43
click right opening terminal and code space Dot okay 44
so it has opened the folder this is our folder so I will just open here 45
and then there will be some recommendations to you here that if you want to install 46
your Ros extension then you will come here to the extension and 47
type ros there is the extension that you need to install you will go here and in my case this is already 48
installed but you will be seeing an option here install and I will come to the files 49
okay so here is the SRC and my node and here it is a small C plus plus 50
node that is just printing this and whenever I try to run the node