Throughout this course, we have been organizing our code within a Roth package.
In this lecture, we're going to take a look at Rust, two packages made by other developers and use
it.
The packages we will ultimately be using is the USB cam package.
You should be able to follow along with me.
If you have a laptop with a built in camera or a camera which you can plug in via USB.
First thing to do before we get into anything.
Ross related is a check that our camera works properly in Ubuntu.
We can use an app called cheese, which should be installed by default.
If I click on it, you can see a window open which shows my camera feed.
Hello.
If you're unable to get that to work, chances are you will also have a hard time trying to get it to
work in.
Ross.
If you are using a virtual machine, make sure to configure your virtual machine settings USB to be
able to utilize USB three ports if that is what your camera is plugged into.
With that out of the way, let's get to the rock packages.
Let's go ahead and open up a browser to search for readily available rescue packages.
We can check out the Ross Index site.
If you have used Ross one before, you are probably more familiar with the Ross wiki to find information
about packages.
Justin Keep in mind that going forward all Ross to package info will instead be found on the Ross index
page and will not be kept on this Ross wiki.
On the Ross Index home page.
You can see the current active distributions at the time of this recording.
You may see different distros as galactic will be depreciated in November 2022 and melodic in May 2023.
If you click on any of these links, it'll take you to the general distribution Description page.
Instead, we are interested in checking out some of the Ross packages available so I can hit the packages
list button in the upper left.
Here we get a list of Ross packages for the humble distribution sorted by latest release date.
You could click on other distributions to check out the corresponding supported packages.
Package we are going to be using is called USB cam so I can go ahead and search for it in the search
bar.
We get some results.
And near the top we see the USB cam package for the humble distribution.
So I'll go ahead and click on that.
So here we're taking to the package page.
At the top you can see the supported distros for this package.
And slightly lower.
We can see things such as the package description, summary and repository information.
If we scroll down further, we'll get brought to a redmi MD file in the package repo, which generally
gives a detailed description of what the package is and how to use it.
And past that we get a changelog with various changes that were made to this package.
So I'll go ahead and scroll back up.
So here in the redmi it tells us how to install the package with apt install as well as instructions
on how to build a package from source.
And we can scroll down further.
To see examples of running this node using the available launch files and nodes.
And one last thing I want to show before we get into this is near the top.
You can find a link to the repository which the package is hosted on.
So here if we head over to browse code, I can go ahead and open this in a new tab and which takes us
to, in this case, a GitHub page which hosts the code development for this USB cam package.
So if you ever want to look at the source code before installing a package, this is one of the ways
you could go about doing it.
So for example, we can check out the launch files.
So here we see there's a demo launch py file.
And we can see some of the scripts that are available, such as Show Image Pie.
So I'll go ahead and close that.
All right.
With that intro out of the way, let's go ahead and install this package so we can use our USB camera
with Ross.
So here in the Quickstart section I mentioned earlier, we can install this package using the apt install
command.
So it's simply apt install Ross followed by the distribution name and then the name of the package which
is USB dash can.
Worth mentioning that package names use an underscore snake case convention to separate words.
So this package name is USB underscore cam, but note that the APT install command follows a dash convention
in which each word is separated with a dash instead of an underscore.
So auto students sometimes wonder why they can't install a package, and usually it's because they don't
follow this particular command line convention when trying to run app install.
But let's go ahead and open up a terminal and install it.
So the way I have this command format, it works just fine.
But note another popular convention you may see is the following.
Now, this may seem weird and much more complex than what I had before, but this command will install
the package regardless of what ros distro you have installed and source by utilizing the Ross distro
environment variables so I can actually go ahead and open up a second terminal.
And if I echo this environment variable.
So echoing it, we see we get humble, which is the name of our Disher that we're using.
So essentially in this command where we have this dollar sign Ross distro, this gets replaced with
the string humble just as we saw earlier.
But if we're using a different distribution such as Foxy or Noetic, then the above command will still
install the correct distribution version of the package.
So I'll go ahead and close the second terminal and go ahead and install the USB cam package.
Go ahead.
Put in your password.
Or why?
Enter.
OC.
We have installed the USB cam package.
Packages installed this way can be found in your op ross distro folder.
Some of the files, such as the launch and package files, will end up in the share folder and the executables
can be found in the lib folder so I can head over to share and then we'll scroll to the bottom.
And we can see USB cam.
And here we can see some of the package files such as the launch folder and other environment and configuration
files.
If I go back.
Can head over to lib.
Scroll down.
Yes, we can.
And here we actually can see some of the nodes that were available in this package.
So now that we have this package installed, let's go ahead and run the launch file we saw earlier.
Since we installed it with app install.
It is now part of our ROS Humble installation environment, so by default we can use the package without
having to do any extra environment sourcing.
So go ahead and clear the screen and then we can run it like so.
If all goes well, you should see a pop up window displaying your image feed from your camera.
Hello.
You can also open a new terminal and see the various topics the USB cam node is publishing.
Can then go ahead and stop the launch file by hitting control C in the particular terminal and you might
get a crash report error.
But that was just the UI of the show image.
PY file closing.
Great.
So we successfully installed and use this Ross package.
If you ever want to remove it, you can do so like any other app program using the app.
Remove call.
Go ahead and hit Y and enter.
And now that package has been removed.
So if I actually go back to our humble distribution, I could head over to share.
And if I scroll down to the bottom, we now no longer have that USB camera directory.
And just to confirm this further, you can go ahead and relaunch the demo launch pie.
And of course, USB cam package is not found.
Now, let's take a look at installing ROS packages by building them from source.
So let's head back to the ROS index page.
So again, you can head over to browse code and it'll take you to the source code location, which in
this case is GitHub.
So what I actually want to do is clone this repo, which is actually a ROS package, right?
So just like what we've been creating so far.
So if I go over to code, we can copy this URL.
And now if I head over to our terminal and just to show you what's going on here, I'll go into workspaces
Ros to my workspace and source.
And again, this is the location of all the packages which are located in our workspace.
So we're going to be putting the USB cam package here alongside our Udemy ROS two package.
So I'll go ahead and resize this so we can see what's going on and I'll change into this directory.
All right.
So we see our ROS two package and now we're going to be using the Git Clone command to clone that USB
cam repository.
All right.
So now we see this USB cam package has the folders and corresponding things related to what we're seeing
here in the GitHub.
Although if you notice, it actually looks a little bit different and that's because we're using the
standard master branch.
So GitHub repositories have branches.
So here we can see a series of different branches which is develop Master Ros two and so on.
So we want this Ros to branch, which is what got sent to us when we clicked on the ROS index page.
So in order to switch branches, all we have to do is go into the folder.
So again, we'll take a look at this and I'll close this just a little bit and then I can switch the
branch using the git switch command called by the name of the branch, which in this case is ROS two.
And here, if you were looking over here to the left, you saw that the file's changed because now we're
using the corresponding branch of the files we're seeing here.
So with that, I have the right code within this package.
So now I just need to compile my workspace.
So I'll go back into my workspace folder.
And I'll run.
Call can build.
And of course, you can add your normal options, such as Simulink install.
And here I will specify that I only want to rebuild the USB cam package.
I don't want to have to rebuild our Udemy Ross two package so I can do this with the packages.
Select flag.
And then specify the only package I want to rebuild, which in this case is USB cam.
So I'll go ahead and expand this a little bit.
Just you can see the full command.
So there we go, Colon build Simulink install package, select USB cam.
So if I go ahead and hit enter.
All right.
So notice here we tried to build, but it seems we're missing something.
It says no such file or directory fatal error.
It tried to include this camera info manager http file.
So for those of you who don't understand C++ debugging, that's fine.
All that's really happening here is we are missing some core dependencies to our USB cam package.
So notice throughout the course we've been updating our package on XML files.
So if we open this with text editor, we see this has its own types of dependencies just like our package
has, so we're most likely missing this camera info manager dependency, which this ROS package depends
on.
So the reason for this package of XML file is to tell us the dependencies we need and then we can actually
install them automatically using the Ross DEP command.
So here we're telling it to insult dependencies from source.
So don't worry about this.
Ignore source at the end.
All this is saying is it ignores installing any dependencies if they are already exists within the workspace.
So this is very helpful.
If you had multiple different ROS modules which you wanted to freeze at a certain instance and instead
of installing those dependencies directly onto your computer, it'll make sure to reference the ones
in the workspace.
But for now, let's just ignore that and we'll just go ahead and hit enter.
I made a typo here.
I meant to say source.
So here we can see it's running apt install Ros humble camera and volt manager and we're going to have
to put in our password for this.
It's going to do this for all of the missing dependencies automatically for us.
So here it says all required raw steps were installed successfully.
So go ahead and clear the screen and now we can try and rebuild our workspace.
So we'll be running our coal can build command and just rebuilding that USB cam package.
So try running this one more time.
And it seems we're still running into issues, so I'm going to go ahead and do is restart our workspace
instance because it seems like something's bugged out.
So I will be deleting our build, install and log folders so that we'll be recreating them when we run.
Coal can build.
Make sure not to delete the source folder.
So now we only have our source folder.
Here in our workspace and I'll rerun the can build command and we'll just build all packages in this
case.
And there we go.
So I know that was a little bit of a rough patch there, but essentially sometimes when we're compiling
things, it'll save certain sym links within our build file so that we can build faster the next time
around.
And it most likely saved something which made it continue to think that the camera info manager did
not exist properly.
So we just simply restarted our workspace by deleting the build, install and log folders and everything
compiled successfully.
So now let's go ahead and source this workspace.
And try rerunning the demo launch file we ran earlier.
Hello.
Last but not least, to remove this package from your workspace, you'll need to delete the package
from your source folder.
So just go ahead and delete that and you will need to remove your build, install and log folders again,
just as we did earlier, because there will still be instances pointed to it.
So in this case we still have connections to this USB cam package which no longer exists.
So we'll just go ahead and delete these one more time and rerun our.
All right.
And we got a little warning message because we are a source to our environment, which was deleted momentarily
there.
But you can see our roster package has finished compiling.
So we're back to normal to the way we were with our workspace before this lecture started.
In the future, I believe they will integrate a Coke and clean functionality similar to what Cat Can
Clean did for Ross one, which is able to figure out which files belong to what packages and delete
them for you.
So you don't have to do this part manually like we just did.
So I'll be on the lookout for that when that makes its way to official release.
Now, why would you build from source if using app install is so much easier?
Well, sometimes you may find community ROS packages which are not published to the ROS index or sometimes
people want to freeze dependencies they are using within their own workspace.
So it is important to know about how to build other people's packages from its source code, which we've
been practicing throughout the previous section by compiling our own code within our workspace.
But with that you have successfully learned how to install packages using app install and by building
it within our workspace.
This allowed us to download another ROS developer's package which has launch files and nodes that allow
us to publish the image tree from our USB camera over ROS to.