1
00:00:01,320 --> 00:00:05,800
Throughout this course, we have been organizing our code within a Roth package.

2
00:00:05,820 --> 00:00:11,190
In this lecture, we're going to take a look at Rust, two packages made by other developers and use

3
00:00:11,190 --> 00:00:11,460
it.

4
00:00:11,940 --> 00:00:16,290
The packages we will ultimately be using is the USB cam package.

5
00:00:16,290 --> 00:00:18,000
You should be able to follow along with me.

6
00:00:18,000 --> 00:00:23,690
If you have a laptop with a built in camera or a camera which you can plug in via USB.

7
00:00:24,570 --> 00:00:26,340
First thing to do before we get into anything.

8
00:00:26,340 --> 00:00:30,540
Ross related is a check that our camera works properly in Ubuntu.

9
00:00:30,570 --> 00:00:34,770
We can use an app called cheese, which should be installed by default.

10
00:00:34,830 --> 00:00:38,940
If I click on it, you can see a window open which shows my camera feed.

11
00:00:39,990 --> 00:00:40,560
Hello.

12
00:00:43,350 --> 00:00:47,430
If you're unable to get that to work, chances are you will also have a hard time trying to get it to

13
00:00:47,430 --> 00:00:47,820
work in.

14
00:00:47,820 --> 00:00:48,570
Ross.

15
00:00:48,780 --> 00:00:54,210
If you are using a virtual machine, make sure to configure your virtual machine settings USB to be

16
00:00:54,210 --> 00:00:59,070
able to utilize USB three ports if that is what your camera is plugged into.

17
00:01:00,810 --> 00:01:03,860
With that out of the way, let's get to the rock packages.

18
00:01:03,870 --> 00:01:08,550
Let's go ahead and open up a browser to search for readily available rescue packages.

19
00:01:08,550 --> 00:01:11,100
We can check out the Ross Index site.

20
00:01:11,490 --> 00:01:17,430
If you have used Ross one before, you are probably more familiar with the Ross wiki to find information

21
00:01:17,430 --> 00:01:18,930
about packages.

22
00:01:18,930 --> 00:01:25,020
Justin Keep in mind that going forward all Ross to package info will instead be found on the Ross index

23
00:01:25,020 --> 00:01:27,900
page and will not be kept on this Ross wiki.

24
00:01:28,410 --> 00:01:29,550
On the Ross Index home page.

25
00:01:29,550 --> 00:01:33,210
You can see the current active distributions at the time of this recording.

26
00:01:33,210 --> 00:01:40,710
You may see different distros as galactic will be depreciated in November 2022 and melodic in May 2023.

27
00:01:41,010 --> 00:01:44,820
If you click on any of these links, it'll take you to the general distribution Description page.

28
00:01:45,210 --> 00:01:50,610
Instead, we are interested in checking out some of the Ross packages available so I can hit the packages

29
00:01:50,610 --> 00:01:52,530
list button in the upper left.

30
00:01:53,170 --> 00:01:58,840
Here we get a list of Ross packages for the humble distribution sorted by latest release date.

31
00:01:58,870 --> 00:02:03,490
You could click on other distributions to check out the corresponding supported packages.

32
00:02:03,800 --> 00:02:08,740
Package we are going to be using is called USB cam so I can go ahead and search for it in the search

33
00:02:08,740 --> 00:02:09,220
bar.

34
00:02:10,270 --> 00:02:11,290
We get some results.

35
00:02:11,290 --> 00:02:15,820
And near the top we see the USB cam package for the humble distribution.

36
00:02:15,820 --> 00:02:17,380
So I'll go ahead and click on that.

37
00:02:18,370 --> 00:02:20,590
So here we're taking to the package page.

38
00:02:20,740 --> 00:02:24,040
At the top you can see the supported distros for this package.

39
00:02:24,800 --> 00:02:25,850
And slightly lower.

40
00:02:25,850 --> 00:02:31,160
We can see things such as the package description, summary and repository information.

