└── README.md /README.md: -------------------------------------------------------------------------------- 1 | #### Table of Contents: 2 | 1. [Introduction](#ros-tutorials-and-projects) 3 | 1. [Week 1](#week-1) 4 | * [Assignment 1](#assignment-1) 5 | 1. [Week 2](#week-2) 6 | * [Assignment 2](#assignment-2) 7 | 1. [Week 3](#week-3) 8 | * [Assignment 3a](#assignment-3a) 9 | * [Assignment 3b](#assignment-3b) 10 | 1. [Week 4](#week-4) 11 | 12 | # ROS - Tutorials and Projects 13 | 14 | Hello everyone, 15 | Hope you are safe and doing some productive work at home. If you are enthusiastic in robotics then, Electronics and Robotics Club is here once again to help you out in exploring this field along with ITSP. 16 | Have you ever wondered “How to coordinate between multiple drones? How to simulate a manipulator or robot? How does a robot map the environment and navigate in it?” Answer to each and every question is ROS! These are only some of its applications. ROS applications go far beyond your imagination, above are only some basic things to mention. So what exactly is ROS? 17 | 18 | ___ROS___, which means the Robot Operating System, is a set of software libraries and tools to help you build robot applications. It provides hardware abstraction, device drivers, libraries, visualizers, message-passing, package management, and more. The point of ROS is to create a __robotics standard__, so you don't need to __reinvent the wheel anymore when building new robotic software.__ 19 | 20 | 21 | 27 | 28 | ### Main Objectives of this Tutorial: 29 | 1. The objective of this course is to give you the basic tools and knowledge to be able to understand and create any basic ROS related project. You will be able to move robots, read their sensor data, make the robots perform intelligent tasks, see visual representations of complex data such as laser scans and debug errors in the programs. 30 | 1. This will allow you to understand the packages that others have done. So you can take ROS code made by others and understand what is happening and how to modify it for your own purposes 31 | 1. This can serve as an introduction to be able to understand the ROS documentation of complex ROS packages for object recognition, text to speech, navigation and all the other areas where ROS developed code. 32 | 33 | ## Week 1 34 | * __Ubuntu Installation__ : 35 | For using ROS framework Ubuntu is necessary: 36 | (It's Preferable that you install Ubuntu 16.04) 37 | Follow this [Tutorial](https://parthvpatil.github.io/tutorial/2019/06/03/ubuntu.html "Ubuntu Installation") to install ubuntu in your laptop. 38 | [WARNING], Do at your own risk! We will be not responsible if you lose your data. __Follow instructions carefully and make backups before you start!__ 39 | 40 | * __Get familiar with Linux__: 41 | Here are a few resources that you can refer to in order to get familiar with Linux: 42 | * [Video-based Tutorial](https://www.youtube.com/watch?v=IVquJh3DXUA "Introduction to Linux and Basic Linux Commands for Beginners") 43 | * [Text-based Tutorial](https://ryanstutorials.net/linuxtutorial/ "Linux Tutorial") 44 | 45 | * __ROS Installation/setup__: 46 | - For Ubuntu 16.04: [ROS Kinetic Kame](http://wiki.ros.org/kinetic/Installation "kinetic/Installation") 47 | - For Ubuntu 18.04: [ROS Melodic Morena](http://wiki.ros.org/melodic/Installation "melodic/Installation") 48 | Go to a particular link and put your first step in the world of ROS. 49 | 50 | ### **Getting started with the ROS:** 51 | 52 | *Now that the installation is done, let’s dive into ROS!* 53 | 54 | #### **What is ROS?** 55 | 56 | ROS is a software framework for writing robot software. The main aim of ROS is to reuse the robotic software across the globe. ROS consists of a collection of tools, libraries, and conventions that aim to simplify the task of creating complex and robust robot behavior across a wide variety of robotic platforms. 57 | The official definition on ROS wiki is: 58 | 59 | *ROS is an open-source, meta-operating system for your robot. It provides the services you would expect from an operating system, including hardware abstraction, low-level device control, implementation of commonly-used functionality, message-passing between processes, and package management. It also provides tools and libraries for obtaining, building, writing, and running code across multiple computers. ROS is similar in some respects to ‘robot frameworks, such as Player, YARP, Orocos, CARMEN, Orca, MOOS, and Microsoft Robotics Studio.* 60 | 61 | #### **Basics of ROS** 62 | 63 | First of all, let us start with the basics of ROS. 64 | Go through the beginner level [Tutorials](http://wiki.ros.org/ROS/Tutorials#Beginner_Level). It will cover all the basics materials like how to create a package, what is a node and how to make it, what is a publisher and a subscriber? It will give you a detailed introduction to each and every thing. There are **20** parts to this tutorial, go through them all. Don't go to the intermediate level right now if you get done with the beginner level. We will give you an assignment based on these topics. **Write code on your own. Don't copy paste it directly.** You will grasp the topics covered better when you try the implementation on your own. Assignment will be releasd soon. It's preferable if you use __Python__ instead of __C++__ as python syntax is easier and more readable and you will need it in future for sure, so, better learn it right now. These assignments will require knowledge of only basic python syntax. 65 | 66 | Here, we are briefing about what is a package and how to create a package. This is also given in the tutorials, but we are telling this explicitly because it is the most fundamental thing that you have to do when you start with ROS. 67 | 68 | ##### **What is a package?** 69 | 70 | ROS uses **packages** to organize its programs. You can think of a package as **all the files that a specific ROS program contains**; all its CPP files, python files, configuration files, compilation files, launch files, and parameter files. All those files in the package are organized with the following structure: 71 | 72 | * __launch__ folder: Contains launch files 73 | * __src folder__: Source files (CPP, python) 74 | * __CMakeLists.txt__: List of CMake rules for compilation 75 | * __package.xml__: Package information and dependencies 76 | 77 | To go to any ROS package, ROS gives you a command called `roscd`. Type: 78 | 79 | `roscd ` 80 | 81 | It will take you to the path where the package *package_name* is located. `roscd` is a command which will get you to a ROS package location. `ls`is a command that lists the content of a folder. 82 | 83 | * Every ROS program that you want to execute is organized in a package 84 | * Every ROS program that you create will have to be organized in a package 85 | * Packages are the main organizational system of ROS programs 86 | 87 | 88 | ##### **Create a package** 89 | 90 | Until now we’ve been checking the structure of an already-built package. But now, let’s create one ourselves. When we want to create packages, we need to work in a very specific ROS workspace, which is known as the catkin workspace. The **catkin workspace** is the directory in your hard disk where your own ROS packages must reside in order to be usable by ROS. Usually, the catkin workspace directory is called *catkin_ws* . 91 | 92 | Usually, the *catkin_ws* is created in the home folder of your user account. The catkin workspace has been already created and initialized for you. 93 | 94 | Go to the src folder inside *catkin_ws* : 95 | 96 | ```bash 97 | cd ~/catkin_ws /src 98 | ``` 99 | 100 | The *src* directory is the folder that holds created packages. Those could be your own packages or packages that you copied from other sources e.g. A Github Repository. 101 | 102 | In order for the ROS system to recognize the packages in your *catkin_ws*, it needs to be on the ROS file path. ROS file path is an Ubuntu environment variable that holds the paths to ROS packages. To add our *catkin_ws* to the ROS file path follow the following instructions. 103 | 104 | First, build (compile) your workspace. It’s OK to build the *catkin_ws* even if it has no packages. After the build process, some new folders will appear inside your *catkin_ws* . One of the folders, called *catkin_ws* /devel contains a setup file that will be used to add the path of the *catkin_ws* to the ROS file path. Build the *catkin_ws* using the catkin build inside the *catkin_ws* : 105 | 106 | ```bash 107 | cd ~/catkin_ws # Navigate to the catkin_ws 108 | catkin build # Build 109 | ``` 110 | Now, let’s add the *catkin_ws* path. Execute the following command while inside *catkin_ws* : 111 | 112 | ```bash 113 | source devel/setup.bash 114 | ``` 115 | This adds the *catkin_ws* path in the current terminal session but once you close the terminal window, it forgets it! So, you will have to do it again each time you open a terminal in order for ROS to recognize your workspace! Yeah, I know, that sucks! But no worries, there is a solution. You can automate the execution of the above command each time you open a terminal window. To do that, you want to add the above command to a special file called .bashrc that is located inside your home folder. 116 | 117 | ```bash 118 | cd ~ # go to the home folder 119 | nano .bashrc # open the .bashrc file 120 | ``` 121 | Add the command `source ~/catkin_ws/devel/setup.bash` to the end of *.bashrc*. 122 | Then, hit CTRL+X, then, Y, to save the changes to the file. 123 | 124 | Now, you can refer to the [tutorials](http://wiki.ros.org/ROS/Tutorials#Beginner_Level) on ROS wiki for further instructions. 125 | 126 | ### Assignment 1 127 | 128 | ___ 129 | 130 | ##### Question: 131 | Create a new package with name in the following format NAME_SURNAME. 132 | Now, this new package will require **three nodes** and **two launch files**. 133 | 134 | * The first node will publish your *NAME*(string) to the topic **name_listener** 135 | 136 | * The second node will publish your *PHONE NUMBER*(int) to the topic **num_listener** 137 | 138 | * The third node will subscribe both the above topics 139 | 140 | * The first launch file contains two nodes. It contains both of the publisher nodes. 141 | 142 | * The second launch file contains the last subscriber node. 143 | 144 | Your task is to print an assimilated string in the following format: 145 | 146 | **If you want to contact NAME, then call on this NUMBER.** 147 | 148 | NAME and NUMBER should be replaced by your own details. 149 | 150 | 151 | 152 | #### Submission details: 153 | You have to make a .zip file of your package and submit it to **erciitbombay@gmail.com**. 154 | Submissions of only registered people will be considered. 155 | **Deadline: 11:59 pm, 29/04/20** 156 | 157 | --- 158 | ## Week 2 159 | 160 | What is presented here are the main ROS concepts that are the core of ROS. These are the most important concepts that you have to master. Once you master them, the rest of ROS can follow easily. 161 | 162 | During this course, you will learn: 163 | 164 | - How **ROS Basic Structure** works. 165 | - What are **ROS Topics** and how to use them. 166 | - What are **ROS Services** and how to use them. 167 | - What are **ROS Actions** and how to use them. 168 | - How to use **ROS Debugging Tools** for finding errors in your programs (especially Rviz). 169 | 170 | Note: 171 | 172 | We will use **Python** as the programming language in all the course exercises 173 | 174 | 175 | #### Install TurtleBot packages 176 | 177 | 178 | During this tutorial, you will work with a simulated robot called **TurtleBot**, to apply the concepts of ROS. The following image is a picture of the robot you will work with. It is a differential drive robot, that has a Kinect sensor for environmental mapping, wheel encoders for position estimation. 179 | 180 | 181 | 182 | 183 | Open application called **Terminator**, you can install it by running following command in the terminal: 184 | ```bash 185 | sudo apt-get install terminator 186 | ``` 187 | 188 | It's highly recommended to use this application instead of stock Terminal. You can have tabs or split windows into few terminals. To install the required packages, execute the following command. 189 | 190 | ```bash 191 | sudo apt-get install ros-kinetic-turtlebot ros-kinetic-turtlebot-apps ros-kinetic-turtlebot-interactions ros-kinetic-turtlebot-simulator ros-kinetic-turtlebot-gazebo -y 192 | ``` 193 | 194 | Just copy and paste it in a terminal. 195 | 196 | 197 | After the installation is done, check that the simulation works in Gazebo. Execute the following command in a shell terminal. 198 | 199 | 200 | ```bash 201 | roslaunch turtlebot_gazebo turtlebot_world.launch 202 | ``` 203 | 204 | 205 | You should get something similar to the following. 206 | 207 | ![env](https://risc.readthedocs.io/_images/turtlebot-gazebo.png ) 208 | 209 | #### Move the robot 210 | 211 | 212 | How can you move the Turtlebot? 213 | 214 | The easiest way is by executing an existing ROS program to control the robot. A ROS program is executed by using some special files called **launch files**. 215 | Since a previously-made ROS program already exists that allows you to move the robot using the keyboard, let's launch that ROS program to teleoperate the robot. 216 | 217 | Execute in a separate terminal: 218 | 219 | `roslaunch turtlebot_teleop keyboard_teleop.launch` 220 | 221 | Read the instructions on the screen to know which keys to use to move the robot around, and start moving the robot! 222 | 223 | 224 | Try it! When you're done, you can CTRL+C to stop the execution of the program. 225 | 226 | 227 | #### What is a launch file ? 228 | 229 | 230 | We've seen that ROS uses launch files in order to execute programs. But... how do they work? Let's have a look. 231 | 232 | lets have a look at a launch file. Open the launch folder inside the ``turtlebot_teleop`` package and check the ``keyboard_teleop.launch`` file. 233 | 234 | ``` bash 235 | 236 | roscd turtlebot_teleop 237 | cd launch 238 | gedit keyboard_teleop.launch 239 | 240 | ``` 241 | 242 | 243 | You will see: 244 | 245 | ``` xml 246 | 247 | 248 | 249 | 250 | 251 | 252 | 253 | 254 | ``` 255 | 256 | In the launch file, you have some extra tags for setting parameters and remaps. For now, don't worry about those tags and focus on the node tag. 257 | 258 | All launch files are contained within a ```` tag. Inside that tag, you can see a ```` tag, where we specify the following parameters: 259 | 260 | - pkg="``package_name``": Name of the package that contains the code of the ROS program to execute 261 | - type="``python_file_name.py``" : Name of the program file that we want to execute 262 | - name="``node_name``" : Name of the ROS node that will launch our Python file 263 | - output="``type_of_output``" : Through which channel you will print the output of the Python file 264 | 265 | Now, lets create a package. Just a revision of your [previous](#create-a-package) tutorial. 266 | 267 | ___Remember to create ROS packages inside the ``src`` folder___ 268 | 269 | 270 | #### Create a package 271 | 272 | ```catkin_create_pkg my_package rospy``` 273 | 274 | 275 | This will create, inside our ``src``, directory a new package with some files in it. We'll check this later. Now, let's see how this command is built: 276 | 277 | ```catkin_create_pkg ``` 278 | 279 | 280 | The **package_name** is the name of the package you want to create, and the **package_dependencies** are the names of other ROS packages that your package depends on. 281 | 282 | Now, re-build your catkin_ws and source it as above. 283 | 284 | In order to check that our package has been created successfully, we can use some ROS commands related to packages. For example, let's type: 285 | 286 | ```bash 287 | rospack list 288 | rospack list | grep my_package 289 | roscd my_package 290 | ``` 291 | 292 | 293 | ``rospack list``: Gives you a list with all of the packages in your ROS system. 294 | 295 | ``rospack list | grep my_package``: Filters, from all of the packages located in the ROS system, the package named *my_package*. 296 | 297 | ``roscd my_package``: Takes you to the location in the Hard Drive of the package, named *my_package*. 298 | 299 | #### Exercise: Move the Robot 300 | 301 | Now you're ready to create your own publisher and make the robot move, so let's go for it! 302 | 303 | First, you need to bring up the robot simulation in Gazebo using the command: 304 | 305 | `roslaunch turtlebot_gazebo turtlebot_world.launch` 306 | 307 | #### Required information: 308 | 309 | * The ``cmd_vel_mux/input/teleop`` topic is the topic used to move the robot. Do a ``rostopic info cmd_vel_mux/input/teleop`` in order to get information about this topic, and identify the message it uses. You have to modify the code to use that message. 310 | 311 | * In order to fill the Twist message, you need to create an instance of the message. In Python, this is done like this: ``var = Twist()`` 312 | 313 | * In order to know the structure of the Twist messages, you need to use the ``rosmsg show`` command, with the type of the message used by the topic ``cmd_vel_mux/input/teleop``. 314 | 315 | * In this case, the robot uses a differential drive plugin to move. That is, the robot can only move linearly in the *x* axis, or rotationally in the angular *z* axis. This means that the only values that you need to fill in the Twist message are the linear *x* and the angular *z*. 316 | 317 | 318 | 319 | 320 | The magnitudes of the Twist message are in m/s, so it is recommended to use values between 0 and 1. For example, *0.5 m/s* 321 | 322 | #### What to do: 323 | 324 | Create a launch file that launches the code ``topic_publisher.py`` (basically the name of the python file stored in your src folder of your package.) 325 | 326 | Modify the code you used previously (in the previous week) to publish data to the ``cmd_vel_mux/input/teleop`` topic. 327 | 328 | Launch the program and check that the robot moves. 329 | 330 | You need the knowledge of attributes of rotopic and rosmsg like rostopic info, rostopic echo, rosmsg show. So, refer to the previous tutorial, if you have any queries with the same. 331 | 332 | *At first it may seems to be a bit harder problem but we want you to think first and explore the ROS environment. Use the required information and think about what is happening. We don't expect that you will solve it at your first go. You will get stuck in between various times. This will lead to discussion and you will get to know more as much you discuss on the group. It is a very intersting problem. You will see your bot move autonomously.* 333 | 334 | ___ 335 | 336 | __Solution to the exercise__ : 337 | 338 | ```python 339 | #! /usr/bin/env python 340 | 341 | import rospy 342 | from geometry_msgs.msg import Twist 343 | 344 | rospy.init_node('move_robot_node') 345 | pub = rospy.Publisher('cmd_vel_mux/input/teleop', Twist, queue_size=1) 346 | rate = rospy.Rate(2) 347 | move = Twist() 348 | move.linear.x = 0.5 #Move the robot with a linear velocity in the x axis 349 | move.angular.z = 0.5 #Move the with an angular velocity in the z axis 350 | 351 | while not rospy.is_shutdown(): 352 | pub.publish(move) 353 | rate.sleep() 354 | ``` 355 | ___ 356 | 357 | ### Assignment 2 358 | 359 | ___ 360 | 361 | In this assignment, you will write code to make the bot avoid walls in front of it. To help you achieve this, let’s divide the project down into smaller units: 362 | 363 | * Create a Publisher that writes into the *cmd_vel_mux/input/teleop* topic in order to move the robot. 364 | 365 | * Create a Subscriber that reads from the */scan* topic. This is the topic where the laser publishes its data. 366 | 367 | Depending on the readings you receive from the laser’s topic, you’ll have to change the data you’re sending to the *cmd_vel_mux/input/teleop* topic, in order to avoid the wall. This means, use the values of the laser to decide. 368 | 369 | 370 | ### Required Information: 371 | 372 | * The data that is published into the */scan* topic has a large structure. For this project, you just have to pay attention to the ranges array. 373 | 374 | Hint: 375 | To check the laser message type, execute the following: `rosmsg show sensor_msgs/LaserScan` 376 | 377 | * The *ranges* array has a lot of values. The ones that are in the middle of the array represent the distances that the laser is detecting right in front of it. This means that the values in the middle of the array will be the ones that detect the wall. So in order to avoid the wall, you just have to read these values. 378 | 379 | Hint: The size of the array is 639. 380 | * The laser has a range of 30m. When you get readings of values around 30, it means that the laser isn’t detecting anything. If you get a value that is under 30, this will mean that the laser is detecting some kind of obstacle in that direction (the wall). 381 | 382 | * The scope of the laser is about 180 degrees from right to left. This means that the values at the beginning and at the end of the *ranges* array will be the ones related to the readings on the sides of the laser (left and right), while the values in the middle of the array will be the ones related to the front of the laser. 383 | 384 | So, in the end you probably will get something like this: 385 | 386 | The robot moves forward until it detects an obstacle in front of it which is closer than 1 meter, so it begins to turn left in order to avoid it. 387 | 388 | 389 | ![Reuqired Output](https://risc.readthedocs.io/_images/mini_project_1.gif) 390 | 391 | The robot keeps turning left and moving forward until it detects that it has an obstacle at the right side which is closer than 1 meter, so it stops and turns left in order to avoid it. 392 | 393 | ![Reuqired Output](https://risc.readthedocs.io/_images/mini_project_2.gif) 394 | 395 | __If you are using ROS Melodic, do the following:__ 396 | People having turtlebot3 have to simualte the same task in turtlebot3_house using any of the bots: burger, waffle, waffle-pi. Use all the required information as stated above. 397 | 398 | #### Installation problem in turtlebot/turtlebot3: 399 | For **ROS kinetic** do: `sudo apt-get install ros-kinetic-turtlebot-*` 400 | 401 | For **ROS mleodic** do: `sudo apt-get install ros-melodic-turtlebot3-*` 402 | 403 | If anyone is still facing any issue, then you can ping any of us ASAP. 404 | 405 | #### Submission details: 406 | You have to make a .zip file of your package and submit it to **erciitbombay@gmail.com**. 407 | Submissions of only registered people will be considered. 408 | **Deadline: 11:59 pm, 07/05/20** 409 | 410 | 411 | ## Week 3 412 | 413 | People using ROS-kinetic do: 414 | 415 | `sudo apt-get install ros-kinetic-turtlebot3-*` 416 | 417 | Those using ROS-melodic do: 418 | 419 | `sudo apt-get install ros-melodic-turtlebot3-*` 420 | 421 | After the installation: 422 | 423 | ```bash 424 | cd ~ 425 | nano .bashrc 426 | ``` 427 | 428 | At the end of your .bashrc file add this line: 429 | 430 | ```bash 431 | export TURTLEBOT3_MODEL=waffle 432 | ``` 433 | 434 | 435 | We have mentioned waffle here. You can use waffle_pi or burger also. 436 | 437 | In the following weeks we will cover these topics: 438 | 439 | * SLAM 440 | * Navigation 441 | * Path Planning 442 | 443 | Let's start with SLAM: 444 | 445 | ### SLAM 446 | 447 | **SLAM** (Simultaneous Localization and Mapping) is a technique to draw a map by estimating current location in an arbitrary space. 448 | 449 | Now do things step-by-step in different terminals: 450 | ```bash 451 | roscore 452 | 453 | roslaunch turtlebot3_gazebo turtlebot3_world.launch 454 | 455 | roslaunch turtlebot3_slam turtlebot3_slam.launch slam_methods:=gmapping 456 | 457 | roslaunch turtlebot3_teleop turtlebot3_teleop_key.launch 458 | 459 | ``` 460 | 461 | ```bash 462 | Control Your TurtleBot3! 463 | --------------------------- 464 | Moving around: 465 | w 466 | a s d 467 | x 468 | 469 | w/x : increase/decrease linear velocity 470 | a/d : increase/decrease angular velocity 471 | space key, s : force stop 472 | 473 | CTRL-C to quit 474 | 475 | ``` 476 | 477 | > Practice mapping the environment on your own as you will require it for the assignment. 478 | 479 | 480 | Now move your bot in entire world and start mapping the world. 481 | It may take a larger time to map the whole world and your PC may also heat up a bit, but don't worry a lot about it. 482 | Sometimes your map will get distorted in between and when you see the terminal, it will show something like this: 483 | 484 | `Scan Matching Failed, using odometry. Likelihood = 0` 485 | 486 | This mostly happens when there is some issue with **tf** package. Maneuver your bot multiple times to the entire world until you get a perfect map. 487 | It requires a lot of practice to build a good map, so you may find it difficult to get a good map in first try. 488 | 489 | Once your map is built, i.e. you have mapped the entire world, then for saving this map, execute this: 490 | 491 | `rosrun map_server map_saver -f ~/map` 492 | 493 | > Remember to save your map after completing mapping, else your entire work will be of no use. 494 | 495 | For now, we are done SLAM basics 496 | 497 | ### Navigation 498 | 499 | Just as a demo of how it works, do the following after closing all the previous windows: 500 | 501 | ```bash 502 | roscore 503 | 504 | roslaunch turtlebot3_gazebo turtlebot3_world.launch 505 | 506 | roslaunch turtlebot3_gazebo turtlebot3_simulation.launch 507 | 508 | roslaunch turtlebot3_gazebo turtlebot3_gazebo_rviz.launch 509 | 510 | ``` 511 | 512 | Now a new window of RViz will popup. **RVIZ** is a ROS graphical interface that allows you to visualize a lot of information, using plugins for many kinds of available topics. 513 | 514 | Now till now, you are somewhat familiar with what all the things we are using. Now, turtlebot3 provides its own navigation example. So, first we will simulate it. Close all the terminals except roscore ;) 515 | 516 | Now, execute the followin commands: 517 | ```bash 518 | roslaunch turtlebot3_gazebo turtlebot3_world.launch 519 | 520 | roslaunch turtlebot3_navigation turtlebot3_navigation.launch map_file:=$HOME/map.yaml 521 | ``` 522 | 523 | A RViz window will popup, it may take sometime to open. Hold your breathe till that. Now, follow the given below steps. 524 | 525 | 1. Click on **2D pose estimate** loacted at the top panels and then click on any random point on the map. (The bot will move to that location fastly. It basically sets your initial position) 526 | 527 | 2. Click on **2D nav goal** loacted side of 2D pose estimate and then click on any point on the graph.(This is your goal location.) 528 | 529 | Now, you will see an arrow pointing to your goal location and the bot will start moving slowly towards it. Tha path planning algorithm which we are using here is **DWA Algorithm**. Google it, it's an interesting algorithm which will aviod both static as well as dynamic obstacles. 530 | 531 | ### Assignment 3a 532 | 533 | ___ 534 | 535 | In this assignment you are provided with a world file which we have made on gazebo. So, your task is to map the entire world and then save your map file. The gazebo world file is as follows with `.world` extension: 536 | 537 | ```xml 538 | 539 | 540 | 541 | 542 | model://sun 543 | 544 | 545 | 546 | 547 | model://ground_plane 548 | 549 | 550 | 0 0.01 0 0 -0 0 551 | 552 | 553 | 554 | 555 | 20.15 0.15 2.5 556 | 557 | 558 | 0 0 1.25 0 -0 0 559 | 560 | 561 | 0 0 1.25 0 -0 0 562 | 563 | 564 | 20.15 0.15 2.5 565 | 566 | 567 | 568 | 572 | 1 1 1 1 573 | 574 | 575 | 0 576 | 577 | 578 | 0 10.01 0 0 -0 0 579 | 580 | 581 | 582 | 583 | 584 | 20.15 0.15 2.5 585 | 586 | 587 | 0 0 1.25 0 -0 0 588 | 589 | 590 | 0 0 1.25 0 -0 0 591 | 592 | 593 | 20.15 0.15 2.5 594 | 595 | 596 | 597 | 601 | 1 1 1 1 602 | 603 | 604 | 0 605 | 606 | 607 | 10 -0.01 0 0 -0 1.5708 608 | 609 | 610 | 611 | 612 | 613 | 8.15 0.15 2.5 614 | 615 | 616 | 0 0 1.25 0 -0 0 617 | 618 | 619 | 0 0 1.25 0 -0 0 620 | 621 | 622 | 8.15 0.15 2.5 623 | 624 | 625 | 626 | 630 | 1 1 1 1 631 | 632 | 633 | 0 634 | 635 | 636 | -2 5.99 0 0 -0 -1.5708 637 | 638 | 639 | 640 | 641 | 642 | 4.15 0.15 2.5 643 | 644 | 645 | 0 0 1.25 0 -0 0 646 | 647 | 648 | 0 0 1.25 0 -0 0 649 | 650 | 651 | 4.15 0.15 2.5 652 | 653 | 654 | 655 | 659 | 1 1 1 1 660 | 661 | 662 | 0 663 | 664 | 665 | -6 7.99 0 0 -0 -1.5708 666 | 667 | 668 | 669 | 670 | 671 | 0.65 0.15 2.5 672 | 673 | 674 | 0 0 1.25 0 -0 0 675 | 676 | 677 | 0 0 1.25 0 -0 0 678 | 679 | 680 | 0.65 0.15 2.5 681 | 682 | 683 | 684 | 688 | 1 1 1 1 689 | 690 | 691 | 0 692 | 693 | 694 | -6.25 5.99 0 0 -0 3.14159 695 | 696 | 697 | 698 | 699 | 700 | 4.15 0.15 2.5 701 | 702 | 703 | 0 0 1.25 0 -0 0 704 | 705 | 706 | 0 0 1.25 0 -0 0 707 | 708 | 709 | 4.15 0.15 2.5 710 | 711 | 712 | 713 | 717 | 1 1 1 1 718 | 719 | 720 | 0 721 | 722 | 723 | -6.5 3.99 0 0 -0 -1.5708 724 | 725 | 726 | 727 | 728 | 729 | 4.65 0.15 2.5 730 | 731 | 732 | 0 0 1.25 0 -0 0 733 | 734 | 735 | 0 0 1.25 0 -0 0 736 | 737 | 738 | 4.65 0.15 2.5 739 | 740 | 741 | 742 | 746 | 1 1 1 1 747 | 748 | 749 | 0 750 | 751 | 752 | -4.25 1.99 0 0 -0 0 753 | 754 | 755 | 756 | 757 | 758 | 2.07 0.07 2.5 759 | 760 | 761 | 0 0 1.25 0 -0 0 762 | 763 | 764 | 0 0 1.25 0 -0 0 765 | 766 | 767 | 2.07 0.07 2.5 768 | 769 | 770 | 771 | 775 | 1 1 1 1 776 | 777 | 778 | 0 779 | 780 | 781 | -1 8.99 0 0 -0 -1.5708 782 | 783 | 784 | 785 | 786 | 787 | 4.65 0.15 2.5 788 | 789 | 790 | 0 0 1.25 0 -0 0 791 | 792 | 793 | 0 0 1.25 0 -0 0 794 | 795 | 796 | 4.65 0.15 2.5 797 | 798 | 799 | 800 | 804 | 1 1 1 1 805 | 806 | 807 | 0 808 | 809 | 810 | -4.25 5.99 0 0 -0 0 811 | 812 | 813 | 814 | 815 | 816 | 20.15 0.15 2.5 817 | 818 | 819 | 0 0 1.25 0 -0 0 820 | 821 | 822 | 0 0 1.25 0 -0 0 823 | 824 | 825 | 20.15 0.15 2.5 826 | 827 | 828 | 829 | 833 | 1 1 1 1 834 | 835 | 836 | 0 837 | 838 | 839 | -10 -0.01 0 0 -0 -1.5708 840 | 841 | 842 | 843 | 844 | 845 | 2.65 0.15 2.5 846 | 847 | 848 | 0 0 1.25 0 -0 0 849 | 850 | 851 | 0 0 1.25 0 -0 0 852 | 853 | 854 | 2.65 0.15 2.5 855 | 856 | 857 | 858 | 862 | 1 1 1 1 863 | 864 | 865 | 0 866 | 867 | 868 | -5.25 -2.01 0 0 -0 0 869 | 870 | 871 | 872 | 873 | 874 | 4.15 0.15 2.5 875 | 876 | 877 | 0 0 1.25 0 -0 0 878 | 879 | 880 | 0 0 1.25 0 -0 0 881 | 882 | 883 | 4.15 0.15 2.5 884 | 885 | 886 | 887 | 891 | 1 1 1 1 892 | 893 | 894 | 0 895 | 896 | 897 | -6.5 -4.01 0 0 -0 -1.5708 898 | 899 | 900 | 901 | 902 | 903 | 4.15 0.15 2.5 904 | 905 | 906 | 0 0 1.25 0 -0 0 907 | 908 | 909 | 0 0 1.25 0 -0 0 910 | 911 | 912 | 4.15 0.15 2.5 913 | 914 | 915 | 916 | 920 | 1 1 1 1 921 | 922 | 923 | 0 924 | 925 | 926 | -4 -4.01 0 0 -0 -1.5708 927 | 928 | 929 | 930 | 931 | 932 | 4.65 0.15 2.5 933 | 934 | 935 | 0 0 1.25 0 -0 0 936 | 937 | 938 | 0 0 1.25 0 -0 0 939 | 940 | 941 | 4.65 0.15 2.5 942 | 943 | 944 | 945 | 949 | 1 1 1 1 950 | 951 | 952 | 0 953 | 954 | 955 | -4.25 -6.01 0 0 -0 0 956 | 957 | 958 | 959 | 960 | 961 | 8.15 0.15 2.5 962 | 963 | 964 | 0 0 1.25 0 -0 0 965 | 966 | 967 | 0 0 1.25 0 -0 0 968 | 969 | 970 | 8.15 0.15 2.5 971 | 972 | 973 | 974 | 978 | 1 1 1 1 979 | 980 | 981 | 0 982 | 983 | 984 | -2 -6.01 0 0 -0 -1.5708 985 | 986 | 987 | 988 | 989 | 990 | 20.15 0.15 2.5 991 | 992 | 993 | 0 0 1.25 0 -0 0 994 | 995 | 996 | 0 0 1.25 0 -0 0 997 | 998 | 999 | 20.15 0.15 2.5 1000 | 1001 | 1002 | 1003 | 1007 | 1 1 1 1 1008 | 1009 | 1010 | 0 1011 | 1012 | 1013 | 0 -10.01 0 0 -0 0 1014 | 1015 | 1 1016 | 1017 | 1018 | 1019 | 1020 | ``` 1021 | 1022 | You don't have to worry about how this world is file made right now. Just copy-paste this entire code. 1023 | 1024 | Now, step-by-step procedure of how to proceed: 1025 | 1026 | * Create a package and build it 1027 | * Make a directory in your package directory, name it as worlds, and then make a file in it and copy paste the entire code. 1028 | * Now, next step is to make a launch directory in your package directory and make two launch files there. 1029 | * Give any name to one file, eg. `model.launch` and copy paste the code given below in it and change the name of your package and name of world file in the line: 1030 | ``` 1031 | 1032 | ``` 1033 | Ask on the group if you find this confusing. 1034 | 1035 | ```bash 1036 | 1037 | 1038 | 1039 | 1040 | 1041 | 1042 | 1043 | 1044 | 1045 | 1046 | 1047 | 1048 | 1049 | 1050 | 1051 | 1052 | 1053 | 1054 | 1055 | 1056 | ``` 1057 | Now, if you do 1058 | ``` 1059 | roslaunch package_name model.launch 1060 | ``` 1061 | then, a gazebo world will open up and you will see your bot sitting in the middle of your world. It may take some time. 1062 | 1063 | * Now, go to the insert section, top left in your gazebo screen, and insert the obstacles in the environment. Insert a large number of obstacles typically, 8-10. 1064 | * Now, next step is to do SLAM in this world. For this, make a another file in your launch file and name it as, let's say `slam.launch` 1065 | * Now, 1066 | ``` 1067 | gedit slam.launch 1068 | ``` 1069 | and copy paste the entire code: 1070 | 1071 | ```bash 1072 | 1073 | 1074 | 1075 | 1076 | 1077 | 1078 | 1079 | 1080 | 1081 | 1082 | 1083 | 1084 | 1085 | 1086 | 1087 | 1088 | 1089 | 1090 | 1091 | 1092 | 1094 | 1095 | 1096 | ``` 1097 | 1098 | * Now, open a separate terminal do: 1099 | ```bash 1100 | roslaunch package_name slam.launch 1101 | ``` 1102 | * A RViz window will pop up and you will see your bot and some grey patches around it. 1103 | * Now, in a separate terminal do: 1104 | ``` 1105 | roslaunch turtlebot3_teleop turtlebot3_teleop_key.launch 1106 | ``` 1107 | 1108 | * Now, you have to map the entire world. You may not get an accurate map but try your best to have some rough map and save it using the command: 1109 | ``` 1110 | rosrun map_server map_saver -f ~/map 1111 | ``` 1112 | * When you open your home directory in files menu, you will see your map. There will be one `.pgm` file and another `.yaml` 1113 | 1114 | So, upto now, you have your own map of the environment and ready to do navigation in it. 1115 | 1116 | 1117 | ### Assignment 3b 1118 | 1119 | In this tutorial, we will do navigation in the map that we have done in week 3(A) assignment. 1120 | 1121 | Before proceeding on to it directly, let's first move autonomously in a given map file. So, in the same directory as the previous one, make a launch file and name it as let's say `navigation.launch` 1122 | 1123 | Now, do 1124 | ``` 1125 | gedit navigation.launch 1126 | ``` 1127 | Copy paste the given below code in it: 1128 | ```bash 1129 | 1130 | 1131 | 1132 | 1133 | 1134 | 1135 | 1136 | 1137 | 1138 | 1139 | 1140 | 1141 | 1142 | 1143 | 1144 | 1145 | 1146 | 1147 | 1148 | 1149 | 1150 | 1151 | 1152 | 1153 | 1154 | 1155 | 1157 | 1158 | 1159 | ``` 1160 | 1161 | Now, do the following things step by step: 1162 | 1163 | * ```roscore``` 1164 | * ```roslaunch turtlebot3_gazebo turtlebot3_world.launch ``` 1165 | * ```roslaunch turtlebot3_navigation turtlebot3_navigation.launch ``` 1166 | 1167 | A RViz window will pop up after sometime. Now, do the following things: 1168 | * Select **2-D pose estimate** and click on any point in the map. The robot will move to this point autonomously. This will set the initial location of the robot. 1169 | * Next step is to select **2-D nav goal** and click on any point in the map. This point will be our final position. 1170 | 1171 | Now, you will see that robot will move to this point by using DWA path planning algorithm. For more details about DWA algorithm refer this: 1172 | [DWA algorithm ](https://ieeexplore.ieee.org/document/8833259/) 1173 | 1174 | Play with the things in the left panel, you will get to know that how the things are working in RViz. 1175 | 1176 | Now, the final step is to move to our robot in the map that we have build. 1177 | 1178 | Make a directory named as maps in your package and copy paste the `.pgm` and `.yaml` files that you have made using assignment 3(A). Let's say the name of your `.pgm` file is **my_first_map.pgm** and name of your `.yaml` is **my_map.yaml** 1179 | 1180 | Next step is to modify the **my_map.yaml** file. 1181 | Do, 1182 | ```bash 1183 | gedit my_map.yaml 1184 | ``` 1185 | You have to change the first line of this to 1186 | ```bash 1187 | image: ./my_first_map.pgm 1188 | ``` 1189 | Next we have to move our robot in our map. 1190 | 1191 | 1192 | For this do the following changes in your `navigation.launch` file 1193 | ```bash 1194 | 1195 | ``` 1196 | 1197 | Now all the task has been done. Follow the same steps as described above to make your robot autonomously in your own environment. 1198 | 1199 | ### Submission details: 1200 | Since this task 2 doesn't require much of your time, you have to submit complete assignment 3 by **11:59 pm, 25/05/2020**. You have to send your package and video recording of your screen while the robot is moving in your own map. 1201 | Send it as zip file on **erciitbombay@gmail.com** 1202 | 1203 | ## Week 4 1204 | 1205 | This is the last week of this ROS tutorial session and in this week, we will be focusing on building a custom bot. At the end of this exercise you will be able to make a robot and launch it in gazebo and simulate in the environment. 1206 | 1207 | Please refer to the link given below: 1208 | 1209 | [Custom bot development from scratch](https://www.theconstructsim.com/ros-projects-exploring-ros-using-2-wheeled-robot-part-1/#part10) 1210 | 1211 | You **don't** need to do this on **Robot Development Studio**. Just follow the same steps as given in the link. This will resolve all your doubts that you were asking in week 3 content about what is **URDF** file and **.sdf** file! Feel free to post doubts in the group. 1212 | 1213 | There will be no assignment in this week. The part 2 of Week 3 assignment will be uploaded shortly. For time being, complete this. 1214 | --------------------------------------------------------------------------------