Skip to content

Commit 46b1198

Browse files
Daraanglopezdiestwentasah
authored
Increase code quality and fix test (#1124)
* upgraded version checking to fix deprecation warnings Removed usage of pgk_resources and distutils.version.LooseVersion * Code cleanup 1 Ruff E,W, defalts * Check return statement --ignore F405,F403,F401,RET504,RET505 --exclude tests/ --select E,W,R,PIE,R * flake8-bugbear * remove full width comma * Simplify code with SIM * remove double defined function * fix too long lines * Unnecessary lambda and unnecessary else if * parameterless super() minor changes * Whitespace and other E,W fixes * Add docstring to CDP methods - minor lint fixes * Avoid unbound Name Error * Solve most atomic behavior warnings * further formatting remove extra lines (#1074) Add misc type default blueprint (#1064) Co-authored-by: Pablo Villanueva-Domingo <[email protected]> Fix: wrong initial transform when using request_new_batch_actors (#1068) (#1075) See: #1068 Co-authored-by: Daraan <[email protected]> Update atomic_trigger_conditions.py (#946) In the StandStill() class, change the EPSILON, 0.001 Implement variable frame rate (#1005) Replaced class variable frame_rate with an argument provided on the CLI. Co-authored-by: glopezdiest <[email protected]> Workflow improvements and code quality passing (#1052) * CI: Checkout v4 and unit tests name correction * Small tweaks to ensure Code Quality passes --------- Co-authored-by: glopezdiest <[email protected]> Fixed metrics wheel parser (#1076) Co-authored-by: glopezdiest <[email protected]> [Feature] Blueprint-based spawn_actor function for CarlaDataProvider (#1071) * blueprint-based spawn_actor function for CDP * Auto-Option to decide tracking * Updated changelog * spawned actors are tracked if they are Vehicle | Walker * Updated spawn_actor description --------- Co-authored-by: glopezdiest <[email protected]> Hotfix: missing AttachmentType in the carla mock module for unittest (#1077) * blueprint-based spawn_actor function for CDP * Auto-Option to decide tracking * Updated changelog * spawned actors are tracked if they are Vehicle | Walker * Updated spawn_actor description * Added missing AttachmentType for carla mock --------- Co-authored-by: glopezdiest <[email protected]> Backward compatible upgrade to fix deprecation warnings concerning LooseVersion and pkg_resources for Python3.8+ (#1058) * upgraded version checking to fix deprecation warnings Removed usage of pgk_resources and distutils.version.LooseVersion * < python3.8 backward compatible version checking * Compacter version checking. --------- Co-authored-by: glopezdiest <[email protected]> Replace deprecated python 3.8 code and add missing __init__.py files for proper python module recognition (#1053) Co-authored-by: glopezdiest <[email protected]> add support for scientific notation parsing while running OpenSCENARIO files (#1023) Co-authored-by: glopezdiest <[email protected]> Update osc2_scenario_configuration.py (#1040) Add super.__init__() to class OSC2ScenarioConfiguration to prevent error "AttributeError: 'OSC2ScenarioConfiguration' object has no attribute 'route'" when running scenario_runner.py with --openscenario2 parameter Co-authored-by: glopezdiest <[email protected]> Remove version redundancy (#1081) Update minimum CARLA version to 0.9.14 (#1082) * Remove version redundancy * Merge branch 'master' of https://github.com/carla-simulator/scenario_runner * Update minimum CARLA version Type-hint comments for CarlaDataProvider (#1066) * Type-hint comments for CarlaDataProvider * Suppress Any import warning * Removed None values, increased type-coverage Added log agent [fix]rename compound_symbol.py (#1089) Fixed a typo in openscenario_parser.py (#1118) * Fixed a typo There was a typo in function "get_traffic_light_from_osc_name", which was accessing "CCarlaDataProvider" insted of "CarlaDataProvider". * Delete the unneeded file Fix: Remove duplicate clean method calls (#1096) * [fix]rename compound_symbol.py * [fix]Remove duplicate clean method calls * Fix Atomic_behaviors AddActor Func No return status Link documentation in README (#1129) Include 0.9.14 carla release as compatible with scenario runner 0.9.13 (#1130) * Link documentation in README * Include 0.9.14 carla release as compatible with scenario runner 0.9.13 * Merge branch 'master' into docs_in_readme Added a missing element to the blackboard (#1141) Co-authored-by: glopezdiest <[email protected]> Replaced deprecated is_intersection with is_junction (#1114) Co-authored-by: glopezdiest <[email protected]> CDP request_new_actor new optional argument. (#1113) spawn_point can be ommited when random_location=True Co-authored-by: glopezdiest <[email protected]> Faster information retrieval if actor key is present (#1098) Co-authored-by: glopezdiest <[email protected]> Don't depend on distutils (#1121) distutils are no longer available in Python 3.12. Therefore, we copy the strtobool function from distutils to our own module. This is in line with https://peps.python.org/pep-0632/#migration-advice. Co-authored-by: glopezdiest <[email protected]> Fix dead actor accumulation in CDP (#1091) * Slightly more informative function Returns bool if actor was in the pool, else otherwise * Fix accumulation of dead actors in CDP actor pool * Dead actor cleaning in CDP._actor_*_maps --------- Co-authored-by: glopezdiest <[email protected]> * osc2_scenario: Fix SyntaxWarnings (#1122) This fixes warnings like the one below: .../srunner/scenarios/osc2_scenario.py:515: SyntaxWarning: invalid escape sequence '\W' expression_value = re.split("\W+", option) Co-authored-by: glopezdiest <[email protected]> * formatting * Return iterable * fix: missing import, docstring, explicit return * style: unnecessary super * style: import order * fix | ignore further infractions * some more formatting * define method in init * less general Exception also formatting --------- Co-authored-by: glopezdiest <[email protected]> Co-authored-by: Michal Sojka <[email protected]>
1 parent aff5dbc commit 46b1198

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

57 files changed

+1206
-751
lines changed

manual_control.py

+5-2
Original file line numberDiff line numberDiff line change
@@ -396,6 +396,7 @@ def on_world_tick(self, timestamp):
396396
self.simulation_time = timestamp.elapsed_seconds
397397

398398
def tick(self, world, clock):
399+
# type: (carla.World, pygame.time.Clock) -> None
399400
self._notifications.tick(world, clock)
400401
if not self._show_info:
401402
return
@@ -781,10 +782,12 @@ def __init__(self, parent_actor, hud):
781782
Attachment = carla.AttachmentType
782783

783784
self._camera_transforms = [
784-
(carla.Transform(carla.Location(x=-2.0*bound_x, y=+0.0*bound_y, z=2.0*bound_z), carla.Rotation(pitch=8.0)), Attachment.SpringArm),
785+
(carla.Transform(carla.Location(x=-2.0*bound_x, y=+0.0*bound_y, z=2.0*bound_z),
786+
carla.Rotation(pitch=8.0)), Attachment.SpringArm),
785787
(carla.Transform(carla.Location(x=+0.8*bound_x, y=+0.0*bound_y, z=1.3*bound_z)), Attachment.Rigid),
786788
(carla.Transform(carla.Location(x=+1.9*bound_x, y=+1.0*bound_y, z=1.2*bound_z)), Attachment.SpringArm),
787-
(carla.Transform(carla.Location(x=-2.8*bound_x, y=+0.0*bound_y, z=4.6*bound_z), carla.Rotation(pitch=6.0)), Attachment.SpringArm),
789+
(carla.Transform(carla.Location(x=-2.8*bound_x, y=+0.0*bound_y, z=4.6*bound_z),
790+
carla.Rotation(pitch=6.0)), Attachment.SpringArm),
788791
(carla.Transform(carla.Location(x=-1.0, y=-1.0*bound_y, z=0.4*bound_z)), Attachment.Rigid)]
789792

790793
self.transform_index = 1

metrics_manager.py

+19-8
Original file line numberDiff line numberDiff line change
@@ -130,21 +130,32 @@ def main():
130130
"""
131131

132132
# pylint: disable=line-too-long
133-
description = ("Scenario Runner's metrics module. Evaluate the execution of a specific scenario by developing your own metric.\n")
133+
description = "Scenario Runner's metrics module. Evaluate the execution of a specific scenario by developing your own metric.\n"
134+
# pylint: enable=line-too-long
134135

135136
parser = argparse.ArgumentParser(description=description,
136137
formatter_class=RawTextHelpFormatter)
137138
parser.add_argument('--host', default='127.0.0.1',
138139
help='IP of the host server (default: localhost)')
139140
parser.add_argument('--port', '-p', default=2000,
140141
help='TCP port to listen to (default: 2000)')
141-
parser.add_argument('--log', required=True,
142-
help='Path to the CARLA recorder .log file (relative to SCENARIO_RUNNER_ROOT).\nThis file is created by the record functionality at ScenarioRunner')
143-
parser.add_argument('--metric', required=True,
144-
help='Path to the .py file defining the used metric.\nSome examples at srunner/metrics')
145-
parser.add_argument('--criteria', default="",
146-
help='Path to the .json file with the criteria information.\nThis file is created by the record functionality at ScenarioRunner')
147-
# pylint: enable=line-too-long
142+
parser.add_argument(
143+
"--log",
144+
required=True,
145+
help="Path to the CARLA recorder .log file (relative to SCENARIO_RUNNER_ROOT)."
146+
"\nThis file is created by the record functionality at ScenarioRunner",
147+
)
148+
parser.add_argument(
149+
"--metric",
150+
required=True,
151+
help="Path to the .py file defining the used metric.\nSome examples at srunner/metrics",
152+
)
153+
parser.add_argument(
154+
"--criteria",
155+
default="",
156+
help="Path to the .json file with the criteria information."
157+
"\nThis file is created by the record functionality at ScenarioRunner",
158+
)
148159

149160
args = parser.parse_args()
150161

no_rendering_mode.py

+45-12
Original file line numberDiff line numberDiff line change
@@ -490,22 +490,55 @@ def draw_broken_line(surface, color, closed, points, width):
490490

491491
def get_lane_markings(lane_marking_type, lane_marking_color, waypoints, sign):
492492
margin = 0.20
493-
if lane_marking_type == carla.LaneMarkingType.Broken or (lane_marking_type == carla.LaneMarkingType.Solid):
494-
marking_1 = [world_to_pixel(lateral_shift(w.transform, sign * w.lane_width * 0.5)) for w in waypoints]
493+
if lane_marking_type == carla.LaneMarkingType.Broken or (
494+
lane_marking_type == carla.LaneMarkingType.Solid
495+
):
496+
marking_1 = [
497+
world_to_pixel(
498+
lateral_shift(w.transform, sign * w.lane_width * 0.5)
499+
)
500+
for w in waypoints
501+
]
495502
return [(lane_marking_type, lane_marking_color, marking_1)]
496-
elif lane_marking_type == carla.LaneMarkingType.SolidBroken or lane_marking_type == carla.LaneMarkingType.BrokenSolid:
497-
marking_1 = [world_to_pixel(lateral_shift(w.transform, sign * w.lane_width * 0.5)) for w in waypoints]
498-
marking_2 = [world_to_pixel(lateral_shift(w.transform,
499-
sign * (w.lane_width * 0.5 + margin * 2))) for w in waypoints]
500-
return [(carla.LaneMarkingType.Solid, lane_marking_color, marking_1),
501-
(carla.LaneMarkingType.Broken, lane_marking_color, marking_2)]
503+
elif (
504+
lane_marking_type == carla.LaneMarkingType.SolidBroken
505+
or lane_marking_type == carla.LaneMarkingType.BrokenSolid
506+
):
507+
marking_1 = [
508+
world_to_pixel(
509+
lateral_shift(w.transform, sign * w.lane_width * 0.5)
510+
)
511+
for w in waypoints
512+
]
513+
marking_2 = [
514+
world_to_pixel(
515+
lateral_shift(
516+
w.transform, sign * (w.lane_width * 0.5 + margin * 2)
517+
)
518+
)
519+
for w in waypoints
520+
]
521+
return [
522+
(carla.LaneMarkingType.Solid, lane_marking_color, marking_1),
523+
(carla.LaneMarkingType.Broken, lane_marking_color, marking_2),
524+
]
502525
elif lane_marking_type == carla.LaneMarkingType.BrokenBroken:
503-
marking = [world_to_pixel(lateral_shift(w.transform,
504-
sign * (w.lane_width * 0.5 - margin))) for w in waypoints]
526+
marking = [
527+
world_to_pixel(
528+
lateral_shift(w.transform, sign * (w.lane_width * 0.5 - margin))
529+
)
530+
for w in waypoints
531+
]
505532
return [(carla.LaneMarkingType.Broken, lane_marking_color, marking)]
506533
elif lane_marking_type == carla.LaneMarkingType.SolidSolid:
507-
marking = [world_to_pixel(lateral_shift(w.transform,
508-
sign * ((w.lane_width * 0.5) - margin))) for w in waypoints]
534+
marking = [
535+
world_to_pixel(
536+
lateral_shift(
537+
w.transform, sign * ((w.lane_width * 0.5) - margin)
538+
)
539+
)
540+
for w in waypoints
541+
]
509542
return [(carla.LaneMarkingType.Solid, lane_marking_color, marking)]
510543

511544
return [(carla.LaneMarkingType.NONE, carla.LaneMarkingColor.Other, [])]

scenario_runner.py

+27-9
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
try:
2424
from packaging.version import Version
2525
except ImportError:
26-
from distutils.version import LooseVersion as Version # Python 2 fallback
26+
from distutils.version import LooseVersion as Version # Python 2 fallback
2727
import importlib
2828
import inspect
2929
import os
@@ -35,11 +35,13 @@
3535
try:
3636
# requires Python 3.8+
3737
from importlib.metadata import metadata
38+
3839
def get_carla_version():
3940
return Version(metadata("carla")["Version"])
4041
except ModuleNotFoundError:
4142
# backport checking for older Python versions; module is deprecated
4243
import pkg_resources
44+
4345
def get_carla_version():
4446
return Version(pkg_resources.get_distribution("carla").version)
4547

@@ -106,7 +108,11 @@ def __init__(self, args):
106108
self.client.set_timeout(self.client_timeout)
107109
carla_version = get_carla_version()
108110
if carla_version < Version(MIN_CARLA_VERSION):
109-
raise ImportError("CARLA version {} or newer required. CARLA version found: {}".format(MIN_CARLA_VERSION, carla_version))
111+
raise ImportError(
112+
"CARLA version {} or newer required. CARLA version found: {}".format(
113+
MIN_CARLA_VERSION, carla_version
114+
)
115+
)
110116

111117
# Load agent if requested via command line args
112118
# If something goes wrong an exception will be thrown by importlib (ok here)
@@ -582,8 +588,11 @@ def main():
582588
help='Frame rate (Hz) to use in \'sync\' mode (default: 20)')
583589

584590
parser.add_argument(
585-
'--scenario', help='Name of the scenario to be executed. Use the preposition \'group:\' to run all scenarios of one class, e.g. ControlLoss or FollowLeadingVehicle')
586-
parser.add_argument('--openscenario', help='Provide an OpenSCENARIO definition')
591+
"--scenario",
592+
help="Name of the scenario to be executed. Use the preposition 'group:' to run all scenarios of one class"
593+
" e.g. ControlLoss or FollowLeadingVehicle",
594+
)
595+
parser.add_argument("--openscenario", help="Provide an OpenSCENARIO definition")
587596
parser.add_argument('--openscenarioparams', help='Overwrited for OpenSCENARIO ParameterDeclaration')
588597
parser.add_argument('--openscenario2', help='Provide an openscenario2 definition')
589598
parser.add_argument('--route', help='Run a route as a scenario', type=str)
@@ -604,11 +613,20 @@ def main():
604613
parser.add_argument('--debug', action="store_true", help='Run with debug output')
605614
parser.add_argument('--reloadWorld', action="store_true",
606615
help='Reload the CARLA world before starting a scenario (default=True)')
607-
parser.add_argument('--record', type=str, default='',
608-
help='Path were the files will be saved, relative to SCENARIO_RUNNER_ROOT.\nActivates the CARLA recording feature and saves to file all the criteria information.')
609-
parser.add_argument('--randomize', action="store_true", help='Scenario parameters are randomized')
610-
parser.add_argument('--repetitions', default=1, type=int, help='Number of scenario executions')
611-
parser.add_argument('--waitForEgo', action="store_true", help='Connect the scenario to an existing ego vehicle')
616+
parser.add_argument(
617+
"--record",
618+
type=str,
619+
default="",
620+
help="Path were the files will be saved, relative to SCENARIO_RUNNER_ROOT."
621+
"\nActivates the CARLA recording feature and saves to file all the criteria information.",
622+
)
623+
parser.add_argument("--randomize", action="store_true", help="Scenario parameters are randomized")
624+
parser.add_argument("--repetitions", default=1, type=int, help="Number of scenario executions")
625+
parser.add_argument(
626+
"--waitForEgo",
627+
action="store_true",
628+
help="Connect the scenario to an existing ego vehicle",
629+
)
612630

613631
arguments = parser.parse_args()
614632
# pylint: enable=line-too-long

srunner/autoagents/ros_agent.py

+67-29
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,13 @@
3030
from sensor_msgs.point_cloud2 import create_cloud_xyz32
3131
from std_msgs.msg import Header, String
3232
import tf
33-
# pylint: disable=line-too-long
34-
from carla_msgs.msg import CarlaEgoVehicleStatus, CarlaEgoVehicleInfo, CarlaEgoVehicleInfoWheel, CarlaEgoVehicleControl, CarlaWorldInfo
35-
# pylint: enable=line-too-long
33+
from carla_msgs.msg import (
34+
CarlaEgoVehicleStatus,
35+
CarlaEgoVehicleInfo,
36+
CarlaEgoVehicleInfoWheel,
37+
CarlaEgoVehicleControl,
38+
CarlaWorldInfo,
39+
)
3640

3741
from srunner.autoagents.autonomous_agent import AutonomousAgent
3842

@@ -122,42 +126,73 @@ def setup(self, path_to_conf_file):
122126
self.cv_bridge = CvBridge()
123127

124128
# setup ros publishers for sensors
125-
# pylint: disable=line-too-long
126129
for sensor in self.sensors():
127-
self.id_to_sensor_type_map[sensor['id']] = sensor['type']
128-
if sensor['type'] == 'sensor.camera.rgb':
129-
self.publisher_map[sensor['id']] = rospy.Publisher(
130-
'/carla/ego_vehicle/camera/rgb/' + sensor['id'] + "/image_color", Image, queue_size=1, latch=True)
131-
self.id_to_camera_info_map[sensor['id']] = self.build_camera_info(sensor)
132-
self.publisher_map[sensor['id'] + '_info'] = rospy.Publisher(
133-
'/carla/ego_vehicle/camera/rgb/' + sensor['id'] + "/camera_info", CameraInfo, queue_size=1, latch=True)
134-
elif sensor['type'] == 'sensor.lidar.ray_cast':
135-
self.publisher_map[sensor['id']] = rospy.Publisher(
136-
'/carla/ego_vehicle/lidar/' + sensor['id'] + "/point_cloud", PointCloud2, queue_size=1, latch=True)
137-
elif sensor['type'] == 'sensor.other.gnss':
138-
self.publisher_map[sensor['id']] = rospy.Publisher(
139-
'/carla/ego_vehicle/gnss/' + sensor['id'] + "/fix", NavSatFix, queue_size=1, latch=True)
140-
elif sensor['type'] == 'sensor.can_bus':
130+
self.id_to_sensor_type_map[sensor["id"]] = sensor["type"]
131+
if sensor["type"] == "sensor.camera.rgb":
132+
self.publisher_map[sensor["id"]] = rospy.Publisher(
133+
"/carla/ego_vehicle/camera/rgb/" + sensor["id"] + "/image_color",
134+
Image,
135+
queue_size=1,
136+
latch=True,
137+
)
138+
self.id_to_camera_info_map[sensor["id"]] = self.build_camera_info(
139+
sensor
140+
)
141+
self.publisher_map[sensor["id"] + "_info"] = rospy.Publisher(
142+
"/carla/ego_vehicle/camera/rgb/" + sensor["id"] + "/camera_info",
143+
CameraInfo,
144+
queue_size=1,
145+
latch=True,
146+
)
147+
elif sensor["type"] == "sensor.lidar.ray_cast":
148+
self.publisher_map[sensor["id"]] = rospy.Publisher(
149+
"/carla/ego_vehicle/lidar/" + sensor["id"] + "/point_cloud",
150+
PointCloud2,
151+
queue_size=1,
152+
latch=True,
153+
)
154+
elif sensor["type"] == "sensor.other.gnss":
155+
self.publisher_map[sensor["id"]] = rospy.Publisher(
156+
"/carla/ego_vehicle/gnss/" + sensor["id"] + "/fix",
157+
NavSatFix,
158+
queue_size=1,
159+
latch=True,
160+
)
161+
elif sensor["type"] == "sensor.can_bus":
141162
if not self.vehicle_info_publisher:
142163
self.vehicle_info_publisher = rospy.Publisher(
143-
'/carla/ego_vehicle/vehicle_info', CarlaEgoVehicleInfo, queue_size=1, latch=True)
164+
"/carla/ego_vehicle/vehicle_info",
165+
CarlaEgoVehicleInfo,
166+
queue_size=1,
167+
latch=True,
168+
)
144169
if not self.vehicle_status_publisher:
145170
self.vehicle_status_publisher = rospy.Publisher(
146-
'/carla/ego_vehicle/vehicle_status', CarlaEgoVehicleStatus, queue_size=1, latch=True)
147-
elif sensor['type'] == 'sensor.hd_map':
171+
"/carla/ego_vehicle/vehicle_status",
172+
CarlaEgoVehicleStatus,
173+
queue_size=1,
174+
latch=True,
175+
)
176+
elif sensor["type"] == "sensor.hd_map":
148177
if not self.odometry_publisher:
149178
self.odometry_publisher = rospy.Publisher(
150-
'/carla/ego_vehicle/odometry', Odometry, queue_size=1, latch=True)
179+
"/carla/ego_vehicle/odometry",
180+
Odometry,
181+
queue_size=1,
182+
latch=True,
183+
)
151184
if not self.world_info_publisher:
152185
self.world_info_publisher = rospy.Publisher(
153-
'/carla/world_info', CarlaWorldInfo, queue_size=1, latch=True)
186+
"/carla/world_info", CarlaWorldInfo, queue_size=1, latch=True
187+
)
154188
if not self.map_file_publisher:
155-
self.map_file_publisher = rospy.Publisher('/carla/map_file', String, queue_size=1, latch=True)
189+
self.map_file_publisher = rospy.Publisher(
190+
"/carla/map_file", String, queue_size=1, latch=True
191+
)
156192
if not self.tf_broadcaster:
157193
self.tf_broadcaster = tf.TransformBroadcaster()
158194
else:
159-
raise TypeError("Invalid sensor type: {}".format(sensor['type']))
160-
# pylint: enable=line-too-long
195+
raise TypeError("Invalid sensor type: {}".format(sensor["type"]))
161196

162197
def destroy(self):
163198
"""
@@ -293,9 +328,12 @@ def publish_gnss(self, sensor_id, data):
293328
msg.longitude = data[1]
294329
msg.altitude = data[2]
295330
msg.status.status = NavSatStatus.STATUS_SBAS_FIX
296-
# pylint: disable=line-too-long
297-
msg.status.service = NavSatStatus.SERVICE_GPS | NavSatStatus.SERVICE_GLONASS | NavSatStatus.SERVICE_COMPASS | NavSatStatus.SERVICE_GALILEO
298-
# pylint: enable=line-too-long
331+
msg.status.service = (
332+
NavSatStatus.SERVICE_GPS
333+
| NavSatStatus.SERVICE_GLONASS
334+
| NavSatStatus.SERVICE_COMPASS
335+
| NavSatStatus.SERVICE_GALILEO
336+
)
299337
self.publisher_map[sensor_id].publish(msg)
300338

301339
def publish_camera(self, sensor_id, data):

srunner/metrics/tools/metrics_log.py

+1-4
Original file line numberDiff line numberDiff line change
@@ -407,10 +407,7 @@ def is_vehicle_light_active(self, light, vehicle_id, frame):
407407
"""
408408
lights = self.get_vehicle_lights(vehicle_id, frame)
409409

410-
if light in lights:
411-
return True
412-
413-
return False
410+
return light in lights
414411

415412
# Scene lights
416413
def get_scene_light_state(self, light_id, frame):

srunner/metrics/tools/metrics_parser.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -507,7 +507,7 @@ def parse_recorder_info(self):
507507

508508
elif name == "use_gear_auto_box":
509509
name = "use_gear_autobox"
510-
value = True if elements[1] == "true" else False
510+
value = elements[1] == "true"
511511
setattr(physics_control, name, value)
512512

513513
elif "forward_gears" in name or "wheels" in name:

srunner/metrics/tools/osc2_log.py

+1-4
Original file line numberDiff line numberDiff line change
@@ -427,10 +427,7 @@ def is_vehicle_light_active(self, light, vehicle_id, frame):
427427
"""
428428
lights = self.get_vehicle_lights(vehicle_id, frame)
429429

430-
if light in lights:
431-
return True
432-
433-
return False
430+
return light in lights
434431

435432
# Scene lights
436433
def get_scene_light_state(self, light_id, frame):

srunner/metrics/tools/osc2_trace_parser.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -512,7 +512,7 @@ def parse_recorder_info(self):
512512

513513
elif name == "use_gear_auto_box":
514514
name = "use_gear_autobox"
515-
value = True if elements[1] == "true" else False
515+
value = elements[1] == "true"
516516
setattr(physics_control, name, value)
517517

518518
elif "forward_gears" in name or "wheels" in name:

0 commit comments

Comments
 (0)