41
00:02:31,280 --> 00:02:37,520
If we scroll down further, we'll get brought to a redmi MD file in the package repo, which generally

42
00:02:37,520 --> 00:02:41,990
gives a detailed description of what the package is and how to use it.

43
00:02:43,320 --> 00:02:48,210
And past that we get a changelog with various changes that were made to this package.

44
00:02:48,210 --> 00:02:49,830
So I'll go ahead and scroll back up.

45
00:02:50,970 --> 00:02:57,150
So here in the redmi it tells us how to install the package with apt install as well as instructions

46
00:02:57,150 --> 00:02:59,100
on how to build a package from source.

47
00:02:59,100 --> 00:03:01,140
And we can scroll down further.

48
00:03:02,380 --> 00:03:08,170
To see examples of running this node using the available launch files and nodes.

49
00:03:08,440 --> 00:03:11,950
And one last thing I want to show before we get into this is near the top.

50
00:03:11,950 --> 00:03:15,130
You can find a link to the repository which the package is hosted on.

51
00:03:15,130 --> 00:03:19,510
So here if we head over to browse code, I can go ahead and open this in a new tab and which takes us

52
00:03:19,510 --> 00:03:26,410
to, in this case, a GitHub page which hosts the code development for this USB cam package.

53
00:03:26,410 --> 00:03:30,700
So if you ever want to look at the source code before installing a package, this is one of the ways

54
00:03:30,700 --> 00:03:31,810
you could go about doing it.

55
00:03:31,810 --> 00:03:33,580
So for example, we can check out the launch files.

56
00:03:33,580 --> 00:03:36,340
So here we see there's a demo launch py file.

57
00:03:37,320 --> 00:03:41,940
And we can see some of the scripts that are available, such as Show Image Pie.

58
00:03:42,150 --> 00:03:43,740
So I'll go ahead and close that.

59
00:03:44,500 --> 00:03:44,770
All right.

60
00:03:44,770 --> 00:03:49,690
With that intro out of the way, let's go ahead and install this package so we can use our USB camera

61
00:03:49,690 --> 00:03:50,780
with Ross.

62
00:03:50,800 --> 00:03:56,320
So here in the Quickstart section I mentioned earlier, we can install this package using the apt install

63
00:03:56,320 --> 00:03:57,100
command.

64
00:03:57,550 --> 00:04:03,910
So it's simply apt install Ross followed by the distribution name and then the name of the package which

65
00:04:03,910 --> 00:04:06,100
is USB dash can.

66
00:04:07,040 --> 00:04:12,440
Worth mentioning that package names use an underscore snake case convention to separate words.

67
00:04:12,830 --> 00:04:19,850
So this package name is USB underscore cam, but note that the APT install command follows a dash convention

68
00:04:19,850 --> 00:04:23,920
in which each word is separated with a dash instead of an underscore.

69
00:04:23,930 --> 00:04:27,890
So auto students sometimes wonder why they can't install a package, and usually it's because they don't

70
00:04:27,890 --> 00:04:32,450
follow this particular command line convention when trying to run app install.

71
00:04:32,630 --> 00:04:35,390
But let's go ahead and open up a terminal and install it.

72
00:04:38,170 --> 00:04:41,110
So the way I have this command format, it works just fine.

73
00:04:41,110 --> 00:04:44,740
But note another popular convention you may see is the following.

74
00:04:47,600 --> 00:04:52,040
Now, this may seem weird and much more complex than what I had before, but this command will install

75
00:04:52,040 --> 00:04:58,040
the package regardless of what ros distro you have installed and source by utilizing the Ross distro

76
00:04:58,040 --> 00:05:01,090
environment variables so I can actually go ahead and open up a second terminal.

77
00:05:01,100 --> 00:05:03,440
And if I echo this environment variable.

78
00:05:05,840 --> 00:05:09,800
So echoing it, we see we get humble, which is the name of our Disher that we're using.

