Skip to content

Commit 771c718

Browse files
added new service type for rebuild
1 parent 01523ff commit 771c718

4 files changed

Lines changed: 43 additions & 24 deletions

File tree

docker/autoware_msgs.tar

478 KB
Binary file not shown.

srunner/autoagents/autoware_agent.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,10 @@ def setup(self, config: EnvironmentConfig | None = None) -> None:
6060

6161
self.publish_sensor_state()
6262

63+
self.setup_tick_service()
64+
65+
self.setup_route()
66+
6367
def publish_sensor_state(self) -> None:
6468
# publish sensor information to the bridge
6569
# wait for it to return the correct message
@@ -78,7 +82,7 @@ def publish_sensor_state(self) -> None:
7882
# big performance diminishment here
7983
while not self.autoware_state.bridge_ready:
8084
logger.info("Sending Sensor state to Agent...")
81-
time.sleep(5) # DO NOT CHANGE THIS IS A MAGIC NUMBER
85+
time.sleep(5) # DO NOT CHANGE THIS IS A MAGIC NUMBER
8286
self.state_node.ego_config_publisher.publish(ego_config_msg)
8387

8488
def set_route(self) -> None:
@@ -123,7 +127,7 @@ def run_step(self) -> None:
123127
self.counter += 1
124128
if self.counter % 20 == 0:
125129
logger.info("Ticked 1 second")
126-
130+
127131
if not self.agent_set_route:
128132
self.set_route()
129133

@@ -152,4 +156,4 @@ def run_step(self) -> None:
152156

153157
# check if the current route is set
154158
if self.autoware_state.route_set() and not self.autoware_state.sent_engage:
155-
self.autoware_node.publish_engage(True)
159+
self.autoware_node.publish_engage(True)

srunner/autoagents/autoware_nodes/autoware_node.py

Lines changed: 5 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -15,25 +15,18 @@
1515

1616

1717
class AutowareNode(Node):
18-
engage_topic = "/autoware/engage" # Renamed for clarity as it's a topic
19-
localize_service = (
20-
"/api/localization/initialize" # Renamed for clarity as it's a service
21-
)
18+
engage_topic = "/autoware/engage"
19+
localize_service = "/api/localization/initialize"
2220

23-
def __init__(
24-
self, autoware_state_instance: autoware_state.AutowareState
25-
): # Renamed arg for clarity
26-
super().__init__("autoware_node") # Initialize the Node with a unique name
21+
def __init__(self, autoware_state_instance: autoware_state.AutowareState):
22+
super().__init__("autoware_node")
2723

28-
# This is correct: Engage is a message type for a topic
2924
self.engage_publisher = self.create_publisher(Engage, self.engage_topic, 10)
3025

31-
# FIX: Create a service client, not a publisher, for InitializeLocalization
3226
self.localize_client = self.create_client(
3327
InitializeLocalization, self.localize_service
3428
)
3529

36-
# marker publisher
3730
self.marker_publisher = self.create_publisher(
3831
Marker, "visulaization_marker", 10
3932
)
@@ -77,24 +70,15 @@ def request_localize(
7770
"""
7871
self.get_logger().info("Sending localization initialization request...")
7972

80-
# Create a request object for the InitializeLocalization service
81-
request = (
82-
InitializeLocalization_Request()
83-
) # InitializeLocalization() would also work
84-
73+
request = InitializeLocalization_Request()
8574
if global_pose:
8675
# Populate the request with the provided pose
8776
# Assuming the service definition has a field named 'pose' of type PoseWithCovarianceStamped
8877
request.pose = global_pose
8978
else:
90-
# If no pose is provided, send an empty request (as per Autoware behavior)
91-
# The 'pose' field of the request message would default to its empty state.
9279
self.get_logger().info(
9380
"No initial global_pose provided, sending empty localization request."
9481
)
95-
# If the service requires 'pose' to always be set, even to a default,
96-
# you'd need to explicitly set a default PoseWithCovarianceStamped here.
97-
# Example: request.pose = PoseWithCovarianceStamped() # Creates an empty message
9882

9983
# Call the service asynchronously
10084
future = self.localize_client.call_async(request)
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# import message types
2+
3+
from rclpy.node import Node
4+
5+
6+
class TickNode(Node):
7+
"""ROS2 Client Node solely responsible for ticking the Autoware-Carla-Bridge.
8+
The service is called syncronously, blocking execution until Autoware executes the action and replies.
9+
10+
The node also has an optional boolean to enable tracking execution time.
11+
"""
12+
13+
tick_service = "/autoware/tick"
14+
15+
def __init__(self, exec_time: bool = False, debug: bool = False) -> None:
16+
super().__init__("")
17+
self._exec_time = exec_time
18+
self.debug = debug
19+
20+
self.tick_client = self.create_client(
21+
# message type - implement,
22+
self.tick_service
23+
)
24+
25+
def autoware_tick(self) -> None:
26+
# get current time
27+
# assemble tick message
28+
# over client
29+
# block until response received
30+
31+
return

0 commit comments

Comments
 (0)