|
1 |
| -# assignment-1 |
| 1 | +# Assignment 1 |
| 2 | + |
| 3 | +The goal in this assignment is to explore concepts of perception in a robotic system to accomplish a task. Given a mobile robot with a set of sensors in a partially known environment, objects/obstacles must be detected and counted. In addition, the robot must be started in a random position and not rely on any teleoperated commands. |
| 4 | + |
| 5 | +## Methodology |
| 6 | + |
| 7 | +The task to be solved here has been divided into several other tasks that together are the complete assignment resolution. |
| 8 | + |
| 9 | +### Random start |
| 10 | + |
| 11 | +To be able to initialize the robot in a random position, the [`worlds_gazebo`](https://github.com/autonomous-robots/worlds_gazebo) repository was built. When launching, one of the worlds will be randomly chosen as well as the position of the robot. The [python-sdformat](https://pypi.org/project/python-sdformat/0.1.0/) library is used to read the [SDFormat XML](http://sdformat.org/) file. Thus, the position of the cylinders is collected and a check is made to ensure that the robot never starts in a place already occupied by an obstacle. |
| 12 | + |
| 13 | +### Environment exploration |
| 14 | + |
| 15 | +Exploration is done using just a simple controller `turtlebot3_explorer` based on the [`turtlebot3_examples`](https://github.com/ROBOTIS-GIT/turtlebot3/tree/humble-devel) package. This ROS2 node subscribes to receive messages from the laser sensor and publishes velocity commands. If any obstacle is detected in front of the robot, it then rotates until it finds a free path again. Also has a service that allows to enable or disable this behavior. |
| 16 | + |
| 17 | +<p align="center"> |
| 18 | + <img src="etc/images/turtlebot3_explorer.png" alt="turtlebot3_explorer" width="400"/> |
| 19 | +</p> |
| 20 | + |
| 21 | +### Occupancy grid |
| 22 | + |
| 23 | +The entire solution proposed here for counting obstacles is based on the use of an occupancy grid map. To generate this map, it was developed a ROS2 node that subscribes to receive messages from the laser sensor and updates the occupancy grid map for each message received. Initially, all points on the occupancy map have probability equal to 50%. As messages are received from the laser sensor, occupied points will have probability above 50% and free points on the map will have probability below 50%. This probabilistic occupancy grid is published at a fixed rate in the `/custom_map` topic. |
| 24 | + |
| 25 | + |
| 26 | +<p align="center"> |
| 27 | + <img src="etc/images/turtlebot3_occupancy_grid.png" alt="turtlebot3_occupancy_grid" width="400"/> |
| 28 | +</p> |
| 29 | + |
| 30 | + |
| 31 | +The occupancy grid mapping algorithm ses the log-odds representation of occupancy: |
| 32 | + |
| 33 | +$$l_{t,i} = log(\frac{p(m_i|z_{1:t},x_{1:t})}{1 - p(m_i|z_{1:t},x_{1:t})})$$ |
| 34 | + |
| 35 | +The probabilities are easily recovered from the log-odds ratio: |
| 36 | + |
| 37 | +$$p(m_i|z_{1:t},x_{1:t}) = 1 - \frac{1}{1+ exp(l_{t,i})}$$ |
| 38 | + |
| 39 | +The algorithm occupancy grid mapping in below loops through all grid cells $i$, and updates those that were measured. The function `inverse_sensor_model` implements the inverse measurement model $p(m_i|z_{1:t},x_{1:t})$ in its log-odds form: if it measured any smaller than the maximum laser range, then mark the points on the map that are under the laser beam as free and the last one as occupied; if it measured some infinite value, truncated to max laser range and marks all as free grid cells. |
| 40 | + |
| 41 | +<p align="center"> |
| 42 | + <img src="etc/images/occupancy_grid_algo.png" alt="occupancy_grid" width="400"/> |
| 43 | +</p> |
| 44 | + |
| 45 | +### Detect obstacles/objects |
| 46 | + |
| 47 | +<p align="center"> |
| 48 | + <img src="etc/images/turtlebot3_object_detector.png" alt="turtlebot3_object_detector" width="400"/> |
| 49 | +</p> |
| 50 | + |
| 51 | +### Exploration end |
| 52 | + |
| 53 | +<p align="center"> |
| 54 | + <img src="etc/images/turtlebot3_mission_controller.png" alt="turtlebot3_mission_controller" width="400"/> |
| 55 | +</p> |
| 56 | + |
| 57 | + |
| 58 | + |
| 59 | +## Building |
| 60 | + |
| 61 | +```bash |
| 62 | +docker build -t assignment-1 -f etc/docker/Dockerfile . |
| 63 | +``` |
| 64 | + |
| 65 | +## Runnning |
| 66 | + |
| 67 | +```bash |
| 68 | +sudo xhost +local:root |
| 69 | +``` |
| 70 | + |
| 71 | +```bash |
| 72 | +docker network create my-net |
| 73 | +``` |
| 74 | + |
| 75 | +```bash |
| 76 | +docker run -it -e DISPLAY=$DISPLAY -v /tmp/.X11-unix:/tmp/.X11-unix:rw --device /dev/dri/ --net=my-net assignment-1 /bin/bash |
| 77 | +``` |
| 78 | + |
| 79 | +```bash |
| 80 | +docker run -it --net=my-net assignment-1 /bin/bash |
| 81 | +``` |
0 commit comments