Skip to content

Commit

Permalink
Refactored repo with linters
Browse files Browse the repository at this point in the history
  • Loading branch information
JulianTrommer committed Oct 15, 2024
1 parent 5d522eb commit daf2255
Show file tree
Hide file tree
Showing 24 changed files with 101 additions and 117 deletions.
1 change: 0 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
{
"githubIssues.issueBranchTitle": "${issueNumber}-${sanitizedIssueTitle}",
"githubIssues.queries": [

{
"label": "My Issues",
"query": "default"
Expand Down
4 changes: 4 additions & 0 deletions build/agent_service.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@ services:
build:
dockerfile: build/docker/agent/Dockerfile
context: ../
args:
USERNAME: ${USERNAME}
USER_UID: ${USER_UID}
USER_GID: ${USER_GID}
init: true
tty: true
shm_size: 2gb
Expand Down
4 changes: 3 additions & 1 deletion build/docker-compose.dev.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# compose file for the development without a driving vehicle
# "interactive" development without a car
include:
- roscore_service.yaml

services:
agent-dev:
build:
Expand All @@ -24,5 +27,4 @@ services:
- DISPLAY=${DISPLAY}
network_mode: host
privileged: true
entrypoint: ["/dev_entrypoint.sh"]
command: bash -c "sudo chown -R ${USER_UID}:${USER_GID} ../ && sudo chmod -R a+w ../ && bash"
16 changes: 2 additions & 14 deletions build/docker/agent-dev/dev_entrypoint.sh
Original file line number Diff line number Diff line change
@@ -1,19 +1,7 @@
#!/bin/bash
set -e

# Source ROS setup
source /opt/ros/noetic/setup.bash

# Source the catkin workspace setup
source /catkin_ws/devel/setup.bash

# Set up any additional environment variables if needed
export CARLA_ROOT=/opt/carla
export SCENARIO_RUNNER_ROOT=/opt/scenario_runner
export LEADERBOARD_ROOT=/opt/leaderboard

# Execute the command passed to the script, or start a bash session if no command was given
if [ $# -eq 0 ]; then
exec bash
else
exec "$@"
fi
exec "$@"
3 changes: 1 addition & 2 deletions build/docker/agent/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -170,12 +170,11 @@ RUN source /opt/ros/noetic/setup.bash && catkin_make

ADD ./build/docker/agent/entrypoint.sh /entrypoint.sh



# set the default working directory to the code
WORKDIR /workspace/code

RUN echo "source /opt/ros/noetic/setup.bash" >> ~/.bashrc
RUN echo "source /catkin_ws/devel/setup.bash" >> ~/.bashrc

ENTRYPOINT ["/entrypoint.sh"]
CMD ["bash", "-c", "sleep 10 && \
Expand Down
35 changes: 18 additions & 17 deletions build/docker/agent/Dockerfile_Submission
Original file line number Diff line number Diff line change
Expand Up @@ -19,18 +19,18 @@ ARG DEBIAN_FRONTEND=noninteractive

# install rendering dependencies for rviz / rqt
RUN apt-get update \
&& apt-get install -y -qq --no-install-recommends \
&& apt-get install -y -qq --no-install-recommends \
libxext6 libx11-6 libglvnd0 libgl1 \
libglx0 libegl1 freeglut3-dev

# install dependencies for libgit2 and Carla PythonAPI
RUN apt-get install wget unzip

RUN wget https://github.com/una-auxme/paf/releases/download/v0.0.1/PythonAPI_Leaderboard-2.0.zip -O PythonAPI.zip \
&& unzip PythonAPI.zip \
&& rm PythonAPI.zip \
&& mkdir -p /opt/carla \
&& mv PythonAPI /opt/carla/PythonAPI
&& unzip PythonAPI.zip \
&& rm PythonAPI.zip \
&& mkdir -p /opt/carla \
&& mv PythonAPI /opt/carla/PythonAPI

# build libgit2
RUN wget https://github.com/libgit2/libgit2/archive/refs/tags/v1.5.0.tar.gz -O libgit2-1.5.0.tar.gz \
Expand Down Expand Up @@ -67,12 +67,12 @@ ENV PYTHONPATH=$PYTHONPATH:/opt/carla/PythonAPI/carla/dist/carla-0.9.14-py3.7-li

# install mlocate, pip, wget, git and some ROS dependencies for building the CARLA ROS bridge
RUN apt-get update && apt-get install -y \
mlocate python3-pip wget git python-is-python3 \
ros-noetic-ackermann-msgs ros-noetic-derived-object-msgs \
ros-noetic-carla-msgs ros-noetic-pcl-conversions \
ros-noetic-rviz ros-noetic-rqt ros-noetic-pcl-ros ros-noetic-rosbridge-suite ros-noetic-rosbridge-server \
ros-noetic-robot-pose-ekf ros-noetic-ros-numpy \
ros-noetic-py-trees-ros ros-noetic-rqt-py-trees ros-noetic-rqt-reconfigure
mlocate python3-pip wget git python-is-python3 \
ros-noetic-ackermann-msgs ros-noetic-derived-object-msgs \
ros-noetic-carla-msgs ros-noetic-pcl-conversions \
ros-noetic-rviz ros-noetic-rqt ros-noetic-pcl-ros ros-noetic-rosbridge-suite ros-noetic-rosbridge-server \
ros-noetic-robot-pose-ekf ros-noetic-ros-numpy \
ros-noetic-py-trees-ros ros-noetic-rqt-py-trees ros-noetic-rqt-reconfigure

SHELL ["/bin/bash", "-c"]

Expand Down Expand Up @@ -178,12 +178,13 @@ ADD ./build/docker/agent/entrypoint.sh /entrypoint.sh
WORKDIR /workspace/code

RUN echo "source /opt/ros/noetic/setup.bash" >> ~/.bashrc
RUN echo "source /catkin_ws/devel/setup.bash" >> ~/.bashrc

ENTRYPOINT ["/entrypoint.sh"]
CMD ["bash", "-c", "sleep 10 && python3 /opt/leaderboard/leaderboard/leaderboard_evaluator.py --debug=${DEBUG_CHALLENGE} \
--repetitions=${REPETITIONS} \
--checkpoint=${CHECKPOINT_ENDPOINT} \
--track=${CHALLENGE_TRACK} \
--agent=${TEAM_AGENT} \
--routes=${ROUTES} \
--host=${CARLA_SIM_HOST}"]
--repetitions=${REPETITIONS} \
--checkpoint=${CHECKPOINT_ENDPOINT} \
--track=${CHALLENGE_TRACK} \
--agent=${TEAM_AGENT} \
--routes=${ROUTES} \
--host=${CARLA_SIM_HOST}"]
4 changes: 2 additions & 2 deletions build/docker/agent/entrypoint.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/bin/bash
set -e

source "/opt/ros/noetic/setup.bash"
source "/catkin_ws/devel/setup.bash"
source /opt/ros/noetic/setup.bash
source /catkin_ws/devel/setup.bash

exec "$@"
Empty file removed code/__init__.py
Empty file.
4 changes: 2 additions & 2 deletions code/perception/launch/perception.launch
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@
<param name="right" value="False" />

<!--Object-Detection:
- fasterrcnn_resnet50_fpn_v2
- fasterrcnn_mobilenet_v3_large_320_fpn
- frcnn_resnet50_fpn_v2
- frcnn_mobilenet_v3_large_320_fpn
- yolov8n
- yolov8s
- yolov8m
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,15 @@
import os

sys.path.append(os.path.abspath(sys.path[0] + "/.."))
from traffic_light_detection.transforms import (
from traffic_light_detection.transforms import ( # noqa: E402
Normalize,
ResizeAndPadToSquare,
load_image,
) # noqa: E402
)
from data_generation.weights_organizer import WeightsOrganizer # noqa: E402
from traffic_light_detection.classification_model import (
from traffic_light_detection.classification_model import ( # noqa: E402
ClassificationModel,
) # noqa: E402
)
from traffic_light_config import TrafficLightConfig # noqa: E402


Expand Down
4 changes: 2 additions & 2 deletions code/perception/src/traffic_light_node.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@
from perception.msg import TrafficLightState
from std_msgs.msg import Int16
from cv_bridge import CvBridge
from traffic_light_detection.src.traffic_light_detection.traffic_light_inference import (
from traffic_light_detection.src.traffic_light_detection.traffic_light_inference import ( # noqa: E501
TrafficLightInference,
) # noqa: E501
)
import cv2
import numpy as np

Expand Down
4 changes: 2 additions & 2 deletions code/perception/src/vision_node.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,15 +42,15 @@ def __init__(self, name, **kwargs):

# dictionary of pretrained models
self.model_dict = {
"fasterrcnn_resnet50_fpn_v2": (
"frcnn_resnet50_fpn_v2": (
fasterrcnn_resnet50_fpn_v2(
weights=FasterRCNN_ResNet50_FPN_V2_Weights.DEFAULT
),
FasterRCNN_ResNet50_FPN_V2_Weights.DEFAULT,
"detection",
"pyTorch",
),
"fasterrcnn_mobilenet_v3_large_320_fpn": (
"frcnn_mobilenet_v3_large_320_fpn": (
fasterrcnn_mobilenet_v3_large_320_fpn(
weights=FasterRCNN_MobileNet_V3_Large_320_FPN_Weights.DEFAULT
),
Expand Down
1 change: 0 additions & 1 deletion code/planning/__init__.py

This file was deleted.

Empty file.
72 changes: 29 additions & 43 deletions code/planning/src/behavior_agent/behavior_tree.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,21 @@
import py_trees_ros
import rospy
import sys
import behaviours
from behaviours import (
intersection,
lane_change,
overtake,
maneuvers,
meta,
road_features,
topics2blackboard,
)
from py_trees.composites import Parallel, Selector, Sequence

"""
Source: https://github.com/ll7/psaf2
"""

# flake8: noqa: E501


def grow_a_tree(role_name):

Expand All @@ -23,34 +29,26 @@ def grow_a_tree(role_name):
Selector(
"Priorities",
children=[
behaviours.maneuvers.UnstuckRoutine("Unstuck Routine"),
maneuvers.UnstuckRoutine("Unstuck Routine"),
Selector(
"Road Features",
children=[
behaviours.maneuvers.LeaveParkingSpace(
"Leave Parking Space"
),
maneuvers.LeaveParkingSpace("Leave Parking Space"),
Sequence(
"Intersection",
children=[
behaviours.road_features.IntersectionAhead(
road_features.IntersectionAhead(
"Intersection Ahead?"
),
Sequence(
"Intersection Actions",
children=[
behaviours.intersection.Approach(
intersection.Approach(
"Approach Intersection"
),
behaviours.intersection.Wait(
"Wait Intersection"
),
behaviours.intersection.Enter(
"Enter Intersection"
),
behaviours.intersection.Leave(
"Leave Intersection"
),
intersection.Wait("Wait Intersection"),
intersection.Enter("Enter Intersection"),
intersection.Leave("Leave Intersection"),
],
),
],
Expand All @@ -63,61 +61,49 @@ def grow_a_tree(role_name):
Sequence(
"Laneswitch",
children=[
behaviours.road_features.LaneChangeAhead(
"Lane Change Ahead?"
),
road_features.LaneChangeAhead("Lane Change Ahead?"),
Sequence(
"Lane Change Actions",
children=[
behaviours.lane_change.Approach(
"Approach Change"
),
behaviours.lane_change.Wait("Wait Change"),
behaviours.lane_change.Enter(
"Enter Change"
),
behaviours.lane_change.Leave(
"Leave Change"
),
lane_change.Approach("Approach Change"),
lane_change.Wait("Wait Change"),
lane_change.Enter("Enter Change"),
lane_change.Leave("Leave Change"),
],
),
],
),
Sequence(
"Overtaking",
children=[
behaviours.road_features.OvertakeAhead(
"Overtake Ahead?"
),
road_features.OvertakeAhead("Overtake Ahead?"),
Sequence(
"Overtake Actions",
children=[
behaviours.overtake.Approach(
"Approach Overtake"
),
behaviours.overtake.Wait("Wait Overtake"),
behaviours.overtake.Enter("Enter Overtake"),
behaviours.overtake.Leave("Leave Overtake"),
overtake.Approach("Approach Overtake"),
overtake.Wait("Wait Overtake"),
overtake.Enter("Enter Overtake"),
overtake.Leave("Leave Overtake"),
],
),
],
),
],
),
behaviours.maneuvers.Cruise("Cruise"),
maneuvers.Cruise("Cruise"),
],
)
],
)

metarules = Sequence(
"Meta",
children=[behaviours.meta.Start("Start"), rules, behaviours.meta.End("End")],
children=[meta.Start("Start"), rules, meta.End("End")],
)
root = Parallel(
"Root",
children=[
behaviours.topics2blackboard.create_node(role_name),
topics2blackboard.create_node(role_name),
metarules,
Running("Idle"),
],
Expand Down
3 changes: 0 additions & 3 deletions code/planning/src/behavior_agent/behaviours/__init__.py
100755 → 100644
Original file line number Diff line number Diff line change
@@ -1,3 +0,0 @@
from . import intersection, lane_change, overtake, maneuvers, meta, road_features
from . import topics2blackboard, traffic_objects
from . import behavior_speed
12 changes: 8 additions & 4 deletions code/planning/src/behavior_agent/behaviours/intersection.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,16 @@
from std_msgs.msg import String

import rospy
import sys
import os

from . import behavior_speed as bs
from behaviours import behavior_speed as bs

import planning # noqa: F401

from local_planner.utils import TARGET_DISTANCE_TO_STOP, convert_to_ms
sys.path.append(os.path.abspath(sys.path[0] + "/.."))
from local_planner.utils import ( # type: ignore # noqa: E402
TARGET_DISTANCE_TO_STOP,
convert_to_ms,
)

"""
Source: https://github.com/ll7/psaf2
Expand Down
2 changes: 1 addition & 1 deletion code/planning/src/behavior_agent/behaviours/lane_change.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

import rospy

from . import behavior_speed as bs
from behaviours import behavior_speed as bs
from local_planner.utils import TARGET_DISTANCE_TO_STOP, convert_to_ms

"""
Expand Down
2 changes: 1 addition & 1 deletion code/planning/src/behavior_agent/behaviours/maneuvers.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import rospy
from std_msgs.msg import String, Float32, Bool
import numpy as np
from . import behavior_speed as bs
from behaviours import behavior_speed as bs

# from behavior_agent.msg import BehaviorSpeed

Expand Down
Loading

0 comments on commit daf2255

Please sign in to comment.