1
00:00:00,870 --> 00:00:07,120
In this lecture, we'll be going over creating a Ross workspace so we can organize our development files.

2
00:00:07,140 --> 00:00:12,720
So before we do anything on our computer, let's get an illustration of what our file structure should

3
00:00:12,720 --> 00:00:13,380
look like.

4
00:00:14,540 --> 00:00:18,980
First thing to start off our development is to create a workspace directory.

5
00:00:19,130 --> 00:00:24,620
Inside our workspace directory, we will create a source folder, which is where our packages we develop

6
00:00:24,620 --> 00:00:25,490
will go.

7
00:00:25,670 --> 00:00:30,980
Other folders which will also appear in the workspace folder are the build, install and log folders

8
00:00:30,980 --> 00:00:34,400
which will be auto generated once we compile our project.

9
00:00:34,580 --> 00:00:40,160
Let's go ahead and focus more on the source folder since that is where we will be organizing our project

10
00:00:40,160 --> 00:00:41,000
contents.

11
00:00:41,420 --> 00:00:45,860
As I mentioned earlier, the source folder is where our packages will be placed.

12
00:00:46,070 --> 00:00:51,920
Think of packages like individual software bundles generally used for a specific task which can then

13
00:00:51,920 --> 00:00:54,290
be shared and distributed to other developers.

14
00:00:54,530 --> 00:00:57,950
Let's go ahead and see what our package structure looks like.

15
00:00:58,990 --> 00:01:03,400
The first thing we're going to see in our package is another source folder, which is where we would

16
00:01:03,400 --> 00:01:06,740
put our code if we were developing in C++.

17
00:01:06,760 --> 00:01:12,880
Now, since we're developing in Python, we will instead make a folder called Scripts to contain all

18
00:01:12,880 --> 00:01:14,260
of our Python code.

19
00:01:14,740 --> 00:01:19,300
Also in our package are two files that are auto generated when we first create our package.

20
00:01:19,300 --> 00:01:24,970
The first is our package XML file, which contains information about our package such as the ROS packages

21
00:01:24,970 --> 00:01:29,590
and systems we are using as dependencies as well as the author and version number of the package.

22
00:01:29,800 --> 00:01:35,020
The second file is a list text file which has specific instructions on compiling our package.

23
00:01:35,110 --> 00:01:39,490
This will give information to the compiler, such as if we created a custom interface type as well as

24
00:01:39,490 --> 00:01:40,870
any build dependencies.

25
00:01:41,140 --> 00:01:45,670
So if we actually go into our scripts folder, we can see these are just where our Python scripts which

26
00:01:45,670 --> 00:01:47,300
we develop are placed.

27
00:01:47,320 --> 00:01:51,010
You can name your scripts whatever you want and you'll be able to run it directly through the ROS to

28
00:01:51,010 --> 00:01:54,310
run command after we have compiled and source our package.

29
00:01:54,340 --> 00:01:59,800
Now notice we have this init py file which for the purposes of this course we will leave blank.

30
00:01:59,800 --> 00:02:03,730
But this shows you this is organized as a typical Python library.

31
00:02:03,760 --> 00:02:07,360
Now it's worth noting that this is a very simplistic hierarchy which we will generally use for this

32
00:02:07,360 --> 00:02:08,050
course.

33
00:02:08,050 --> 00:02:13,390
But also keep in mind in package folders, you may also find things such as launch folders, custom

34
00:02:13,390 --> 00:02:17,340
message declarations, simulation configurations, and much more.

35
00:02:17,350 --> 00:02:22,150
So as long as it pertains to the purpose of the package, we will go over these in more depth throughout

36
00:02:22,150 --> 00:02:22,960
the course.

37
00:02:24,550 --> 00:02:25,010
All right.

38
00:02:25,030 --> 00:02:29,500
Now that you have a general overview of what our RA workspace file structure should look like, let's

39
00:02:29,500 --> 00:02:31,780
go ahead and create our own workspace.

40
00:02:33,620 --> 00:02:33,920
All right?

