Skip to content

Commit

Permalink
Restructured repo
Browse files Browse the repository at this point in the history
  • Loading branch information
Adrimapo committed Apr 9, 2024
1 parent b3ffaa7 commit b74c748
Show file tree
Hide file tree
Showing 100 changed files with 2,355 additions and 45 deletions.
15 changes: 7 additions & 8 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
src/drone_driver/test_dataset
src/drone_driver/training_dataset
src/drone_driver/prueba
src/drone_driver/src/car
src/drone_driver/profiling
src/drone_driver/utils/*.tar
src/drone_driver/src/plotFunctions/positionRecords
src/drone_driver/networks
drone_sim_driver/data
drone_sim_driver/models
drone_sim_driver/results

tello_driver/data
tello_driver/models
tello_driver/results
28 changes: 20 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,20 +1,32 @@
# 2023-tfg-adrian-madinabeitia

<div align="center">
<img width=100px src="https://img.shields.io/badge/lenguage-%20python-blue" alt="Python">
<img width=100px src="https://img.shields.io/badge/status-in%20process-orange" alt="In process">
</div>

## Index

- [2023-tfg-adrian-madinabeitia](#2023-tfg-adrian-madinabeitia)
- [Index](#index)
- [Folder distribution](#folder-distribution)
- [Manual](#manual)
- [Automation scripts](#automation-scripts)
- [Dataset generator](#dataset-generator)
- [Training script](#training-script)

---
---

<!-- ## Installation
Versions
Ros Humble
Gazebo 11.10.2 -->
## Folder distribution
We follow the following [repository distribution](https://medium.com/analytics-vidhya/folder-structure-for-machine-learning-projects-a7e451a8caaa) for machine learning projects, along with the basic ROS structure.

The **drone_sim_driver** contains nodes and scripts related to the training and usage of the neural network for a simulated environment, while **tello_driver** contains the nodes for the DJI Tello drone.

<!-- Tmux installation -->
---
---

<!-- ---
--- -->
## Manually
## Manual

1. For launch only the world

Expand Down
78 changes: 78 additions & 0 deletions docs/_posts/2024-03-20-Semana-20.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
---
title: "Semana 20 - Piloto remoto"
categories:
- Registro Semanal
tags:
- ROS2
- Aprendizaje Automático
---

## Índice

---

Durante esta semana se desarrolló un piloto remoto para poder controlar adecuadamente el drone.

## Preparación de drivers para mando de ps4

1. Se instaló el driver para el mando:

```bash
sudo apt install ds4drv
```

2. Se conectó el mando al ordenador siguiente la siguiente [página](https://ros-developer.com/2017/12/14/ps4-controller-bluetooth-ubuntu/).

3. Clonamos el siguiente [repositorio](https://github.com/naoki-mizuno/ds4_driver)

4. Desarrollo del controlador para la teleoperación.

---

## Distribución de los botones del mando

<figure class="align-center" style="width:60%">
<img src="{{ site.url }}{{ site.baseurl }}/assets/images/post20/controller.png" alt="">
<figcaption>Controles</figcaption>
</figure>

---

## Controlador

Para programar el piloto remoto se aprovechó la facilidad de aerostack2 para intercambiar entre mundo real y mundo simulado y se desarrolló este mismo en simulación. Permitiendo desarrollar el programa mas agilmente además de poder visualizar y controlar situaciones que podrían haber puesto en peligro al drone real añadiendo mas robustez y seguridad al programa.

Adiccionalmente se añadió la posibilidad de grabar y detener grabaciones de rosbags desde el mando para facilitar el control del dataset.

## Filtros

Al ver que el filtro de paso bajo daba buenos resultados se investigaron mas tipos de filtros para poder añadir una mayor robustez al sistema:

1. **Filtro de paso bajo:** Permite el paso de frecuencias por debajo de cierto punto de corte mientras atenúa las frecuencias más altas
2. **Filtro de paso Alto:** Permite el paso de frecuencias por encima de cierto punto de corte mientras atenúa las frecuencias mas bajas
3. **Filtro de paso de Banda:** Permite el paso de frecuencias dentro de un rango específico.
4. **Filtro de rechazo de banda:** Atenua las frecuencias dentro de un rango específico mientras permite el paso de frecuencias fuera de ese rango
5. **Filtro Noch:** Suprime una frecuencia específica o un rango de frecuencias dejando pasar las que están por encima o por debajo
6. **Filtro de Retaso de grupo constante:** Asegura que todas las componentes de frecuencia de una señal se retrasen por el mismo tiempo.

## Drone real

Ya que el código en simulación se hizo con aerostack2 se trató de seguir con este middleware. Aprovechando el cambio de plataforma se puede manejar el mismo script en distintos drones. Sin embargo al usar la plataforma surgió un fallo el cual queda reflejado en el siguiente [issue](https://github.com/aerostack2/aerostack2/issues/447).


## Estandarización

Otro aspecto importante es la estandarización del repositorio para que sea adecuadamente reutilizable. En el siguiente [medium](https://medium.com/analytics-vidhya/folder-structure-for-machine-learning-projects-a7e451a8caaa) se muestra esta misma estructura.

<figure class="align-center" style="width:60%">
<img src="{{ site.url }}{{ site.baseurl }}/assets/images/post20/controller.png" alt="">
<figcaption>Estructura</figcaption>
</figure>

Dejando las siguientes mejoras a realizar en el repositorio:

- [ ] References folder
- [ ] Reports folder
- [ ] requirements.txt
- [ ] setup.py
- [ ] Licencia
Binary file added docs/assets/images/post20/controller.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/assets/images/post20/repoEstructure.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
cmake_minimum_required(VERSION 3.8)
project(drone_driver)
project(drone_sim_driver)

if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")
add_compile_options(-Wall -Wextra -Wpedantic)
Expand Down Expand Up @@ -38,23 +38,23 @@ install(
)

install(
PROGRAMS src/droneExpertPilot.py
PROGRAMS src/dataset/droneExpertPilot.py
DESTINATION lib/${PROJECT_NAME}
)

install(
PROGRAMS src/droneNeuralPilot.py
PROGRAMS src/models/droneNeuralPilot.py
DESTINATION lib/${PROJECT_NAME}
)

install(
PROGRAMS src/image_filter_node.py
PROGRAMS src/dataset/image_filter_node.py
DESTINATION lib/${PROJECT_NAME}
)

## Install world and launch files
install(
DIRECTORY launch worlds config models utils include
DIRECTORY launch worlds config sim_assets utils include
DESTINATION share/${PROJECT_NAME}
)

Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ def exit_process_function(_launch_context, route, ns):
subprocess.run(["bash", route, ns], check=True)

def generate_launch_description():
sim_config = os.path.join(get_package_share_directory('drone_driver'), 'config')
utils_path = os.path.join(get_package_share_directory('drone_driver'), 'utils')
sim_config = os.path.join(get_package_share_directory('drone_sim_driver'), 'config')
utils_path = os.path.join(get_package_share_directory('drone_sim_driver'), 'utils')

world = DeclareLaunchArgument(
'world',
Expand Down Expand Up @@ -61,16 +61,16 @@ def generate_launch_description():

tmuxAttach = ExecuteProcess(
# Aerostack2 terminal
# cmd=['gnome-terminal', '--', 'tmux', 'attach-session', '-t', namespace],
cmd=['gnome-terminal', '--', 'tmux', 'attach-session', '-t', namespace],

# No additional window
cmd=['tmux', 'attach-session', '-t', namespace],
#cmd=['tmux', 'attach-session', '-t', namespace],
name="attach",
)


parseYaml = Node(
package='drone_driver',
package='drone_sim_driver',
executable='parseWorld.py',
output='screen',
arguments=[
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@
world = "/ocean.world"

def generate_launch_description():
sim_config = os.path.join(get_package_share_directory('drone_driver'), 'config')
worlds_dir = os.path.join(get_package_share_directory('drone_driver'), 'worlds')
tmux_yml = os.path.join(get_package_share_directory('drone_driver'), 'config/tmuxLaunch.yml')
sim_config = os.path.join(get_package_share_directory('drone_sim_driver'), 'config')
worlds_dir = os.path.join(get_package_share_directory('drone_sim_driver'), 'worlds')
tmux_yml = os.path.join(get_package_share_directory('drone_sim_driver'), 'config/tmuxLaunch.yml')

# Px4 autopilot gazebo launch
gazeboPx4 = ExecuteProcess(
Expand Down Expand Up @@ -40,7 +40,7 @@ def generate_launch_description():


parseYaml = Node(
package='drone_driver',
package='drone_sim_driver',
executable='parseWorld.py',
output='screen',
arguments=[
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
def generate_launch_description():

filterImage = Node(
package='drone_driver',
package='drone_sim_driver',
executable='image_filter_node.py',
arguments=[
'--output_directory', LaunchConfiguration('out_dir'),
Expand All @@ -33,7 +33,7 @@ def generate_launch_description():
)

control = Node(
package='drone_driver',
package='drone_sim_driver',
executable='droneExpertPilot.py',
output='screen',
arguments=[
Expand Down
56 changes: 56 additions & 0 deletions drone_sim_driver/launch/neuralPilot.launch.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
from launch import LaunchDescription
from launch_ros.actions import Node
from launch.substitutions import LaunchConfiguration
from launch.actions import DeclareLaunchArgument

namespace= "drone0"

env_vars = {
'AEROSTACK2_SIMULATION_DRONE_ID': namespace
}

def generate_launch_description():

# Arguments
out_dir = DeclareLaunchArgument(
'out_dir',
default_value="."
)

trace_arg = DeclareLaunchArgument(
'trace',
default_value="false",
description="Enable trace"
)

network_path = DeclareLaunchArgument(
'network_path',
default_value="."
)

filterImage = Node(
package='drone_sim_driver',
executable='image_filter_node.py',
arguments=[
'--output_directory', LaunchConfiguration('out_dir'),
'--trace', LaunchConfiguration('trace')
],
)

control = Node(
package='drone_sim_driver',
executable='droneNeuralPilot.py',
output='screen',
arguments=[
'--output_directory', LaunchConfiguration('out_dir'),
'--network_directory', LaunchConfiguration('network_path')
],
)

return LaunchDescription([
out_dir,
trace_arg,
network_path,
filterImage,
control,
])
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0"?>
<?xml-model href="http://download.ros.org/schema/package_format3.xsd" schematypens="http://www.w3.org/2001/XMLSchema"?>
<package format="3">
<name>drone_driver</name>
<name>drone_sim_driver</name>
<version>1.0.0</version>
<description>TODO: Driver package for drone Tello </description>
<maintainer email="[email protected]">adrian</maintainer>
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
import argparse

import ament_index_python
package_path = ament_index_python.get_package_share_directory("drone_driver")
package_path = ament_index_python.get_package_share_directory("drone_sim_driver")
sys.path.append(package_path)

from include.control_functions import PID, band_midpoint, search_top_line, search_bottom_line, save_timestamps, save_profiling, search_farthest_column
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
import os

# Package includes
package_path = ament_index_python.get_package_share_directory("drone_driver")
package_path = ament_index_python.get_package_share_directory("drone_sim_driver")
sys.path.append(package_path)

from include.control_functions import band_midpoint, search_top_line, search_bottom_line, save_profiling, search_farthest_column
Expand Down
Loading

0 comments on commit b74c748

Please sign in to comment.