79
00:05:09,800 --> 00:05:15,710
So essentially in this command where we have this dollar sign Ross distro, this gets replaced with

80
00:05:15,710 --> 00:05:18,290
the string humble just as we saw earlier.

81
00:05:18,680 --> 00:05:23,990
But if we're using a different distribution such as Foxy or Noetic, then the above command will still

82
00:05:23,990 --> 00:05:26,830
install the correct distribution version of the package.

83
00:05:26,840 --> 00:05:32,060
So I'll go ahead and close the second terminal and go ahead and install the USB cam package.

84
00:05:33,230 --> 00:05:33,500
Go ahead.

85
00:05:33,500 --> 00:05:34,400
Put in your password.

86
00:05:36,190 --> 00:05:37,140
Or why?

87
00:05:37,140 --> 00:05:37,770
Enter.

88
00:05:40,400 --> 00:05:40,700
OC.

89
00:05:40,700 --> 00:05:43,020
We have installed the USB cam package.

90
00:05:43,040 --> 00:05:48,020
Packages installed this way can be found in your op ross distro folder.

91
00:05:50,310 --> 00:05:57,240
Some of the files, such as the launch and package files, will end up in the share folder and the executables

92
00:05:57,240 --> 00:06:03,390
can be found in the lib folder so I can head over to share and then we'll scroll to the bottom.

93
00:06:05,070 --> 00:06:06,780
And we can see USB cam.

94
00:06:06,900 --> 00:06:13,320
And here we can see some of the package files such as the launch folder and other environment and configuration

95
00:06:13,320 --> 00:06:14,010
files.

96
00:06:15,600 --> 00:06:16,590
If I go back.

97
00:06:17,450 --> 00:06:18,530
Can head over to lib.

98
00:06:19,590 --> 00:06:20,400
Scroll down.

99
00:06:22,200 --> 00:06:23,060
Yes, we can.

100
00:06:23,070 --> 00:06:27,270
And here we actually can see some of the nodes that were available in this package.

101
00:06:27,860 --> 00:06:32,900
So now that we have this package installed, let's go ahead and run the launch file we saw earlier.

102
00:06:35,220 --> 00:06:36,840
Since we installed it with app install.

103
00:06:36,840 --> 00:06:41,640
It is now part of our ROS Humble installation environment, so by default we can use the package without

104
00:06:41,640 --> 00:06:43,770
having to do any extra environment sourcing.

105
00:06:43,770 --> 00:06:47,730
So go ahead and clear the screen and then we can run it like so.

106
00:06:53,930 --> 00:06:59,180
If all goes well, you should see a pop up window displaying your image feed from your camera.

107
00:06:59,510 --> 00:07:00,170
Hello.

108
00:07:00,560 --> 00:07:05,120
You can also open a new terminal and see the various topics the USB cam node is publishing.

109
00:07:10,000 --> 00:07:14,950
Can then go ahead and stop the launch file by hitting control C in the particular terminal and you might

110
00:07:14,950 --> 00:07:15,820
get a crash report error.

111
00:07:15,820 --> 00:07:18,340
But that was just the UI of the show image.

112
00:07:18,340 --> 00:07:19,450
PY file closing.

113
00:07:20,680 --> 00:07:21,010
Great.

114
00:07:21,010 --> 00:07:24,520
So we successfully installed and use this Ross package.

115
00:07:24,550 --> 00:07:29,300
If you ever want to remove it, you can do so like any other app program using the app.

116
00:07:29,320 --> 00:07:30,220
Remove call.

117
00:07:33,590 --> 00:07:35,300
Go ahead and hit Y and enter.

118
00:07:37,560 --> 00:07:39,510
And now that package has been removed.

119
00:07:39,510 --> 00:07:44,040
So if I actually go back to our humble distribution, I could head over to share.

120
00:07:44,400 --> 00:07:49,290
And if I scroll down to the bottom, we now no longer have that USB camera directory.

