Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

638 feature rework entering overtake #659

Merged
merged 30 commits into from
Feb 6, 2025
Merged
Show file tree
Hide file tree
Changes from 24 commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
578d0b0
Merge remote-tracking branch 'origin/main' into 638-feature-rework-en…
seefelke Jan 21, 2025
8fffe5d
updated overtake so that the car actually enters the routine
seefelke Jan 22, 2025
1423fc7
Merge branch '599-feature-add-first-intermediate-layer-map-function-f…
seefelke Jan 22, 2025
0d3b04f
some smaller changes
seefelke Jan 22, 2025
d64e63c
Merge branch '634-add-map-function-to-detect-entities-on-trajectory' …
seefelke Jan 23, 2025
65202bc
Merge remote-tracking branch 'origin/main' into 638-feature-rework-en…
seefelke Jan 23, 2025
78a5a57
changed overtake ahead to be based on trajectory collisions
seefelke Jan 25, 2025
a5f854d
Merge remote-tracking branch 'origin/634-feature-add-collision-avoida…
seefelke Jan 25, 2025
3edcfb4
more progress
seefelke Jan 26, 2025
b839282
Merge remote-tracking branch 'origin/634-feature-add-collision-avoida…
seefelke Jan 26, 2025
b3b0efd
added overtake marker visualization
seefelke Jan 26, 2025
118d76c
Merge remote-tracking branch 'origin/611-feature-intermediate-layer-m…
seefelke Jan 26, 2025
23790d7
integrated lane free checking to overtake
seefelke Jan 26, 2025
a302b18
comments
seefelke Jan 26, 2025
8313700
Merge branch 'main' into 638-feature-rework-entering-overtake
seefelke Jan 26, 2025
29bc3ef
wait is now skipped if oncoming was free
seefelke Jan 26, 2025
5b411ec
Merge branch '638-feature-rework-entering-overtake' of https://github…
seefelke Jan 26, 2025
7e55f6d
Merge remote-tracking branch 'origin/main' into 638-feature-rework-en…
seefelke Jan 28, 2025
31e5845
some number tweaks and new abort condition
seefelke Jan 28, 2025
677bb7d
linter
seefelke Jan 28, 2025
501032e
Merge branch 'main' into 638-feature-rework-entering-overtake
seefelke Feb 4, 2025
83f70b0
Merge remote-tracking branch 'origin/main' into 638-feature-rework-en…
seefelke Feb 4, 2025
dcd13b9
added utils file and work on new map function integration
seefelke Feb 4, 2025
88eea2a
refactored overtake to use new tree functions, added bicycle handling
seefelke Feb 4, 2025
8a32913
some fixes
seefelke Feb 4, 2025
4486128
removed some obsolete code
seefelke Feb 4, 2025
66a5a81
Merge remote-tracking branch 'origin/main' into 638-feature-rework-en…
seefelke Feb 5, 2025
b1343c3
review fixes
seefelke Feb 5, 2025
c7b3487
linter
seefelke Feb 5, 2025
1b1e655
Merge branch 'main' into 638-feature-rework-entering-overtake
seefelke Feb 6, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion code/planning/src/behavior_agent/behavior_tree.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,13 @@ def grow_a_tree(role_name):
),
],
),
],
),
Selector(
"Overtaking",
children=[
Sequence(
"Overtaking",
"Overtake",
children=[
overtake.Ahead("Overtake Ahead?"),
Sequence(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ def convert_to_ms(speed):

# Wait

ot_wait_stopped = Behavior("ot_wait_stopped", convert_to_ms(0.0))
ot_wait_stopped = Behavior("ot_wait_stopped", 3.0)

ot_wait_free = Behavior("ot_wait_free", -1)

Expand Down
72 changes: 72 additions & 0 deletions code/planning/src/behavior_agent/behaviors/behavior_utils.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
import rospy
import mapping_common.entity
from mapping_common.map import Map
from visualization_msgs.msg import Marker
from mapping_common.shape import Polygon

"""
This file represents the utility functions for the behavior tree
It containes parameters and utility functions to reduce code in the behaviors.
"""
MARKER_NAMESPACE: str = "behaviortree"


def get_hero_width(map: Map):
"""Returns the hero width

Args:
map (Map): Intermediate layer map object

Returns:
float: width of the hero
"""
hero = map.hero()
if hero is None or hero.motion is None:
# We currenly have no hero data.
# -> cannot drive safely
rospy.logerr("Behavior utils: No hero with motion found in map!")
return 0
return max(1.0, hero.get_width())


def get_marker_arr_in_front(entity, distance, hero, collision_masks):
"""Generates a marker array for visualization. Used for obstacle in front scenarios.

Args:
entity (Entity): The entity in front
distance (float): Distance to the entity
hero (Entity): The hero car
collision_masks (Polygon Array): Array of polygon masks to visualize

Returns:
_type_: _description_
"""
text_markers = []
entity_markers = []
shape_markers = []
for mask in collision_masks:
shape_markers.append((Polygon.from_shapely(mask), (0, 1.0, 1.0, 0.5)))
current_velocity = hero.get_global_x_velocity() or 0.0
entity_markers.append((entity, (1.0, 0.0, 0.0, 0.5)))

lead_delta_velocity = (
hero.get_delta_forward_velocity_of(entity) or -current_velocity
)

marker_text = (
f"LeadDistance: {distance}\n"
+ f"LeadXVelocity: {entity.get_global_x_velocity()}\n"
+ f"DeltaV: {lead_delta_velocity}\n"
)
text_marker = Marker(type=Marker.TEXT_VIEW_FACING, text=marker_text)
text_marker.pose.position.x = -2.0
text_marker.pose.position.y = 0.0
text_markers.append((text_marker, (1.0, 1.0, 1.0, 1.0)))

marker_array = mapping_common.entity.shape_debug_marker_array(
MARKER_NAMESPACE,
entities=entity_markers,
shapes=shape_markers,
markers=text_markers,
)
return marker_array
Loading
Loading