Skip to content

Commit

Permalink
Come back to deadline code
Browse files Browse the repository at this point in the history
  • Loading branch information
Adrimapo committed Dec 2, 2024
1 parent 7ad2a21 commit 88cce9b
Show file tree
Hide file tree
Showing 92 changed files with 101 additions and 121 deletions.
3 changes: 2 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ RUN git clone https://github.com/eProsima/Micro-XRCE-DDS-Agent.git --branch v2.4
RUN git clone https://github.com/PX4/px4_msgs.git src/px4/px4_msgs -b release/1.14

RUN git clone https://github.com/aerostack2/aerostack2.git -b 1.0.9 src/aerostack2
RUN git clone https://github.com/pariaspe/2023-tfg-adrian-madinabeitia.git src/2023-tfg-adrian-madinabeitia
RUN git clone https://github.com/RoboticsLabURJC/2023-tfg-adrian-madinabeitia src/2023-tfg-adrian-madinabeitia
RUN apt update && rosdep update && rosdep install --from-paths src --ignore-src -r -y

RUN /bin/bash -c "source /opt/ros/$ROS_DISTRO/setup.bash && colcon build"
Expand Down Expand Up @@ -154,5 +154,6 @@ 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

WORKDIR /root/ws/src/2023-tfg-adrian-madinabeitia/drone_platforms/src

CMD [ "/bin/bash" ]
31 changes: 0 additions & 31 deletions drone_behaviors/utils/clean_folder.bash

This file was deleted.

4 changes: 0 additions & 4 deletions drone_platforms/utils/end_tmux.sh

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
cmake_minimum_required(VERSION 3.8)
project(drone_behaviors)
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 @@ -32,6 +32,10 @@ include_directories(
## Install Python scripts


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

install(
PROGRAMS src/dataset/droneExpertPilot.py
Expand Down Expand Up @@ -70,7 +74,7 @@ install(

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

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 @@ -6,21 +6,19 @@
from launch.substitutions import LaunchConfiguration
from launch_ros.actions import Node

namespace = "drone0"
namespace= "drone0"
sim_time = "true"

env_vars = {
'AEROSTACK2_SIMULATION_DRONE_ID': namespace
}


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_platforms'), 'config')
utils_path = os.path.join(get_package_share_directory('drone_platforms'), '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 All @@ -47,13 +45,13 @@ def generate_launch_description():
args=[utils_path + '/end_tmux.sh', namespace]
),
LogInfo(msg='Tmux session closed')
]
]
)

# Prepares the tmux session
tmuxLauncher = ExecuteProcess(
cmd=['tmuxinator', 'start', '-n', namespace, '-p', sim_config + '/tmuxLaunch.yml',
"drone_namespace=" + namespace,
cmd=['tmuxinator', 'start', '-n', namespace, '-p', sim_config + '/tmuxLaunch.yml',
"drone_namespace=" + namespace,
"simulation_time=" + sim_time,
"config_path=" + sim_config],

Expand All @@ -66,26 +64,27 @@ def generate_launch_description():
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_platforms',
package='drone_sim_driver',
executable='parseWorld.py',
output='screen',
arguments=[
sim_config + '/world.json',
LaunchConfiguration('world'),
'0.0', '0.0', '0.0', LaunchConfiguration('yaw') # 3.14 # 3.54
'0.0', '0.0', '0.0', LaunchConfiguration('yaw') #3.14 # 3.54
],
)
)