41
00:02:33,920 --> 00:02:37,430
We're honorable unto machine and we can open up our file explorer.

42
00:02:37,580 --> 00:02:42,590
Ross workspace is generally live in our home directory, so we would normally create a new folder by

43
00:02:42,590 --> 00:02:44,770
right clicking, hitting new folder.

44
00:02:44,780 --> 00:02:49,010
And if you follow a lot of tutorials on the Ross website, you would call it something along the lines

45
00:02:49,010 --> 00:02:53,090
of dev underscore CSS or workspace.

46
00:02:53,120 --> 00:02:58,460
Now in my experience this is not very descriptive of what this workspace is for, and this will start

47
00:02:58,460 --> 00:03:01,970
to get unorganized if we want to make new separate projects.

48
00:03:02,060 --> 00:03:04,910
Instead, we can call this folder workspaces.

49
00:03:06,920 --> 00:03:12,530
Now, if we go into our Workspaces folder, we can go ahead and make our actual project workspace folder,

50
00:03:12,650 --> 00:03:14,550
which we're going to be using for this course.

51
00:03:14,570 --> 00:03:18,170
So generally this would be named after a particular robot we are working on.

52
00:03:18,170 --> 00:03:25,250
But for the purposes of this course, we are just going to call this the Ross to py w for workspace.

53
00:03:25,250 --> 00:03:30,340
Just so we know this is our workspace where we work on projects related to this Udemy course.

54
00:03:30,350 --> 00:03:34,610
Now we can go into our workspace folder and create our source folder.

55
00:03:35,750 --> 00:03:40,760
Now, instead of creating a new folder for our package, we are instead going to use the Ross to package

56
00:03:40,760 --> 00:03:42,200
create command in the terminal.

57
00:03:42,200 --> 00:03:43,820
So go ahead and open up the source folder.

58
00:03:44,680 --> 00:03:46,090
I'll go ahead and open up my terminal.

59
00:03:46,540 --> 00:03:52,120
And with the terminal open, we will change into our Ross to CME Workspace source folder, which we're

60
00:03:52,120 --> 00:03:53,200
looking at right here.

61
00:03:58,030 --> 00:04:01,240
Once we're here, we will run Ross to package carry.

62
00:04:01,600 --> 00:04:02,920
I will call my package.

63
00:04:02,920 --> 00:04:04,990
Ross to underscore Udemy.

64
00:04:04,990 --> 00:04:06,640
Underscore package.

65
00:04:06,760 --> 00:04:11,290
We will also need to pass a bill type parameter in which we will use a mint.

66
00:04:11,620 --> 00:04:19,410
Make note that you could change the build type to amend python, in which case you would use a setup

67
00:04:19,690 --> 00:04:21,790
script to create your build instructions.

68
00:04:21,790 --> 00:04:25,810
For this course though I will use a mentor make and we'll talk about it a bit later.

69
00:04:27,860 --> 00:04:32,150
After running the command, we can see some text up here on the screen and we can see in our folder

70
00:04:32,150 --> 00:04:39,170
it went ahead and created our package and created some of these default folders and files for us, which

71
00:04:39,170 --> 00:04:43,630
include our see, make list, text file and package XML file we talked about earlier.

72
00:04:43,640 --> 00:04:47,330
So let's take a look at the generated package XML file.

73
00:04:53,100 --> 00:04:56,060
Here we see different fields to describe our package.

74
00:04:56,070 --> 00:05:01,350
You would generally want to fill these fields such as version, description, maintainer and license,

75
00:05:01,350 --> 00:05:03,630
before releasing your package to the public.

76
00:05:04,370 --> 00:05:08,120
We can go back now and take a look at our C list text file.

77
00:05:11,190 --> 00:05:16,110
So by default, this is our see make list text file, which has some things about our project and the

78
00:05:16,110 --> 00:05:20,180
dependencies we're going to be requiring to compile our ROS package.

79
00:05:20,190 --> 00:05:22,440
Now, for the time being, it's not syntax highlighting.

