Skip to content

Commit 22325bf

Browse files
Merge pull request #59 from Intelligent-Testing-Lab/get-appropriate-yaw-value
added waypoints
2 parents fedfb2a + 4f3722a commit 22325bf

5 files changed

Lines changed: 7243 additions & 8 deletions

File tree

srunner/autoagents/autoware_agent.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,7 @@ def _convert_to_waypoint(self, point):
102102
point[0].location.x,
103103
point[0].location.y,
104104
point[0].location.z,
105+
marker_pub=self.autoware_node.marker_publisher,
105106
)
106107

107108
def destroy(self) -> None:

srunner/autoagents/autoware_nodes/autoware_node.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
InitializeLocalization_Request,
88
) # Explicitly import Request
99
from geometry_msgs.msg import PoseWithCovarianceStamped
10+
from visualization_msgs.msg import Marker
1011

1112
# Assuming this import path is correct for your project
1213
from srunner.autoagents.agent_state import autoware_state
@@ -31,6 +32,11 @@ def __init__(
3132
InitializeLocalization, self.localize_service
3233
)
3334

35+
# marker publisher
36+
self.marker_publisher = self.create_publisher(
37+
Marker, "visulaization_marker", 10
38+
)
39+
3440
# Good practice: Wait for the service to be available
3541
self.get_logger().info(f"Waiting for '{self.localize_service}' service...")
3642
while not self.localize_client.wait_for_service(timeout_sec=1.0):

srunner/autoagents/autoware_nodes/autoware_types/waypoint.py

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,16 +9,14 @@
99

1010

1111
class Waypoint(object):
12-
def __init__(self, x, y, z):
12+
def __init__(self, x, y, z, marker_pub=None):
1313
self.x = x
1414
self.y = y
1515
self.z = z
1616

17-
self.client = CarlaDataProvider.get_client()
17+
self.marker_pub = marker_pub
1818

19-
self.marker_publisher = self.create_publisher(
20-
Marker, "visulaization_marker", 10
21-
)
19+
self.client = CarlaDataProvider.get_client()
2220

2321
def autoware_from_world_coords(self) -> Pose:
2422
"""convert from carla world coordinates to autoware waypoints
@@ -42,8 +40,12 @@ def autoware_from_world_coords(self) -> Pose:
4240
z=orientation["z"],
4341
w=orientation["w"],
4442
)
45-
46-
self._publish_marker()
43+
44+
if self.marker_pub is not None:
45+
print(self)
46+
self.marker_pub.publish(self._publish_marker(pose))
47+
48+
self.pose = pose
4749

4850
return pose
4951

@@ -93,4 +95,9 @@ def _publish_marker(self, pose):
9395
marker.color.b = 0.0
9496
marker.color.a = 1.0
9597

96-
self.marker_publisher.publish(marker)
98+
return marker
99+
100+
def __str__(self) -> str:
101+
if self.pose:
102+
return f"{self.pose}"
103+
return f"x: {self.x}, y: {-self.y}, z: {self.z}"

0 commit comments

Comments
 (0)