In this lecture, we will take our Simple World file a little bit further by adding in some sensors
and utilizing plug ins.
So let's take our Simple World file a bit further by adding in some sensors, and we can do this by
going back to the example PSD file for the camera sensor that we were looking at earlier as a reference.
Just a reminder that you can find this file in the following folder on your computer.
So go to other locations.
Computer User Share Ignition, Mission, Gazebo, six and Worlds.
And this is where you will find all of these example world files.
And we're going to be going off the camera sensor, SDF.
Now, keep in mind, in order to utilize sensors, you must have included the sensor plugin within your
SDF file.
So now let's try to implement some of these features in our simple test world SDF file.
The main thing I will copy over are the physics sensor, user commands and scene broadcasts or plug
ins, and I'll place them near the top of my file.
And just to tidy this up a bit, I'm going to go ahead and delete all the things we have commented out
here from that example model that we've created earlier.
So instead we're just going to be including the Sun model for some lighting and our ground plane model,
which we made earlier in the previous lecture.
So now let's go back to the camera sensor SDF file, and I'm going to scroll down till we get to this
camera model.
So we're just going to go ahead and copy and paste it directly into our file to see if we can get it
working in our test world.
Now, one of the tags I didn't go over yet is the post tag which we see here near the top of the model,
and we also can have poses for our individual links.
These post tags allow you to place your object within the desired x, y, z role.
Pitch your space in your simulation.
So here we see our camera is at an X position of for a y position of zero, a z position of 1.0 and
a roll of zero degrees in radiance your of 0.0 degrees and 3.14 radians in the Z or your axis of rotation.
And for those of you who don't know, 3.14 radians is 180 degrees.
So basically the camera normally faces in the positive X direction, but in this case it is turned around
to face towards the origin.
I can also go ahead and change the attributes of our image to be a slightly higher resolution to say
for AP.
All right.
That's all the changes I'll make for right now.
So I'll go ahead and save what we have so far and we can go ahead and try to run this in terminal.
And we want to make sure that we are properly including our models which we have imported in such as
this ground plane.
So I'll be sure to set the ignition gazebo resource path environment variable.
All right, Let's test out what we have so far.
So we see our total ground plane and a small black cube which represents our camera.
Now, keep in mind that this black cube, which is representing our camera, also has physics and collision
models enabled on it.
So if we actually play the simulation, we'll see it falls to the ground.
If you didn't want this, you could set these static property to true within our model.
But let's see if we're able to successfully integrate our camera sensor into ROS.
So I'll be sure to play the simulation.
Head over to our terminal, Open a new terminal tab.
And let's go ahead and list some of the topics that we have available in ignition.
All right.
And we see the camera topic here.
Now, I know we took a look at this topic in the last lecture, but in case you ever wanted to find
information about a particular ignition topic, simply do the dash I flag for info and pass in the particular
topic you're interested in, which in this case we're interested in camera.
So this will tell you things such as that.
It's a publisher and then the address and the message type.
So it's giving you the TCP address as well as the type of ignition message type that it is.
And that might be useful if we're trying to bridge our topic into ROS, which we'll go ahead and do
right now.
So again, we saw this command in the last lecture, but essentially here I'm running the perimeter
bridge node from the Ross Gazebo Bridge Ross package, and I'm taking the camera topic from ignition
and converting it to a sensor messages image message type in Ross And then we are passing it from that
ignition messages image type, which we saw right here.
Then I'm passing in Ross Arcs to simply remap the topic name from camera to camera image raw, which
is a type of format you would normally see within raw systems.
So I'll go ahead and hit enter.
Open up a third terminal tab.
And I'll go ahead and run our.
And here we already had it set up from the last lecture.
But again, if you needed to get to this point, simply go to plugins, visualization, image view,
and from here you can refresh the topics and select the one from above.
So here we just see a ground upper rectangle and a teal lower rectangle.
And that's just what our world looks like from the perspective of our camera.
Now I can actually.
Go ahead.
And I'll pause the simulation.
And I'll see if I can move our camera.
I'll go ahead and move this back up.
All right.
So nothing seems to have changed.
But if I go ahead and put this to the side.
Move this a bit over.
If I hit play, we'll see that the live image feed had changed.
And I can also prove this by placing down additional shapes within the simulation like so.
All right, so that's simple enough.
Now, let's go ahead and see how we can change up this simulation to include things such as a image
view window directly within the simulation.
So I'll go ahead and stop this from running and head back to our VS code instance.
So if we head back to that sample camera sensor SDF file.
So if we scroll up to the top here, we can actually see this gooey tags.
It stands for a graphical user interface.
So we scroll down.
So within these tags we have a series of plug ins related to interfacing with the user interface and
modifying it.
So we have things such as what type of engine and scene renderer we're utilizing and you can do things
such as change the title of the ignition gazebo window.
And here we see things such as the entity context menu, gazebo, scene manager and interactive view
Control.
So a few of these are what I'm actually interested in.
And to get a feel for this, let's actually go ahead and run this example simulation.
So ignition.
Gazebo.
Camera sensors.
And this is not in our world file, but it'll automatically default to that default worlds directory,
which we looked at earlier.
So here we see a few things within the user interface, which we may not have had earlier.
Specifically this image display window.
So if we actually go ahead and hit play, we'll see these things fall down.
If we go ahead and refresh, we see the camera topic and we have this image viewer directly in the user
interface, which might be useful to you.
So let's go ahead and add that in to our Test world file.
So for now, I'm just going to go ahead and copy all the contents within this goofy tag.
And we'll place it just below the other plugins that we put in our file earlier.
Now let's say I want to switch things up a bit and remove the entity tree and component inspector so
that the simulation window only contains the viewport and the image display.
So all I have to do is remove the corresponding plugins.
One of the properties I can modify for this display is I can change the state tag from docked to floating,
and instead of locking it to the right sidebar in the simulation, this will give us a floating window
within the simulation.
So now if I save our test world file and relaunch it in our terminal.
Here.
We have a test file, but we don't have all the normal components we would normally have here on the
right side.
Instead, we have this floating window, which is for our image display.
So now we've subscribed to camera.
If I hit play, we will see the image feed directly within the simulation.
And so this might be useful so that you don't have to bridge the camera topic every time and look through
it in RCT.
You can simply look at what your camera feed sees in your simulation within this simulation window.
Now, that was a lot of code to put into our world file just so that we could configure our user interface.
So optionally, you can save the configuration to an external file within the ignition gazebo simulation
by hitting to this left tab over here.
And we can save client configuration as.
And here you can select a location to save it.
And I'll just set mine as test sim gui config.
And for now, I'll just save it to my home directory.
So that's gone ahead and saved.
And so now if I go ahead and close this.
And now, if I were to go ahead and actually delete all the things we just pasted in for configuring
our user interface.
Right?
So now we're just back to our normal physics plugins and then our models that we're including.
So if I go ahead and save this.
And rerun our test world.
Right, we get this standard configuration, but if we wanted to load that config file we just saved,
all we have to do is pass it an extra parameter.
So when we go to launch our test world SDF, we can type gooey dash config and then we can put in the
location of our config file, which in this case is test sim gui config.
And now we see that it is configured as we had it earlier.
So I have this now floating image view window without having to have all the necessary backbone code
directly here in my test world file.
It's instead within the config file, which we could simply include within our package.
And so this has a lot of attributes just to simply match exactly what you had in your client interface
to make sure it matches when somebody else opens it.
So we didn't have to include any of this within our Test SIM world file.
So that helps us out a little bit, keep things a little bit cleaner.
Now that was a bit take taken, but essentially we added some code to our PSD files to do things such
as configure our simulation user interface and even include sensors, which we could include on our
robot.
In the next lecture, we'll take a look at one of the ways we can create our own robot models so that
we can include them in our ignition gazebo simulation.