Skip to content

Commit 8a5d036

Browse files
Merge pull request #66 from Intelligent-Testing-Lab/64-explore-alternative-routing-technique
Call publish_route() only once
2 parents 2d872a6 + 941e942 commit 8a5d036

2 files changed

Lines changed: 20 additions & 12 deletions

File tree

srunner/autoagents/autoware_agent.py

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@ def setup(self, config: EnvironmentConfig | None = None) -> None:
3737

3838
rclpy.init(args=None)
3939

40-
4140
self.autoware_state = autoware_state.AutowareState("ego_vehicle", None)
4241

4342
self.route_node = route_node.RouteNode(self.autoware_state)
@@ -55,6 +54,8 @@ def setup(self, config: EnvironmentConfig | None = None) -> None:
5554
)
5655
self._executor_thread.start()
5756

57+
self.sent_route = False
58+
5859
# check the bridge is ready
5960
# publish sensor information to the bridge
6061
# wait for it to return the correct message
@@ -93,8 +94,6 @@ def set_route(self) -> None:
9394

9495
logger.info("Clearing route...")
9596
self.route_node.request_clear_route()
96-
97-
9897

9998
def _convert_to_waypoint(self, point):
10099
"""Returns a waypoint
@@ -129,7 +128,11 @@ def run_step(self) -> None:
129128
if not self.agent_set_route:
130129
self.set_route()
131130

132-
if self.autoware_state.is_ready_publish_route() and self.agent_set_route:
131+
if (
132+
self.autoware_state.is_ready_publish_route()
133+
and self.agent_set_route
134+
and not self.sent_route
135+
):
133136
waypoints = []
134137
goal_pose = self._convert_to_waypoint(
135138
self.goal_pose_world
@@ -139,8 +142,9 @@ def run_step(self) -> None:
139142
waypoints.append(
140143
self._convert_to_waypoint(waypoint).autoware_from_world_coords()
141144
)
142-
self.route_node.request_route(goal_pose, waypoints)
145+
# self.route_node.request_route(goal_pose, waypoints)
143146
self.route_node.publish_route(goal_pose, waypoints)
147+
self.sent_route = True
144148

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

srunner/autoagents/autoware_nodes/route_node.py

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -101,22 +101,26 @@ def request_route(self, goal: Pose, waypoints: list[Pose]) -> None:
101101

102102
def publish_route(self, goal: Pose, checkpoints: list[Pose]) -> None:
103103
self._publish_goal(goal)
104-
104+
self.node.create_rate(1.0).sleep()
105105
for checkpoint in checkpoints:
106106
self._publish_checkpoint(checkpoint)
107107

108-
def _publish_goal(self, goal) -> None:
108+
def _publish_goal(self, goal_point) -> None:
109109
goal = PoseStamped()
110110
goal.header.stamp = self.node.get_clock().now().to_msg()
111-
goal.pose = goal
111+
goal.header.frame_id = "map"
112+
113+
goal.pose = goal_point
112114
self.goal_publisher.publish(goal)
113115

114116

115117
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)
118+
checkpoint_msg = PoseStamped()
119+
checkpoint_msg.header.stamp = self.node.get_clock().now().to_msg()
120+
checkpoint_msg.header.frame_id = "map"
121+
122+
checkpoint_msg.pose = checkpoint
123+
self.checkpoint_publisher.publish(checkpoint_msg)
120124

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

0 commit comments

Comments
 (0)