Skip to content

Commit 4ec18dd

Browse files
Merge pull request #55 from Intelligent-Testing-Lab/49-lidar-pointcloud-is-0
49 lidar pointcloud is 0
2 parents b4e093e + c333ac0 commit 4ec18dd

10 files changed

Lines changed: 58 additions & 26 deletions

File tree

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ RUN mkdir /cyclonedds && \
3636
mv /autoware_scenario_runner/docker/cyclonedds.xml /cyclonedds/ && \
3737
echo "export RMW_IMPLEMENTATION=rmw_cyclonedds_cpp" >> ~/.bashrc && \
3838
echo "export CYCLONEDDS_URI=file:///cyclonedds/cyclonedds.xml" >> ~/.bashrc && \
39-
echo "alias rossrc='source ${AUTOWARE_MSG_PKG}} && source ${ROS_PKG}} && echo Sourced'" >> ~/.bashrc && \
39+
echo "alias rossrc='source ${AUTOWARE_MSG_PKG} && source ${ROS_PKG} && echo Sourced'" >> ~/.bashrc && \
4040
source ~/.bashrc
4141

4242
ENV CARLA_API_ROOT="/autoware_scenario_runner/PythonAPI"

aw_scenario_runner.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ def run_scenario(
146146
self.ego_vehicles.append(ego.spawn())
147147
logger.info("Spawned ego...")
148148

149-
self.carla_world.tick()
149+
self.carla_world.tick() # client must tick to spawn actors
150150

151151
logger.info("Setting up sensor configuration...")
152152
ego.setup_sensors()

example_scenario.json

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -34,23 +34,30 @@
3434
"waypoints": [
3535
{
3636
"position": {
37-
"x": 983.5,
38-
"y": 5382.2,
39-
"z": 371
37+
"x": 88.4,
38+
"y": 82.2,
39+
"z": 0.0
4040
}
4141
},
4242
{
4343
"position": {
44-
"x": 1234,
45-
"y": 5.2,
46-
"z": 3123471
44+
"x": 230.0,
45+
"y": 133.5,
46+
"z": 0.0
4747
}
4848
},
4949
{
5050
"position": {
51-
"x": 123412343.5,
52-
"y": 512341234.2,
53-
"z": 3712341234
51+
"x": 209.5,
52+
"y": 195.1,
53+
"z": 0.0
54+
}
55+
},
56+
{
57+
"position": {
58+
"x": 88.4,
59+
"y": 260.7,
60+
"z": 0.0
5461
}
5562
}
5663
],

srunner/autoagents/agent_state/autoware_state.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,9 @@ def is_ready_publish_route(self) -> bool:
3131
def is_planning(self) -> bool:
3232
return self.route_state == 3
3333

34+
def route_ready(self) -> bool:
35+
return self.sent_route and self.route_set()
36+
3437
def reset_state(self) -> None:
3538
# internal message states
3639
self.sent_route: bool = False

srunner/autoagents/agent_state/state.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,3 @@ def __repr__(self):
2323
def __str__(self):
2424
"""Return name of state and list of attributes"""
2525
return f"{self.__class__.__name__} state: {self.__dict__}"
26-
27-
def route_ready(self) -> None:
28-
pass

srunner/autoagents/autoware_agent.py

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

3939
self.autoware_state = autoware_state.AutowareState("ego_vehicle", None)
4040

41-
self.route_node = route_node.RouteNode()
41+
self.route_node = route_node.RouteNode(self.autoware_state)
4242
self.state_node = state_node.StateNode(self.autoware_state)
4343
self.autoware_node = autoware_node.AutowareNode(self.autoware_state)
4444

@@ -87,7 +87,7 @@ def set_route(self) -> None:
8787

8888
# reinitialise localization
8989
logger.info("Localising Autoware agent...")
90-
self.autoware_node.request_localize() # None uses GNSS
90+
# self.autoware_node.request_localize() # None uses GNSS
9191

9292
logger.info("Clearing route...")
9393
self.route_node.request_clear_route()
@@ -135,7 +135,6 @@ def run_step(self) -> None:
135135
self._convert_to_waypoint(waypoint).autoware_from_world_coords()
136136
)
137137
self.route_node.request_route(goal_pose, waypoints)
138-
self.autoware_state.sent_route = True
139138

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

