From cfbd1700b1537a086bc5a3b97b73da27e270c6d8 Mon Sep 17 00:00:00 2001 From: seefelke Date: Thu, 21 Nov 2024 18:36:02 +0100 Subject: [PATCH 1/3] Added new message types Trajectory and Navigation Point. Added Behaviour Enum in localplanning/utils.py --- code/planning/CMakeLists.txt | 23 ++++++++++++++++------- code/planning/msg/NavigationPoint.msg | 3 +++ code/planning/msg/Trajectory.msg | 2 ++ code/planning/package.xml | 4 ++++ code/planning/src/local_planner/utils.py | 7 +++++++ 5 files changed, 32 insertions(+), 7 deletions(-) create mode 100644 code/planning/msg/NavigationPoint.msg create mode 100644 code/planning/msg/Trajectory.msg diff --git a/code/planning/CMakeLists.txt b/code/planning/CMakeLists.txt index 34c3ccd0..9da52430 100755 --- a/code/planning/CMakeLists.txt +++ b/code/planning/CMakeLists.txt @@ -13,8 +13,11 @@ project(planning) find_package(catkin REQUIRED COMPONENTS perception rospy + rosout roslaunch std_msgs + geometry_msgs + message_generation ) roslaunch_add_file_check(launch) @@ -48,9 +51,11 @@ catkin_python_setup() ## * add every package in MSG_DEP_SET to generate_messages(DEPENDENCIES ...) ## Generate messages in the 'msg' folder -# add_message_files( -# MinDistance.msg -# ) + add_message_files( + FILES + NavigationPoint.msg + Trajectory.msg + ) ## Generate services in the 'srv' folder # add_service_files( @@ -67,9 +72,12 @@ catkin_python_setup() # ) ## Generate added messages and services with any dependencies listed here -# generate_messages( -# perception -# ) + generate_messages( + DEPENDENCIES + std_msgs + perception + geometry_msgs + ) ################################################ ## Declare ROS dynamic reconfigure parameters ## @@ -105,7 +113,8 @@ catkin_package( # LIBRARIES planning # CATKIN_DEPENDS other_catkin_pkg # DEPENDS system_lib - CATKIN_DEPENDS perception rospy +# CATKIN_DEPENDS perception rospy + CATKIN_DEPENDS message_runtime ) ########### diff --git a/code/planning/msg/NavigationPoint.msg b/code/planning/msg/NavigationPoint.msg new file mode 100644 index 00000000..e9eb53c9 --- /dev/null +++ b/code/planning/msg/NavigationPoint.msg @@ -0,0 +1,3 @@ +geometry_msgs/Point position +float32 speed +uint8 behaviour \ No newline at end of file diff --git a/code/planning/msg/Trajectory.msg b/code/planning/msg/Trajectory.msg new file mode 100644 index 00000000..94060cdd --- /dev/null +++ b/code/planning/msg/Trajectory.msg @@ -0,0 +1,2 @@ +Header header +planning/NavigationPoint[] navigationPoints \ No newline at end of file diff --git a/code/planning/package.xml b/code/planning/package.xml index a321a109..daf36bc6 100755 --- a/code/planning/package.xml +++ b/code/planning/package.xml @@ -47,6 +47,9 @@ + message_generation + message_runtime + rospy roslaunch @@ -57,6 +60,7 @@ carla_msgs sensor_msgs std_msgs + geometry_msgs perception perception diff --git a/code/planning/src/local_planner/utils.py b/code/planning/src/local_planner/utils.py index d976506d..5d684df9 100644 --- a/code/planning/src/local_planner/utils.py +++ b/code/planning/src/local_planner/utils.py @@ -3,6 +3,7 @@ import math import carla import os +from enum import IntEnum # import rospy @@ -23,6 +24,12 @@ EARTH_RADIUS_EQUA = 6378137.0 +# getattr(Behaviour, "name").value returns the ID +# Behaviour(id) returns Behaviour.NAME +class Behaviour(IntEnum): + CRUISING = 0 + + def get_distance(pos_1, pos_2): """Calculate the distance between two positions From a4355e7c451a7dbaf616cdb63eb61673091e4d45 Mon Sep 17 00:00:00 2001 From: seefelke <33551476+seefelke@users.noreply.github.com> Date: Thu, 21 Nov 2024 18:51:17 +0100 Subject: [PATCH 2/3] Update code/planning/CMakeLists.txt Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> --- code/planning/CMakeLists.txt | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/code/planning/CMakeLists.txt b/code/planning/CMakeLists.txt index 9da52430..c6288e03 100755 --- a/code/planning/CMakeLists.txt +++ b/code/planning/CMakeLists.txt @@ -113,8 +113,7 @@ catkin_package( # LIBRARIES planning # CATKIN_DEPENDS other_catkin_pkg # DEPENDS system_lib -# CATKIN_DEPENDS perception rospy - CATKIN_DEPENDS message_runtime + CATKIN_DEPENDS perception rospy message_runtime ) ########### From 668b6d745a1a443aa265330d47a5e562006946d0 Mon Sep 17 00:00:00 2001 From: seefelke Date: Sun, 24 Nov 2024 11:45:39 +0100 Subject: [PATCH 3/3] refactored enum into seperate file --- code/planning/src/BehaviourEnum.py | 8 ++++++++ code/planning/src/local_planner/utils.py | 7 ------- 2 files changed, 8 insertions(+), 7 deletions(-) create mode 100644 code/planning/src/BehaviourEnum.py diff --git a/code/planning/src/BehaviourEnum.py b/code/planning/src/BehaviourEnum.py new file mode 100644 index 00000000..361b0b43 --- /dev/null +++ b/code/planning/src/BehaviourEnum.py @@ -0,0 +1,8 @@ +from enum import IntEnum + +# getattr(Behaviour, "name").value returns the ID +# Behaviour(id) returns Behaviour.NAME + + +class BehaviourEnum(IntEnum): + CRUISING = 0 diff --git a/code/planning/src/local_planner/utils.py b/code/planning/src/local_planner/utils.py index 5d684df9..d976506d 100644 --- a/code/planning/src/local_planner/utils.py +++ b/code/planning/src/local_planner/utils.py @@ -3,7 +3,6 @@ import math import carla import os -from enum import IntEnum # import rospy @@ -24,12 +23,6 @@ EARTH_RADIUS_EQUA = 6378137.0 -# getattr(Behaviour, "name").value returns the ID -# Behaviour(id) returns Behaviour.NAME -class Behaviour(IntEnum): - CRUISING = 0 - - def get_distance(pos_1, pos_2): """Calculate the distance between two positions