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
12 changes: 10 additions & 2 deletions aw_scenario_runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -263,9 +263,17 @@ def main():

logger.setLevel(logging.INFO)

log_formatter = logging.Formatter(log_config["log_format"])

log_path = LogUtil.create_log_file(log_config["path"])
logger.addHandler(logging.FileHandler(log_path, encoding="utf-8"))
logger.addHandler(logging.StreamHandler(sys.stdout))
fh = logging.FileHandler(log_path, encoding="utf-8")
sh = logging.StreamHandler(sys.stdout)

fh.setFormatter(log_formatter)
sh.setFormatter(log_formatter)

logger.addHandler(fh)
logger.addHandler(sh)

# reload world and sync must be present when running agent-based route scenarios
scenario_runner = None
Expand Down
5 changes: 3 additions & 2 deletions config.yaml
Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@
log:
path: 'logs/'
clear_old_logs: true
log_format: '[%(levelname)s] [%(asctime)s] [%(message)s] [%(filename)s]:[%(lineno)d]'
carla:
host: 127.0.0.1
port: 2000
timeout: 20
sync: true
fixed_delta_seconds: 0.05 # update rate 1 / FPS
traffic_manager:
active: false
active: true
sync: true # must be the same as carla sync
seed: 0
port: 8000
port: 8001
scenario_runner:
debug: false
dev_mode: false
Expand Down
5 changes: 3 additions & 2 deletions example_scenario.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
"weather": {
"route_percentage": 0.0,
"precipitation": 100.0,
"cloudiness": 0.0,
"precipitation_deposits": 100.0,
"wetness": 100.0,
"wind_intensity": 100.0,
Expand All @@ -18,8 +19,9 @@
},
{
"weather": {
"route_percentage": 50.0,
"route_percentage": 100.0,
"precipitation": 0.0,
"cloudiness": 0.0,
"precipitation_deposits": 0.0,
"wetness": 0.0,
"wind_intensity": 0.0,
Expand Down Expand Up @@ -130,7 +132,6 @@
{
"scenario": {
"town": "Town01",
"route-id": 0,
"ego_vehicle": {
"x": 312,
"y": 129,
Expand Down
13 changes: 6 additions & 7 deletions srunner/autoagents/autoware_agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,12 +86,11 @@ def set_route(self) -> None:
self.waypoints_world = self._global_plan_world_coord[:-1]

# reinitialise localization
logger.info("called localise")
# self.autoware_node.request_localize() # None uses GNSS
logger.info("Localising Autoware agent...")
self.autoware_node.request_localize() # None uses GNSS

logger.info("called clear route")
# clear route
# self.route_node.request_clear_route()
logger.info("Clearing route...")
self.route_node.request_clear_route()

def _convert_to_waypoint(self, point):
"""Returns a waypoint
Expand Down Expand Up @@ -121,7 +120,7 @@ def run_step(self) -> None:
"""Tick method containing all logic based on autoware state"""
self.counter += 1
if self.counter % 20 == 0:
logger.info("1 second")
logger.info("Ticked 1 second")

if not self.agent_set_route:
self.set_route()
Expand All @@ -135,7 +134,7 @@ def run_step(self) -> None:
waypoints.append(
self._convert_to_waypoint(waypoint).autoware_from_world_coords()
)
self.route_node.publish_route(goal_pose, waypoints)
self.route_node.request_route(goal_pose, waypoints)
self.autoware_state.sent_route = True

# check if the current route is set
Expand Down
2 changes: 2 additions & 0 deletions srunner/objects/ego_vehicle.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ def spawn(self) -> carla.Actor:
self.ego_model, self.ego_spawn, self.ego_name
)

CarlaDataProvider.get_world().tick()

if self._actor is None:
logger.warning(
"Failed to spawn EgoVehicle. This is likely an issue with CARLA."
Expand Down
2 changes: 1 addition & 1 deletion srunner/objects/sensors.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ def _spawn(self, bp_library, vehicle) -> None:
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()
CarlaDataProvider.get_world().tick()

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