80
00:05:22,440 --> 00:05:25,500
That's because we're in restricted mode because of the way I started up vs code.

81
00:05:25,500 --> 00:05:27,900
So you can just go ahead and trust this workspace.

82
00:05:28,260 --> 00:05:29,310
And there we go.

83
00:05:29,310 --> 00:05:35,220
Now it seems to identify that we are using the make language type and we get this nice syntax highlighting

84
00:05:35,220 --> 00:05:40,890
so we can see the commands such as find package, which we're going to be using throughout this course.

85
00:05:41,040 --> 00:05:46,020
For those of you who have developed in ROS version one, you can see that the default C list text file

86
00:05:46,020 --> 00:05:48,450
has gotten much shorter and cleaner looking.

87
00:05:48,540 --> 00:05:53,310
We will edit this file later in the course to tell the compiler about any dependencies we need for our

88
00:05:53,310 --> 00:05:54,540
ROS package.

89
00:05:54,810 --> 00:05:59,700
The last thing I will do to wrap up our workspace is create a scripts directory so we have a place to

90
00:05:59,700 --> 00:06:01,440
put our python files.

91
00:06:01,860 --> 00:06:06,930
Even though we haven't created any new code yet, we can go ahead and build our workspace to do this.

92
00:06:06,930 --> 00:06:11,490
We can navigate back to our workspace directory within our terminal.

93
00:06:14,120 --> 00:06:17,360
So here I'm in my RA two pi workspace folder.

94
00:06:18,730 --> 00:06:19,330
Right here.

95
00:06:20,160 --> 00:06:22,710
And we can go ahead and run, can build.

96
00:06:24,290 --> 00:06:25,400
So we're running the command.

97
00:06:25,400 --> 00:06:31,100
It begins building our package we've built successfully and it's generated our build, install and log

98
00:06:31,100 --> 00:06:31,910
folders.

99
00:06:31,910 --> 00:06:33,920
If you're having trouble running this command, you get an error.

100
00:06:33,920 --> 00:06:35,560
Sinkhole can build does not exist.

101
00:06:35,570 --> 00:06:41,450
Feel free to check out the following docs page and make sure you have your Python three Culkin Common

102
00:06:41,450 --> 00:06:43,220
Extensions installed.

103
00:06:44,980 --> 00:06:47,140
Now to include our package in our terminal environment.

104
00:06:47,140 --> 00:06:52,720
We need to source the setup bash file within the install directory so we can actually go ahead and look

105
00:06:52,720 --> 00:06:53,370
at that here.

106
00:06:53,380 --> 00:06:58,060
So here in our install directory, we see we have a setup batch file which is going to set up our terminal

107
00:06:58,060 --> 00:06:59,320
environment for us.

108
00:07:03,840 --> 00:07:09,420
Now our terminal is aware of our newly created ROS package and we can check this by running the ROS

109
00:07:09,420 --> 00:07:11,100
to package list command.

110
00:07:11,550 --> 00:07:17,730
And here we can see our ROS two package listed amongst the various packages here that came with our

111
00:07:17,730 --> 00:07:19,110
ROS installation.

112
00:07:22,720 --> 00:07:23,710
Congratulations.

113
00:07:23,710 --> 00:07:28,750
You have successfully created your very own Ross two package, but let's review what we learned.

114
00:07:30,180 --> 00:07:33,540
In this lecture, we learned how to create our Ross workspace.

115
00:07:33,540 --> 00:07:39,180
We created a new ROS to package by creating our workspace and source folders, changing into the source

116
00:07:39,180 --> 00:07:44,280
directory, and then running the ROS to package create command where we gave our package a name and

117
00:07:44,280 --> 00:07:46,830
set the build type to amend see make.

118
00:07:47,220 --> 00:07:51,510
Then we compiled our workspace by running Call can build in the workspace directory.

119
00:07:51,720 --> 00:07:57,420
We could then source the setup bash file in the install directory to make our terminal environment aware

120
00:07:57,420 --> 00:07:59,370
of the new package we created.