121
00:07:50,060 --> 00:07:53,930
And just to confirm this further, you can go ahead and relaunch the demo launch pie.

122
00:07:53,930 --> 00:07:57,170
And of course, USB cam package is not found.

123
00:07:57,410 --> 00:08:01,840
Now, let's take a look at installing ROS packages by building them from source.

124
00:08:01,850 --> 00:08:04,910
So let's head back to the ROS index page.

125
00:08:04,910 --> 00:08:09,050
So again, you can head over to browse code and it'll take you to the source code location, which in

126
00:08:09,050 --> 00:08:10,540
this case is GitHub.

127
00:08:10,550 --> 00:08:16,190
So what I actually want to do is clone this repo, which is actually a ROS package, right?

128
00:08:16,190 --> 00:08:18,410
So just like what we've been creating so far.

129
00:08:18,410 --> 00:08:23,420
So if I go over to code, we can copy this URL.

130
00:08:23,780 --> 00:08:30,320
And now if I head over to our terminal and just to show you what's going on here, I'll go into workspaces

131
00:08:30,320 --> 00:08:32,510
Ros to my workspace and source.

132
00:08:32,510 --> 00:08:36,560
And again, this is the location of all the packages which are located in our workspace.

133
00:08:36,560 --> 00:08:42,260
So we're going to be putting the USB cam package here alongside our Udemy ROS two package.

134
00:08:42,260 --> 00:08:52,640
So I'll go ahead and resize this so we can see what's going on and I'll change into this directory.

135
00:08:52,640 --> 00:08:52,970
All right.

136
00:08:52,970 --> 00:08:58,970
So we see our ROS two package and now we're going to be using the Git Clone command to clone that USB

137
00:08:58,970 --> 00:09:00,050
cam repository.

138
00:09:04,830 --> 00:09:05,160
All right.

139
00:09:05,160 --> 00:09:10,830
So now we see this USB cam package has the folders and corresponding things related to what we're seeing

140
00:09:10,830 --> 00:09:12,840
here in the GitHub.

141
00:09:13,140 --> 00:09:17,520
Although if you notice, it actually looks a little bit different and that's because we're using the

142
00:09:17,520 --> 00:09:19,510
standard master branch.

143
00:09:19,530 --> 00:09:22,560
So GitHub repositories have branches.

144
00:09:22,560 --> 00:09:28,960
So here we can see a series of different branches which is develop Master Ros two and so on.

145
00:09:29,010 --> 00:09:35,070
So we want this Ros to branch, which is what got sent to us when we clicked on the ROS index page.

146
00:09:35,160 --> 00:09:39,030
So in order to switch branches, all we have to do is go into the folder.

147
00:09:40,620 --> 00:09:47,430
So again, we'll take a look at this and I'll close this just a little bit and then I can switch the

148
00:09:47,430 --> 00:09:52,830
branch using the git switch command called by the name of the branch, which in this case is ROS two.

149
00:09:53,010 --> 00:09:57,990
And here, if you were looking over here to the left, you saw that the file's changed because now we're

150
00:09:57,990 --> 00:10:01,440
using the corresponding branch of the files we're seeing here.

151
00:10:01,590 --> 00:10:04,260
So with that, I have the right code within this package.

152
00:10:04,260 --> 00:10:06,810
So now I just need to compile my workspace.

153
00:10:06,810 --> 00:10:09,180
So I'll go back into my workspace folder.

154
00:10:10,500 --> 00:10:11,460
And I'll run.

155
00:10:11,460 --> 00:10:12,450
Call can build.

156
00:10:13,980 --> 00:10:17,280
And of course, you can add your normal options, such as Simulink install.

157
00:10:19,860 --> 00:10:23,940
And here I will specify that I only want to rebuild the USB cam package.

158
00:10:23,940 --> 00:10:29,190
I don't want to have to rebuild our Udemy Ross two package so I can do this with the packages.

159
00:10:29,190 --> 00:10:30,300
Select flag.

