All the details (and unique quirks) that I found out during my Summer Internship
- ROS2 Galactic installed on Ubuntu Linux 20.04
- Note: this tutorial is designed for Ros2 Foxy so replace all "foxy" with "galactic"
- You have created a ROS 2 workspace (I had "dev_ws")
- Python 3.7 installed
- You have a package named two_wheeled_robot inside ~/dev_ws/src
- From this tutorial
A very useful series of websites is made by AutomaticAddison. Some of the sections in the website is out of date so take all the files from their Github
If in doubt:
- StackOverflow
- Gazebo Answers
- ROS Answers
Follow these steps first. Only go to option 2 if you can't save the Gazebo world
-
Load up gazebo (in verbose mode you can find any errors that come up)
gazebo --verbose
-
Go to Edit -> Model Editor (Ctrl + M)
-
Go to Custom Shapes and click add
-
Then browse for the model you want to add
This will be a collada (.dae) file
Make sure the collada file is in a folder with all the textures required
-
Place your model in the world and save the model
-
To change the model from grey to the textures you added:
- Go to your file manager and go to the folder model_editor_models
- Find the folder corresponding to the model name you just saved
- Open the model.sdf
- Delete this seciton of code:
<material> <lighting>1</lighting> <script> <uri>file://media/materials/scripts/gazebo.material</uri> <name>Gazebo/Grey</name> </script> <shader type='pixel'/> </material>
-
Delete the model from your world
-
Insert the model (from the insert tab)
-
Repeat these steps until you have created your desired world
-
To save the world, go to File -> Save World As (Ctrl + shift + s)
If you encounter an issue where you can't save your gazebo world, follow these steps
-
Load up Gazebo using sudo
`sudo gazebo --verbose`
-
Follow steps 2 - 5 in Option 1
-
To change the model from grey to the textures you added:
- Open a new terminal and type:
sudo nautilus
- Find the folder corresponding to the model name you just saved
- Open the model.sdf
- Delete this seciton of code:
<material> <lighting>1</lighting> <script> <uri>file://media/materials/scripts/gazebo.material</uri> <name>Gazebo/Grey</name> </script> <shader type='pixel'/> </material>
-
Delete the model from your world
-
Insert the model (from the insert tab)
-
Repeat these steps until you have created your desired world
-
To save the world, go to File -> Save World As (Ctrl + shift + s)
- Open Gazebo
- Add what ever models to your world that you would like
- Save the model in thee two_wheeled_robots/worlds folder
- Open up that file and paste this section of code at the end just above :
<include> <uri>model://two_wheeled_robot_description</uri> <static>false</static> <pose>-20.0 4.0 3.5 0 0 0</pose> </include>
-
Creating the launch file
colcon_cd two_wheeled_robot
cd launch
gedit load_world_into_gazebo.launch.py
-
Add the code from the load_world_into_gazebo.launch.py file which is in the repository
-
Change line 24 from
world_file_name = 'CHANGE_ME.world'
to the name of your world -
Save the file and close it
-
Go to your root directory
cd ~/dev_ws
-
Build the package
colcon build
-
Open a new terminal and run the launch file using this command:
ros2 launch two_wheeled_robot load_world_into_gazebo.launch.py
Creating a map for rviz involves taking a picture of the floor plan (either .png or .jpeg) and outputs a .pmg and a .yaml file which sets the scale of the map
BE AWARE: door diagrams and other marks in the picture will be perceived as a wall. Use software like paint to remove the unnecessary information
-
Add the files needed which is in the maps folder in the root directory
- Add the file convert_to_binary.py
- Add the file MakeROSMap.py
-
Change the file names in the "convert_to_binary.py" indicated by the CHANGE_ME
-
Convert the floorplan to binary and then make the ros map
To run code do
python3 *insert file name here*
in a terminalFollow the prompts in the terminal
-
Edit the .yaml file kjhdsakjhsakjdhfkjsdhgkjsfkjheksjfhkjhkjdhksjhkjhkjhkjhkjkjhkjhkjh
Change the file names in the launch file
def generate_launch_description():
package_name = 'two_wheeled_robot'
robot_name_in_model = 'two_wheeled_robot'
default_launch_dir = 'launch'
gazebo_models_path = 'models'
map_file_path = 'maps/CHANGE_ME.yaml'
nav2_params_path = 'params/CHANGE_ME/nav2_params.yaml'
robot_localization_file_path = 'config/ekf.yaml'
rviz_config_file_path = 'rviz/CHANGE_ME/nav2_config.rviz'
sdf_model_path = 'models/two_wheeled_robot_description/model.sdf'
urdf_file_path = 'urdf/two_wheeled_robot.urdf'
world_file_path = 'worlds/CHANGE_ME.world'
Note: After any edit of any file, you must rebuild the file
-
Open a new terminal and go to the root directory and build the files
cd ~/dev_ws
colcon build
-
Open another new terminal and type in this command:
ros2 launch two_wheeled_robot *insert_launch_file_name*.launch.py
Assumption that the two_wheeled_robot 's .sdf and .udrf has been set up for using a camera
- Click on the button "ADD" which is on the left of the screen
- Go to By topic -> /depth camera/ image and click OK
- Find the image in the Display section (on the left of the screen)
- Go to Topic -> Reliaility Pollicy and change from "Reliable" to "Best Effort"
Note: You can drag the image section out of the rviz window to have a seperate window of what the robot camera is seeing
To install the the package type this command:
sudo apt-get install ros-galactic-rqt-robot-steering
Then open a new terminal and to run the program type this command:
rqt_robot_steering
You can either interact with the GUI with your mouse or using WASD to move the robot.
Note: Having the camera set up makes moving the robot around a lot easier