return LaunchDescription([
world,
yaw,
parseYaml,
gazeboPx4,
tmuxLauncher,
# tmuxAttach,
])
tmuxAttach,
])
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_platforms'), 'config')
utils_path = os.path.join(get_package_share_directory('drone_platforms'), '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 @@ -70,7 +70,7 @@ def generate_launch_description():


parseYaml = Node(
package='drone_platforms',
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_platforms'), 'config')
worlds_dir = os.path.join(get_package_share_directory('drone_platforms'), 'worlds')
tmux_yml = os.path.join(get_package_share_directory('drone_platforms'), '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_platforms',
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_behaviors',
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_behaviors',
package='drone_sim_driver',
executable='droneExpertPilot.py',
output='screen',
arguments=[
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ def generate_launch_description():
)

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

control = Node(
package='drone_behaviors',
package='drone_sim_driver',
executable='droneNeuralPilot.py',
output='screen',
arguments=[
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,16 +24,16 @@ def generate_launch_description():

net_dir = DeclareLaunchArgument(
'net_dir',
default_value="/home/adrian/workspace/src/tfg/drone_behaviors/models/gateV2Normal/net-1.tar"
default_value="/home/adrian/workspace/src/tfg/drone_sim_driver/models/gateV2Normal/net-1.tar"
)

deepDir = DeclareLaunchArgument(
'deepDir',
default_value="/home/adrian/workspace/src/tfg/drone_behaviors/models/deepPilot/z/net-7.tar" # 7-9
default_value="/home/adrian/workspace/src/tfg/drone_sim_driver/models/deepPilot/z/net-7.tar" # 7-9
)

control = Node(
package='drone_behaviors',
package='drone_sim_driver',
executable='remoteControl.py',
output='screen',
arguments=[
Expand Down
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_behaviors</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.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import albumentations as A
import numpy as np
import random
from torch.utils.data import Datasetf
from torch.utils.data import Dataset
import torchvision.transforms.functional as F
import os
from PIL import Image
Expand Down
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_behaviors")
package_path = ament_index_python.get_package_share_directory("drone_sim_driver")
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
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_behaviors")
package_path = ament_index_python.get_package_share_directory("drone_sim_driver")
sys.path.append(package_path)

from src.control_functions import band_midpoint, search_top_line, search_bottom_line, save_profiling, search_farthest_column
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@


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

from src.control_functions import save_timestamps, save_profiling, PID
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
from geometry_msgs.msg import Point

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

from src.control_functions import PID, save_timestamps, save_profiling
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
import ament_index_python

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

from src.dataset.oldData import rosbagDataset
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
import ament_index_python

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

from src.dataset.data import rosbagDataset
Expand Down
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from ament_index_python.packages import get_package_share_directory
import argparse

package_path = get_package_share_directory("drone_behaviors")
package_path = get_package_share_directory("drone_sim_driver")
sys.path.append(package_path)

from src.dataset.oldData import rosbagDataset, ANGULAR_UMBRALS, LINEAR_UMBRALS
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from ament_index_python.packages import get_package_share_directory
import argparse

package_path = get_package_share_directory("drone_behaviors")
package_path = get_package_share_directory("drone_sim_driver")
sys.path.append(package_path)

from src.dataset.data import rosbagDataset, ALL_UMBRALS, velsDict
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,10 @@ for name in "${tar_files_no_extension[@]}"; do
for world in "${test_worlds[@]}"; do

# Executes the simulator
tmux send-keys -t 0 "ros2 launch drone_ as2_sim_circuit.launch.py world:=../worlds/$world.world yaw:=0.0" C-m
tmux send-keys -t 0 "ros2 launch drone_sim_driver as2_sim_circuit.launch.py world:=../worlds/$world.world yaw:=0.0" C-m
sleep 5

tmux send-keys -t 1 "ros2 launch drone_behaviors neuralPilot.launch.py trace:=False out_dir:=$output_directory/profiling/$world$iteration network_path:=$model_folder/${name}.tar | tee temp_output.txt" C-m
tmux send-keys -t 1 "ros2 launch drone_sim_driver neuralPilot.launch.py trace:=False out_dir:=$output_directory/profiling/$world$iteration network_path:=$model_folder/${name}.tar | tee temp_output.txt" C-m

# Waits until the drone is flying
while ! grep -q "Following" temp_output.txt; do
Expand Down
File renamed without changes.
Binary file added drone_sim_driver/utils/general_timestamps.npy
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,11 @@ for world in "${worlds[@]}"; do
for yaw in "${orientations[@]}"; do

# Executes the simulator
tmux send-keys -t 0 "ros2 launch drone_platforms as2_sim_circuit.launch.py world:=../worlds/$world.world yaw:=$yaw" C-m
tmux send-keys -t 0 "ros2 launch drone_sim_driver as2_sim_circuit.launch.py world:=../worlds/$world.world yaw:=$yaw" C-m
sleep 5

touch temp_output.txt
tmux send-keys -t 1 "ros2 launch drone_behaviors expertPilot.launch.py trace:=False out_dir:=$output_directory/profiling/$world$iteration | tee ./temp_output.txt" C-m
tmux send-keys -t 1 "ros2 launch drone_sim_driver expertPilot.launch.py trace:=False out_dir:=$output_directory/profiling/$world$iteration | tee ./temp_output.txt" C-m

sleep 5

Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,13 @@ worldIter=0

for world in "${test_worlds[@]}"; do
pilots=(
"ros2 launch drone_behaviors neuralPilot.launch.py trace:=False out_dir:=${output_directory}$world/profiling/neural_$world network_path:=$model_name"
"ros2 launch drone_behaviors expertPilot.launch.py trace:=False out_dir:=${output_directory}$world/profiling/expert_$world"
"ros2 launch drone_sim_driver neuralPilot.launch.py trace:=False out_dir:=${output_directory}$world/profiling/neural_$world network_path:=$model_name"
"ros2 launch drone_sim_driver expertPilot.launch.py trace:=False out_dir:=${output_directory}$world/profiling/expert_$world"
)
for pilot in "${pilots[@]}"; do

# Executes the simulator
tmux send-keys -t 0 "ros2 launch drone_platforms as2_sim_circuit.launch.py world:=../worlds/$world.world yaw:=3.14" C-m
tmux send-keys -t 0 "ros2 launch drone_sim_driver as2_sim_circuit.launch.py world:=../worlds/$world.world yaw:=3.14" C-m
sleep 5

tmux send-keys -t 1 "$pilot | tee temp_output.txt" C-m
Expand Down
Binary file added drone_sim_driver/utils/vel_timestamps.npy
Binary file not shown.
File renamed without changes.
File renamed without changes.
Loading

0 comments on commit 88cce9b

Please sign in to comment.