160
00:10:33,570 --> 00:10:39,330
And then specify the only package I want to rebuild, which in this case is USB cam.

161
00:10:39,720 --> 00:10:41,190
So I'll go ahead and expand this a little bit.

162
00:10:41,190 --> 00:10:42,590
Just you can see the full command.

163
00:10:42,600 --> 00:10:46,920
So there we go, Colon build Simulink install package, select USB cam.

164
00:10:47,610 --> 00:10:48,900
So if I go ahead and hit enter.

165
00:10:54,940 --> 00:10:55,300
All right.

166
00:10:55,300 --> 00:10:59,380
So notice here we tried to build, but it seems we're missing something.

167
00:10:59,380 --> 00:11:02,320
It says no such file or directory fatal error.

168
00:11:02,320 --> 00:11:06,460
It tried to include this camera info manager http file.

169
00:11:06,460 --> 00:11:10,510
So for those of you who don't understand C++ debugging, that's fine.

170
00:11:10,510 --> 00:11:15,730
All that's really happening here is we are missing some core dependencies to our USB cam package.

171
00:11:15,730 --> 00:11:20,700
So notice throughout the course we've been updating our package on XML files.

172
00:11:20,710 --> 00:11:27,070
So if we open this with text editor, we see this has its own types of dependencies just like our package

173
00:11:27,070 --> 00:11:33,490
has, so we're most likely missing this camera info manager dependency, which this ROS package depends

174
00:11:33,490 --> 00:11:33,940
on.

175
00:11:34,330 --> 00:11:39,490
So the reason for this package of XML file is to tell us the dependencies we need and then we can actually

176
00:11:39,490 --> 00:11:42,700
install them automatically using the Ross DEP command.

177
00:11:50,260 --> 00:11:53,740
So here we're telling it to insult dependencies from source.

178
00:11:53,740 --> 00:11:54,850
So don't worry about this.

179
00:11:54,850 --> 00:11:56,140
Ignore source at the end.

180
00:11:56,140 --> 00:12:01,810
All this is saying is it ignores installing any dependencies if they are already exists within the workspace.

181
00:12:01,810 --> 00:12:03,040
So this is very helpful.

182
00:12:03,040 --> 00:12:08,830
If you had multiple different ROS modules which you wanted to freeze at a certain instance and instead

183
00:12:08,830 --> 00:12:13,960
of installing those dependencies directly onto your computer, it'll make sure to reference the ones

184
00:12:13,960 --> 00:12:15,430
in the workspace.

185
00:12:15,430 --> 00:12:18,040
But for now, let's just ignore that and we'll just go ahead and hit enter.

186
00:12:20,110 --> 00:12:20,950
I made a typo here.

187
00:12:20,950 --> 00:12:22,030
I meant to say source.

188
00:12:22,030 --> 00:12:28,210
So here we can see it's running apt install Ros humble camera and volt manager and we're going to have

189
00:12:28,210 --> 00:12:29,800
to put in our password for this.

190
00:12:29,970 --> 00:12:33,790
It's going to do this for all of the missing dependencies automatically for us.

191
00:12:39,720 --> 00:12:43,380
So here it says all required raw steps were installed successfully.

192
00:12:43,380 --> 00:12:48,480
So go ahead and clear the screen and now we can try and rebuild our workspace.

193
00:12:50,490 --> 00:12:54,770
So we'll be running our coal can build command and just rebuilding that USB cam package.

194
00:12:54,780 --> 00:12:56,370
So try running this one more time.

195
00:12:56,850 --> 00:13:00,840
And it seems we're still running into issues, so I'm going to go ahead and do is restart our workspace

196
00:13:00,840 --> 00:13:02,970
instance because it seems like something's bugged out.

197
00:13:02,970 --> 00:13:08,940
So I will be deleting our build, install and log folders so that we'll be recreating them when we run.

198
00:13:08,950 --> 00:13:09,900
Coal can build.

199
00:13:15,050 --> 00:13:17,240
Make sure not to delete the source folder.

