From 7ad2a21731f666ea1023c91aed1c8ca4d24f11e0 Mon Sep 17 00:00:00 2001 From: Adrimapo Date: Fri, 29 Nov 2024 17:00:52 +0100 Subject: [PATCH] Docker additions and code corrections --- Dockerfile | 17 +++++++++++++++++ HOWTODOCKER | 6 +++--- README.md | 4 ++++ drone_behaviors/src/dataset/data.py | 2 +- drone_behaviors/src/dataset/droneExpertPilot.py | 2 +- .../src/dataset/image_filter_node.py | 2 +- drone_behaviors/src/dataset/remoteControl.py | 2 +- drone_behaviors/src/models/droneNeuralPilot.py | 2 +- drone_behaviors/src/models/oldTrain.py | 2 +- drone_behaviors/src/models/train.py | 2 +- .../src/visualization/datasetGraphic.py | 2 +- .../visualization/datasetGraphicDeepPilot.py | 2 +- 12 files changed, 33 insertions(+), 12 deletions(-) diff --git a/Dockerfile b/Dockerfile index c0515f9..a3993c2 100644 --- a/Dockerfile +++ b/Dockerfile @@ -138,4 +138,21 @@ RUN echo "source /root/ws/install/setup.bash" >> ~/.bashrc COPY ./entrypoint.bash / ENTRYPOINT [ "/entrypoint.bash" ] + +# Additional configuration +RUN chmod 1777 /tmp +RUN git clone https://github.com/PX4/PX4-Autopilot.git /root/ws/src/px4/PX4-Autopilot +WORKDIR /root/ws/src/px4/PX4-Autopilot +RUN git submodule update --init --recursive +RUN make px4_sitl +RUN chmod +x /root/ws/install/as2_gazebo_classic_assets/share/as2_gazebo_classic_assets/scripts/run_sitl.sh +RUN chmod +x /root/ws/install/as2_gazebo_classic_assets/share/as2_gazebo_classic_assets/scripts/default_run.sh +RUN apt update && apt install -y dbus-x11 libcanberra-gtk-module libcanberra-gtk3-module +RUN apt update && apt install -y alsa-utils +RUN chmod -R +x /root/ws/install/as2_gazebo_classic_assets/share/as2_gazebo_classic_assets/scripts/ +RUN apt update && apt install -y alsa-utils pulseaudio +RUN chown root:root /root/ws/install/as2_gazebo_classic_assets/share/as2_gazebo_classic_assets/scripts/default_run.sh +RUN chmod +x /root/ws/install/as2_gazebo_classic_assets/share/as2_gazebo_classic_assets/scripts/default_run.sh + + CMD [ "/bin/bash" ] diff --git a/HOWTODOCKER b/HOWTODOCKER index 71c99c5..98350ae 100644 --- a/HOWTODOCKER +++ b/HOWTODOCKER @@ -1,7 +1,7 @@ # HOWTODOCKER # Build and run (using docker-compose) -``` +```bash xhost + docker compose up -d # use the -d for keep the container alive in background docker exec -it imitation_learning /bin/bash @@ -28,13 +28,13 @@ make px4_sitl gazebo-classic --- -``` +```bash chmod +x $AS2_GZ_ASSETS_SCRIPT_PATH/default_run.sh $AS2_GZ_ASSETS_SCRIPT_PATH/run_sitl.sh $AS2_GZ_ASSETS_SCRIPT_PATH/parse_json.py $AS2_GZ_ASSETS_SCRIPT_PATH/jinja_gen.py cd /root/ws/src/2023-tfg-adrian-madinabeitia/drone_platforms $AS2_GZ_ASSETS_SCRIPT_PATH/default_run.sh config/world.json ``` -``` +```bash cd /root/ws/src/2023-tfg-adrian-madinabeitia/drone_platforms tmuxinator start -n drone0 -p config/tmuxLaunch.yml drone_namespace=drone0 simulation_time=true config_path=config/ ``` \ No newline at end of file diff --git a/README.md b/README.md index 82ee5f3..6184999 100644 --- a/README.md +++ b/README.md @@ -56,6 +56,10 @@ We used de [aerostack2](https://github.com/aerostack2/aerostack2) platforms to u ```bash cd /PATH_TO_PACKAGE/drone_platforms/launch +# Launch default circuit +ros2 launch drone_platforms as2_sim_circuit.launch.py + +# Launching with arguments ros2 launch drone_platforms as2_sim_circuit.launch.py world:=/PATH_TO_WORLD/NAME.world yaw:=3.14 ``` diff --git a/drone_behaviors/src/dataset/data.py b/drone_behaviors/src/dataset/data.py index 6b622cc..b3b8136 100755 --- a/drone_behaviors/src/dataset/data.py +++ b/drone_behaviors/src/dataset/data.py @@ -6,7 +6,7 @@ import albumentations as A import numpy as np import random -from torch.utils.data import Dataset +from torch.utils.data import Datasetf import torchvision.transforms.functional as F import os from PIL import Image diff --git a/drone_behaviors/src/dataset/droneExpertPilot.py b/drone_behaviors/src/dataset/droneExpertPilot.py index a356783..0325783 100755 --- a/drone_behaviors/src/dataset/droneExpertPilot.py +++ b/drone_behaviors/src/dataset/droneExpertPilot.py @@ -16,7 +16,7 @@ import argparse import ament_index_python -package_path = ament_index_python.get_package_share_directory("drone_sim_driver") +package_path = ament_index_python.get_package_share_directory("drone_behaviors") sys.path.append(package_path) from src.control_functions import PID, band_midpoint, search_top_line, search_bottom_line, save_timestamps, save_profiling, search_farthest_column diff --git a/drone_behaviors/src/dataset/image_filter_node.py b/drone_behaviors/src/dataset/image_filter_node.py index ada8b51..37ecb66 100755 --- a/drone_behaviors/src/dataset/image_filter_node.py +++ b/drone_behaviors/src/dataset/image_filter_node.py @@ -16,7 +16,7 @@ import os # Package includes -package_path = ament_index_python.get_package_share_directory("drone_sim_driver") +package_path = ament_index_python.get_package_share_directory("drone_behaviors") sys.path.append(package_path) from src.control_functions import band_midpoint, search_top_line, search_bottom_line, save_profiling, search_farthest_column diff --git a/drone_behaviors/src/dataset/remoteControl.py b/drone_behaviors/src/dataset/remoteControl.py index 441359b..c9d3f68 100755 --- a/drone_behaviors/src/dataset/remoteControl.py +++ b/drone_behaviors/src/dataset/remoteControl.py @@ -25,7 +25,7 @@ import ament_index_python -package_path = ament_index_python.get_package_share_directory("drone_sim_driver") +package_path = ament_index_python.get_package_share_directory("drone_behaviors") sys.path.append(package_path) from src.control_functions import save_timestamps, save_profiling, PID diff --git a/drone_behaviors/src/models/droneNeuralPilot.py b/drone_behaviors/src/models/droneNeuralPilot.py index 1878ac2..e86ac42 100755 --- a/drone_behaviors/src/models/droneNeuralPilot.py +++ b/drone_behaviors/src/models/droneNeuralPilot.py @@ -18,7 +18,7 @@ from geometry_msgs.msg import Point # Package includes -package_path = ament_index_python.get_package_share_directory("drone_sim_driver") +package_path = ament_index_python.get_package_share_directory("drone_behaviors") sys.path.append(package_path) from src.control_functions import PID, save_timestamps, save_profiling diff --git a/drone_behaviors/src/models/oldTrain.py b/drone_behaviors/src/models/oldTrain.py index 682a415..8cbe495 100755 --- a/drone_behaviors/src/models/oldTrain.py +++ b/drone_behaviors/src/models/oldTrain.py @@ -11,7 +11,7 @@ import ament_index_python # Package includes -package_path = ament_index_python.get_package_share_directory("drone_sim_driver") +package_path = ament_index_python.get_package_share_directory("drone_behaviors") sys.path.append(package_path) from src.dataset.oldData import rosbagDataset diff --git a/drone_behaviors/src/models/train.py b/drone_behaviors/src/models/train.py index 73b37b1..958b55d 100755 --- a/drone_behaviors/src/models/train.py +++ b/drone_behaviors/src/models/train.py @@ -11,7 +11,7 @@ import ament_index_python # Package includes -package_path = ament_index_python.get_package_share_directory("drone_sim_driver") +package_path = ament_index_python.get_package_share_directory("drone_behaviors") sys.path.append(package_path) from src.dataset.data import rosbagDataset diff --git a/drone_behaviors/src/visualization/datasetGraphic.py b/drone_behaviors/src/visualization/datasetGraphic.py index c97d39d..aec95de 100644 --- a/drone_behaviors/src/visualization/datasetGraphic.py +++ b/drone_behaviors/src/visualization/datasetGraphic.py @@ -5,7 +5,7 @@ from ament_index_python.packages import get_package_share_directory import argparse -package_path = get_package_share_directory("drone_sim_driver") +package_path = get_package_share_directory("drone_behaviors") sys.path.append(package_path) from src.dataset.oldData import rosbagDataset, ANGULAR_UMBRALS, LINEAR_UMBRALS diff --git a/drone_behaviors/src/visualization/datasetGraphicDeepPilot.py b/drone_behaviors/src/visualization/datasetGraphicDeepPilot.py index 898c292..65dd25a 100644 --- a/drone_behaviors/src/visualization/datasetGraphicDeepPilot.py +++ b/drone_behaviors/src/visualization/datasetGraphicDeepPilot.py @@ -6,7 +6,7 @@ from ament_index_python.packages import get_package_share_directory import argparse -package_path = get_package_share_directory("drone_sim_driver") +package_path = get_package_share_directory("drone_behaviors") sys.path.append(package_path) from src.dataset.data import rosbagDataset, ALL_UMBRALS, velsDict