|
15 | 15 |
|
16 | 16 |
|
17 | 17 | 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" |
22 | 20 |
|
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") |
27 | 23 |
|
28 | | - # This is correct: Engage is a message type for a topic |
29 | 24 | self.engage_publisher = self.create_publisher(Engage, self.engage_topic, 10) |
30 | 25 |
|
31 | | - # FIX: Create a service client, not a publisher, for InitializeLocalization |
32 | 26 | self.localize_client = self.create_client( |
33 | 27 | InitializeLocalization, self.localize_service |
34 | 28 | ) |
35 | 29 |
|
36 | | - # marker publisher |
37 | 30 | self.marker_publisher = self.create_publisher( |
38 | 31 | Marker, "visulaization_marker", 10 |
39 | 32 | ) |
@@ -77,24 +70,15 @@ def request_localize( |
77 | 70 | """ |
78 | 71 | self.get_logger().info("Sending localization initialization request...") |
79 | 72 |
|
80 | | - # Create a request object for the InitializeLocalization service |
81 | | - request = ( |
82 | | - InitializeLocalization_Request() |
83 | | - ) # InitializeLocalization() would also work |
84 | | - |
| 73 | + request = InitializeLocalization_Request() |
85 | 74 | if global_pose: |
86 | 75 | # Populate the request with the provided pose |
87 | 76 | # Assuming the service definition has a field named 'pose' of type PoseWithCovarianceStamped |
88 | 77 | request.pose = global_pose |
89 | 78 | 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. |
92 | 79 | self.get_logger().info( |
93 | 80 | "No initial global_pose provided, sending empty localization request." |
94 | 81 | ) |
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 |
98 | 82 |
|
99 | 83 | # Call the service asynchronously |
100 | 84 | future = self.localize_client.call_async(request) |
|
0 commit comments