200
00:13:18,680 --> 00:13:20,360
So now we only have our source folder.

201
00:13:22,110 --> 00:13:28,260
Here in our workspace and I'll rerun the can build command and we'll just build all packages in this

202
00:13:28,260 --> 00:13:28,950
case.

203
00:13:33,140 --> 00:13:34,040
And there we go.

204
00:13:34,040 --> 00:13:39,110
So I know that was a little bit of a rough patch there, but essentially sometimes when we're compiling

205
00:13:39,110 --> 00:13:43,790
things, it'll save certain sym links within our build file so that we can build faster the next time

206
00:13:43,790 --> 00:13:44,270
around.

207
00:13:44,270 --> 00:13:49,370
And it most likely saved something which made it continue to think that the camera info manager did

208
00:13:49,370 --> 00:13:50,450
not exist properly.

209
00:13:50,450 --> 00:13:56,780
So we just simply restarted our workspace by deleting the build, install and log folders and everything

210
00:13:56,780 --> 00:13:58,250
compiled successfully.

211
00:14:09,730 --> 00:14:12,160
So now let's go ahead and source this workspace.

212
00:14:17,140 --> 00:14:20,530
And try rerunning the demo launch file we ran earlier.

213
00:14:28,760 --> 00:14:29,330
Hello.

214
00:14:32,230 --> 00:14:37,060
Last but not least, to remove this package from your workspace, you'll need to delete the package

215
00:14:37,060 --> 00:14:38,290
from your source folder.

216
00:14:38,290 --> 00:14:44,770
So just go ahead and delete that and you will need to remove your build, install and log folders again,

217
00:14:44,770 --> 00:14:48,370
just as we did earlier, because there will still be instances pointed to it.

218
00:14:48,370 --> 00:14:53,890
So in this case we still have connections to this USB cam package which no longer exists.

219
00:14:53,890 --> 00:14:59,530
So we'll just go ahead and delete these one more time and rerun our.

220
00:15:03,710 --> 00:15:03,960
All right.

221
00:15:03,960 --> 00:15:08,660
And we got a little warning message because we are a source to our environment, which was deleted momentarily

222
00:15:08,660 --> 00:15:09,140
there.

223
00:15:09,320 --> 00:15:13,250
But you can see our roster package has finished compiling.

224
00:15:13,250 --> 00:15:18,200
So we're back to normal to the way we were with our workspace before this lecture started.

225
00:15:18,200 --> 00:15:22,790
In the future, I believe they will integrate a Coke and clean functionality similar to what Cat Can

226
00:15:22,790 --> 00:15:27,920
Clean did for Ross one, which is able to figure out which files belong to what packages and delete

227
00:15:27,920 --> 00:15:28,430
them for you.

228
00:15:28,430 --> 00:15:31,690
So you don't have to do this part manually like we just did.

229
00:15:31,700 --> 00:15:35,030
So I'll be on the lookout for that when that makes its way to official release.

230
00:15:36,660 --> 00:15:40,950
Now, why would you build from source if using app install is so much easier?

231
00:15:41,220 --> 00:15:47,640
Well, sometimes you may find community ROS packages which are not published to the ROS index or sometimes

232
00:15:47,640 --> 00:15:51,750
people want to freeze dependencies they are using within their own workspace.

233
00:15:51,760 --> 00:15:57,600
So it is important to know about how to build other people's packages from its source code, which we've

234
00:15:57,600 --> 00:16:02,250
been practicing throughout the previous section by compiling our own code within our workspace.

235
00:16:02,400 --> 00:16:07,980
But with that you have successfully learned how to install packages using app install and by building

236
00:16:07,980 --> 00:16:09,410
it within our workspace.

237
00:16:09,420 --> 00:16:15,360
This allowed us to download another ROS developer's package which has launch files and nodes that allow

238
00:16:15,360 --> 00:16:20,280
us to publish the image tree from our USB camera over ROS to.