srunner/autoagents/autoware_nodes/autoware_node.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ def request_localize(
9090
# Example: request.pose = PoseWithCovarianceStamped() # Creates an empty message
9191

9292
# Call the service asynchronously
93-
future = self.localize_client.call(request)
93+
future = self.localize_client.call_async(request)
9494

9595
# Add a callback to process the response when it arrives
9696
future.add_done_callback(self.localize_response_callback)
Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
from tf_transformations import quaternion_from_euler
2-
from geometry_msgs.msg import PoseStamped
2+
from geometry_msgs.msg import Pose
3+
from geometry_msgs.msg import Point
4+
from geometry_msgs.msg import Quaternion
35

46

57
class Waypoint(object):
@@ -12,13 +14,25 @@ def __init__(self, x, y, z, yaw):
1214
# rounding is need by autoware to function properly
1315
self.quaternion = quaternion_from_euler(0, 0, round(self.yaw, 1))
1416

15-
def autoware_from_world_coords(self) -> PoseStamped:
17+
def autoware_from_world_coords(self) -> Pose:
1618
"""convert from carla world coordinates to autoware waypoints
1719
1820
Returns:
1921
PoseStamped: position and time stamp
2022
"""
21-
pose = PoseStamped()
23+
pose = Pose()
2224

23-
pose.header.frame_id = "map"
24-
return
25+
ros_point = Point()
26+
ros_point.x = self.x
27+
ros_point.y = -self.y
28+
ros_point.z = self.z
29+
30+
pose.position = ros_point
31+
pose.orientation = Quaternion(
32+
w=self.quaternion[3],
33+
x=self.quaternion[0],
34+
y=self.quaternion[1],
35+
z=self.quaternion[2],
36+
)
37+
38+
return pose

srunner/autoagents/autoware_nodes/route_node.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,12 @@ class RouteNode(Node):
1818
set_route_points_service_name = "/api/routing/set_route_points"
1919
clear_route_service_name = "/api/routing/clear_route"
2020

21-
def __init__(self) -> None:
21+
def __init__(self, autoware_state) -> None:
2222
# Initialize the Node base class with a unique name
2323
super().__init__("route_client_node")
2424

25+
self.autoware_state = autoware_state
26+
2527
# Create service clients, not publishers
2628
self.set_route_client = self.create_client(
2729
SetRoutePoints, self.set_route_points_service_name
@@ -81,7 +83,7 @@ def request_route(self, goal: Pose, waypoints: list[Pose]) -> None:
8183
request.waypoints = waypoints
8284

8385
# Call the service asynchronously. This returns a Future object.
84-
future = self.set_route_client.call(request)
86+
future = self.set_route_client.call_async(request)
8587

8688
# Add a callback to process the response when it arrives.
8789
future.add_done_callback(self.set_route_response_callback)
@@ -93,6 +95,7 @@ def set_route_response_callback(self, future):
9395
response = future.result()
9496
# Assuming Autoware services return a status field with success/message
9597
if response.status.success:
98+
self.autoware_state.sent_route = True
9699
self.get_logger().info("Route set successfully!")
97100
else:
98101
self.get_logger().warn(
@@ -109,7 +112,7 @@ def request_clear_route(self):
109112
request = ClearRoute_Request() # Or ClearRoute()
110113

111114
# Call the service asynchronously
112-
future = self.clear_route_client.call(request)
115+
future = self.clear_route_client.call_async(request)
113116
future.add_done_callback(self.clear_route_response_callback)
114117

115118
def clear_route_response_callback(self, future):

srunner/autoagents/autoware_nodes/state_node.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,10 @@
55
from srunner.autoagents.agent_state import autoware_state
66
from autoware_carla_interface_msgs.msg import EgoConfig, BridgeState
77

8+
import logging
9+
10+
logger = logging.getLogger("scenario-runner")
11+
812

913
class StateNode(Node):
1014
route_state = "/planning/mission_planning/state"
@@ -46,6 +50,7 @@ def bridge_state_cb(self, bridge_state_msg: BridgeState):
4650
bridge_state_msg (BridgeState): bridge state boolean value
4751
"""
4852
self.autoware_state.bridge_ready = bridge_state_msg.bridge_ready
53+
logger.info(f"Bridge ready state: {self.autoware_state.bridge_ready}")
4954

5055
def route_state_cb(self, route_state_msg: RouteState) -> None:
5156
"""Set the AutowareState attribute route_state
@@ -54,14 +59,17 @@ def route_state_cb(self, route_state_msg: RouteState) -> None:
5459
route_state_msg (RouteState): route state message received
5560
"""
5661
self.autoware_state.route_state = route_state_msg.state
62+
logger.info(f"Route state: {self.autoware_state.route_state}")
5763

5864
def motion_state_cb(self, motion_state_msg: MotionState) -> None:
5965
"""set the AutowareState attribute motion_state
6066
6167
Args:
6268
motion_state_msg (MotionState): motion state message received
6369
"""
70+
6471
self.autoware_state.motion_state = motion_state_msg.state
72+
logger.info(f"Motion state: {self.autoware_state.motion_state}")
6573

6674
def localize_state_cb(
6775
self, localize_state_msg: LocalizationInitializationState
@@ -72,3 +80,4 @@ def localize_state_cb(
7280
localize_state_msg (LocalizationInitializationState): localization message received
7381
"""
7482
self.autoware_state.localize_state = localize_state_msg.state
83+
logger.info(f"Localization state: {self.autoware_state.localize_state}")

0 commit comments

Comments
 (0)