Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ RUN mkdir /ros_workspace/ && \
tar -xvf /ros_workspace/autoware_msgs.tar && \
rm -rf /ros_workspace/autoware_msgs.tar && \
source /opt/ros/humble/setup.bash && \
apt install ros-humble-rmw-cyclonedds-cpp ros-humble-tf-transformations && \
rosdep install -i --from-path /ros_workspace/src --rosdistro humble -y && \
colcon build

Expand Down
18 changes: 15 additions & 3 deletions aw_scenario_runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,12 @@ def __init__(self, config: dict) -> None:
sys.path.insert(0, os.path.dirname(autoware_agent_path))
self.module_aw_agent = importlib.import_module(module_name)

# load the algorithm of choice
algorithm = self._scenario_config["algorithm"] # relative path to entry point
alg_module = os.path.basename(algorithm).split(".")[0]
sys.path.insert(0, os.path.dirname(algorithm))
self.module_algorithm = importlib.import_module(alg_module)

# main class to execute scenarios
self.scenario_manager = ScenarioManager(
self._scenario_config["debug"],
Expand Down Expand Up @@ -221,7 +227,7 @@ def run_scenario(
result = True
except Exception:
traceback.print_exc()
print("It doesn't wokr")
print("It doesn't work")
result = False
return result

Expand All @@ -238,6 +244,8 @@ def _spawn_ego(self, env_config: EnvironmentConfig) -> None:
)
self.ego_vehicles.append(ego)

CarlaDataProvider.get_world().wait_for_tick() # wait for tick

bp_library = self.carla_world.get_blueprint_library()
# setup sensors
for sensor in env_config.sensor_config:
Expand All @@ -254,11 +262,15 @@ def _load_route_scenario(
return route_config[0]

def run(self) -> bool:
# load the original JSON file
# load the route config
# load the scenarion
# run it
# load the scenario config
# run scenario
# get the metrics
# call the algorithm callback
# save using ResultsManager static class

# repeat for iterations

env_config = self._load_scenario_config()
route_config = self._load_route_scenario(env_config)
Expand Down
1 change: 1 addition & 0 deletions config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,5 @@ scenario_runner:
in_docker: true # used for dev
algorithm:
iterations: 1000
path: /srunner/ # relative path
hyperparmaters: # will be passed into the algorithm class
1 change: 0 additions & 1 deletion example_scenario.json
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,6 @@
"upper_fov": 10.0,
"lower_fov": -30.0,
"rotation_frequency": 20,
"noise_stddev": 0.0
}
},
{
Expand Down
3 changes: 1 addition & 2 deletions srunner/autoagents/autoware_agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@ def setup(self, config: EnvironmentConfig | None = None) -> None:
# check the bridge is ready
# publish sensor information to the bridge
# wait for it to return the correct message
# hang until

ego_config_msg = EgoConfig()
ego_config_msg.ego_name = config.ego_name
Expand All @@ -69,7 +68,7 @@ def setup(self, config: EnvironmentConfig | None = None) -> None:
# keep publishing ego_sensor config until the bridge is ready
while not self.autoware_state.bridge_ready:
time.sleep(1)
self.autoware_state.ego_config_publisher.publish(ego_config_msg)
self.state_node.ego_config_publisher.publish(ego_config_msg)

def set_route(self) -> None:
# for every point in the plan
Expand Down
20 changes: 5 additions & 15 deletions srunner/autoagents/autoware_nodes/state_node.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,13 @@
from srunner.autoagents.agent_state import autoware_state
from autoware_carla_interface.msg import EgoConfig, BridgeState

from srunner.tools.environment_parser import DefaultSensor


class StateNode(Node):
route_state = "/planning/mission_planning/state"
motion_state = "/api/motion/state"
localize_state = "/api/localization/initialization_state"

ego_config = "/bridge/ego_vehicle/config" # publish sensor config type: EgoConfig
ego_config = "/bridge/ego_vehicle/config" # publish sensor config type: EgoConfig
bridge_state = "/bridge/state"

def __init__(self, autoware_state: autoware_state.AutowareState) -> None:
Expand All @@ -33,18 +31,13 @@ def __init__(self, autoware_state: autoware_state.AutowareState) -> None:
10,
)
self.autoware_state_subscriber = self.create_subscription(
BridgeState,
self.bridge_state,
self.bridge_state_cb,
10
BridgeState, self.bridge_state, self.bridge_state_cb, 10
)

self.ego_config_publisher = self.create_publisher(
EgoConfig,
self.ego_config,
10
EgoConfig, self.ego_config, 10
)

def bridge_state_cb(self, bridge_state_msg: BridgeState):
"""Set the AutowareState attribute bridge_state

Expand Down Expand Up @@ -78,6 +71,3 @@ def localize_state_cb(
localize_state_msg (LocalizationInitializationState): localization message received
"""
self.autoware_state.localize_state = localize_state_msg.state

def publish_sensor_info(self, sensor_config: list[DefaultSensor]) -> None:
return
12 changes: 7 additions & 5 deletions srunner/tools/environment_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,15 @@ def _spawn(self, bp_library, vehicle) -> None:
sensor_params = [attr for attr in dir(self) if attr not in ignored_params]

for param in sensor_params:
sensor_bp.set_attribute(param, getattr(self, param))
sensor_bp.set_attribute(param, str(getattr(self, param)))

CarlaDataProvider.get_world().spawn_actor(sensor_bp, self.spawn, vehicle)
CarlaDataProvider.get_world().wait_for_tick()

def serealize(self):
return self.type, self.id


class CameraRGB(DefaultSensor):
"""
A class to hold additional information about a camera sensor
Expand All @@ -70,8 +72,7 @@ def __init__(self) -> None:
self.points_per_second: int = 0
self.upper_fov: float = 0.0
self.lower_fov: float = 0.0
self.rotation_freq: int = 0
self.noise_sttdev: float = 0.0
self.rotation_frequency: int = 0


class SensorGNSS(DefaultSensor):
Expand Down Expand Up @@ -171,8 +172,9 @@ def parse_ego_config(config: EnvironmentConfig, elem: Element) -> None:
sensor_obj.points_per_second = sensor.attrib.get("points_per_second", 0)
sensor_obj.upper_fov = sensor.attrib.get("upper_fov", 0.0)
sensor_obj.lower_fov = sensor.attrib.get("lower_fov", 0.0)
sensor_obj.rotation_freq = sensor.attrib.get("rotation_frequency", 0)
sensor_obj.noise_sttdev = sensor.attrib.get("noise_sttdev", 0.0)
sensor_obj.rotation_frequency = sensor.attrib.get(
"rotation_frequency", 0
)

sensor_obj.type = sensor_type
sensor_obj.id = sensor.attrib.get("id", "")
Expand Down
Loading