Skip to content

Commit a52bc57

Browse files
Add alternative publish route function
1 parent de8bcbc commit a52bc57

2 files changed

Lines changed: 35 additions & 0 deletions

File tree

srunner/autoagents/autoware_agent.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
from srunner.scenarioconfigs.environment_configuration import EnvironmentConfig
1111

1212
from autoware_carla_interface_msgs.msg import EgoConfig, SensorConfig
13+
from geometry_msgs.msg import PoseStamped
1314

1415
import threading
1516
import rclpy
@@ -36,6 +37,7 @@ def setup(self, config: EnvironmentConfig | None = None) -> None:
3637

3738
rclpy.init(args=None)
3839

40+
3941
self.autoware_state = autoware_state.AutowareState("ego_vehicle", None)
4042

4143
self.route_node = route_node.RouteNode(self.autoware_state)
@@ -91,6 +93,8 @@ def set_route(self) -> None:
9193

9294
logger.info("Clearing route...")
9395
self.route_node.request_clear_route()
96+
97+
9498

9599
def _convert_to_waypoint(self, point):
96100
"""Returns a waypoint
@@ -136,6 +140,7 @@ def run_step(self) -> None:
136140
self._convert_to_waypoint(waypoint).autoware_from_world_coords()
137141
)
138142
self.route_node.request_route(goal_pose, waypoints)
143+
self.route_node.publish_route(goal_pose, waypoints)
139144

140145
# check if the current route is set
141146
if self.autoware_state.route_ready() and not self.autoware_state.sent_engage:

srunner/autoagents/autoware_nodes/route_node.py

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
# You might explicitly import the Request types for clarity, though not strictly necessary
99
from autoware_adapi_v1_msgs.srv._set_route_points import SetRoutePoints_Request
1010
from autoware_adapi_v1_msgs.srv._clear_route import ClearRoute_Request
11+
from geometry_msgs.msg import PoseStamped
1112

1213

1314
class RouteNode(Node):
@@ -17,6 +18,9 @@ class RouteNode(Node):
1718
# These are service names, not topic names. Renamed for clarity.
1819
set_route_points_service_name = "/api/routing/set_route_points"
1920
clear_route_service_name = "/api/routing/clear_route"
21+
22+
goal_topic = '/planning/mission_planning/goal'
23+
checkpoint_topic = '/planning/mission_planning/checkpoint'
2024

2125
def __init__(self, autoware_state) -> None:
2226
# Initialize the Node base class with a unique name
@@ -31,6 +35,13 @@ def __init__(self, autoware_state) -> None:
3135
self.clear_route_client = self.create_client(
3236
ClearRoute, self.clear_route_service_name
3337
)
38+
39+
self.goal_publisher = self.create_publisher(
40+
PoseStamped, self.goal_topic, 10
41+
)
42+
self.checkpoint_publisher = self.create_publisher(
43+
PoseStamped, self.checkpoint_topic, 10
44+
)
3445

3546
# Good practice: Wait for the service server to be available before trying to call it
3647
self.get_logger().info(
@@ -87,6 +98,25 @@ def request_route(self, goal: Pose, waypoints: list[Pose]) -> None:
8798

8899
# Add a callback to process the response when it arrives.
89100
future.add_done_callback(self.set_route_response_callback)
101+
102+
def publish_route(self, goal: Pose, checkpoints: list[Pose]) -> None:
103+
self._publish_goal(goal)
104+
105+
for checkpoint in checkpoints:
106+
self._publish_checkpoint(checkpoint)
107+
108+
def _publish_goal(self, goal) -> None:
109+
goal = PoseStamped()
110+
goal.header.stamp = self.node.get_clock().now().to_msg()
111+
goal.pose = goal
112+
self.goal_publisher.publish(goal)
113+
114+
115+
def _publish_checkpoint(self, checkpoint) -> None:
116+
goal = PoseStamped()
117+
goal.header.stamp = self.node.get_clock().now().to_msg()
118+
goal.pose = checkpoint
119+
self.checkpoint_publisher.publish(goal)
90120

91121
def set_route_response_callback(self, future):
92122
"""Callback to handle the response from the SetRoutePoints service."""

0 commit comments

Comments
 (0)