index
int64
0
50.7k
project_path
stringclasses
279 values
completion_path
stringlengths
57
199
signature_postion
stringlengths
3
11
class_position
stringlengths
3
11
function_name
stringlengths
1
62
class_name
stringlengths
0
55
body_position
stringlengths
3
11
body_position_with_comments
stringlengths
3
11
masked_class
stringlengths
14
8.32k
masked_class_with_comment
stringlengths
14
8.32k
func_body
stringlengths
9
6.72k
func_body_with_comment
stringlengths
9
6.72k
len_func_body
int64
1
643
len_input
int64
10
2.02k
len_output
int64
4
1.9k
total
int64
20
2.05k
file_code
stringlengths
14
442k
file_code_with_comment
stringlengths
14
442k
47,836
/home/hieuvd/dung_repo/raw/stars_03/huawei-noah_SMARTS/SMARTS
/home/hieuvd/dung_repo/raw/stars_03/huawei-noah_SMARTS/SMARTS/smarts/core/opendrive_road_network.py
157,158
94,184
to_linear_segments
LaneBoundary
159,184
158,184
@dataclass class LaneBoundary: """Describes a lane boundary.""" refline: PlanViewElement inner: Optional["LaneBoundary"] lane_widths: List[LaneWidthElement] lane_offsets: List[LaneOffsetElement] segment_size: float = 0.5 def refline_to_linear_segments(self, s_start: float, s_end: float) ->...
@dataclass class LaneBoundary: """Describes a lane boundary.""" refline: PlanViewElement inner: Optional["LaneBoundary"] lane_widths: List[LaneWidthElement] lane_offsets: List[LaneOffsetElement] segment_size: float = 0.5 def refline_to_linear_segments(self, s_start: float, s_end: float) ->...
if self.inner: inner_s_vals = self.inner.to_linear_segments(s_start, s_end) else: if self.lane_offsets: return get_linear_segments_for_range(s_start, s_end, self.segment_size) return self.refline_to_linear_segments(s_start, s_end) outer_s_vals...
"""Convert from lane boundary shape to linear segments.""" if self.inner: inner_s_vals = self.inner.to_linear_segments(s_start, s_end) else: if self.lane_offsets: return get_linear_segments_for_range(s_start, s_end, self.segment_size) return se...
67
814
337
1,151
# Copyright (C) 2022. Huawei Technologies Co., Ltd. All rights reserved. # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal # in the Software without restriction, including without limitation the rights # to us...
# Copyright (C) 2022. Huawei Technologies Co., Ltd. All rights reserved. # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal # in the Software without restriction, including without limitation the rights # to us...
47,838
/home/hieuvd/dung_repo/raw/stars_03/huawei-noah_SMARTS/SMARTS
/home/hieuvd/dung_repo/raw/stars_03/huawei-noah_SMARTS/SMARTS/smarts/core/opendrive_road_network.py
1344,1345
1218,1397
_edge_shape
Road
1345,1377
1345,1377
class Road(RoadMapWithCaches.Road, Surface): """This is akin to a 'road segment' in real life. Many of these might correspond to a single named road in reality.""" def __init__( self, road_map, road_id: str, is_junction: bool, leng...
class Road(RoadMapWithCaches.Road, Surface): """This is akin to a 'road segment' in real life. Many of these might correspond to a single named road in reality.""" def __init__( self, road_map, road_id: str, is_junction: bool, leng...
leftmost_lane = self.lane_at_index(self._total_lanes - 1) rightmost_lane = self.lane_at_index(0) if buffer_width == 0.0: rightmost_lane_buffered_polygon = rightmost_lane.lane_polygon leftmost_lane_buffered_polygon = leftmost_lane.lane_polygon ...
leftmost_lane = self.lane_at_index(self._total_lanes - 1) rightmost_lane = self.lane_at_index(0) if buffer_width == 0.0: rightmost_lane_buffered_polygon = rightmost_lane.lane_polygon leftmost_lane_buffered_polygon = leftmost_lane.lane_polygon ...
74
1,503
423
1,926
# Copyright (C) 2022. Huawei Technologies Co., Ltd. All rights reserved. # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal # in the Software without restriction, including without limitation the rights # to us...
# Copyright (C) 2022. Huawei Technologies Co., Ltd. All rights reserved. # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal # in the Software without restriction, including without limitation the rights # to us...
47,839
/home/hieuvd/dung_repo/raw/stars_03/huawei-noah_SMARTS/SMARTS
/home/hieuvd/dung_repo/raw/stars_03/huawei-noah_SMARTS/SMARTS/smarts/core/opendrive_road_network.py
1498,1500
1484,1510
roads
Route
1500,1502
1500,1502
class Route(RouteWithCache): """Describes a route between two OpenDRIVE roads.""" def __init__( self, road_map: RoadMap, roads: List[RoadMap.Road] = [], start_lane: Optional[RoadMap.Lane] = None, end_lane: Optional[RoadMap.Lane] = None, ...
class Route(RouteWithCache): """Describes a route between two OpenDRIVE roads.""" def __init__( self, road_map: RoadMap, roads: List[RoadMap.Road] = [], start_lane: Optional[RoadMap.Lane] = None, end_lane: Optional[RoadMap.Lane] = None, ...
return self._roads
return self._roads
2
261
10
271
# Copyright (C) 2022. Huawei Technologies Co., Ltd. All rights reserved. # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal # in the Software without restriction, including without limitation the rights # to us...
# Copyright (C) 2022. Huawei Technologies Co., Ltd. All rights reserved. # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal # in the Software without restriction, including without limitation the rights # to us...
47,840
/home/hieuvd/dung_repo/raw/stars_03/huawei-noah_SMARTS/SMARTS
/home/hieuvd/dung_repo/raw/stars_03/huawei-noah_SMARTS/SMARTS/smarts/core/opendrive_road_network.py
816,818
805,821
is_drivable
Surface
818,821
818,821
class Surface(RoadMapWithCaches.Surface): """Describes an OpenDRIVE surface.""" def __init__(self, surface_id: str, road_map): self._surface_id = surface_id self._map = road_map @property def surface_id(self) -> str: return self._surface_id ...
class Surface(RoadMapWithCaches.Surface): """Describes an OpenDRIVE surface.""" def __init__(self, surface_id: str, road_map): self._surface_id = surface_id self._map = road_map @property def surface_id(self) -> str: return self._surface_id ...
# Not all lanes on OpenDRIVE roads are drivable raise NotImplementedError
# Not all lanes on OpenDRIVE roads are drivable raise NotImplementedError
11
123
27
150
# Copyright (C) 2022. Huawei Technologies Co., Ltd. All rights reserved. # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal # in the Software without restriction, including without limitation the rights # to us...
# Copyright (C) 2022. Huawei Technologies Co., Ltd. All rights reserved. # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal # in the Software without restriction, including without limitation the rights # to us...
47,841
/home/hieuvd/dung_repo/raw/stars_03/huawei-noah_SMARTS/SMARTS
/home/hieuvd/dung_repo/raw/stars_03/huawei-noah_SMARTS/SMARTS/smarts/core/opendrive_road_network.py
1626,1627
1616,1665
_match
_WaypointsCache
1627,1634
1627,1634
class _WaypointsCache: def __init__(self): self.lookahead = 0 self.point = Point(0, 0) self.filter_road_ids = () self._starts = {} # XXX: all vehicles share this cache now (as opposed to before # when it was in Plan.py and each vehicle had it...
class _WaypointsCache: def __init__(self): self.lookahead = 0 self.point = Point(0, 0) self.filter_road_ids = () self._starts = {} # XXX: all vehicles share this cache now (as opposed to before # when it was in Plan.py and each vehicle had it...
return ( lookahead <= self.lookahead and point[0] == self.point[0] and point[1] == self.point[1] and filter_road_ids == self.filter_road_ids )
return ( lookahead <= self.lookahead and point[0] == self.point[0] and point[1] == self.point[1] and filter_road_ids == self.filter_road_ids )
18
449
70
519
# Copyright (C) 2022. Huawei Technologies Co., Ltd. All rights reserved. # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal # in the Software without restriction, including without limitation the rights # to us...
# Copyright (C) 2022. Huawei Technologies Co., Ltd. All rights reserved. # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal # in the Software without restriction, including without limitation the rights # to us...
47,843
/home/hieuvd/dung_repo/raw/stars_03/huawei-noah_SMARTS/SMARTS
/home/hieuvd/dung_repo/raw/stars_03/huawei-noah_SMARTS/SMARTS/smarts/core/plan.py
92,93
84,97
is_reached
Goal
94,97
93,97
@dataclass(frozen=True, unsafe_hash=True) class Goal: """Describes an expected end state for a route or mission.""" def is_specific(self) -> bool: """If the goal is reachable at a specific position.""" return False def is_reached(self, vehicle_state) -> bool: FILL_FUNC_BODY
@dataclass(frozen=True, unsafe_hash=True) class Goal: """Describes an expected end state for a route or mission.""" def is_specific(self) -> bool: """If the goal is reachable at a specific position.""" return False def is_reached(self, vehicle_state) -> bool: """If the goal has bee...
return False
"""If the goal has been completed.""" return False
2
111
9
120
# Copyright (C) 2020. Huawei Technologies Co., Ltd. All rights reserved. # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal # in the Software without restriction, including without limitation the rights # to us...
# Copyright (C) 2020. Huawei Technologies Co., Ltd. All rights reserved. # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal # in the Software without restriction, including without limitation the rights # to us...
47,844
/home/hieuvd/dung_repo/raw/stars_03/huawei-noah_SMARTS/SMARTS
/home/hieuvd/dung_repo/raw/stars_03/huawei-noah_SMARTS/SMARTS/smarts/core/plan.py
302,303
285,310
is_complete
LapMission
304,310
303,310
@dataclass(frozen=True) class LapMission(NavigationMission): """A mission requiring a number of laps through the goal.""" num_laps: Optional[int] = None # None means infinite # of laps # If a route was specified in a sstudio.sstypes.LapMission object, # then this should be set to its road length ...
@dataclass(frozen=True) class LapMission(NavigationMission): """A mission requiring a number of laps through the goal.""" num_laps: Optional[int] = None # None means infinite # of laps # If a route was specified in a sstudio.sstypes.LapMission object, # then this should be set to its road length ...
return ( self.goal.is_reached(vehicle_state) and distance_travelled > self.route_length * self.num_laps )
"""If the mission has been completed.""" return ( self.goal.is_reached(vehicle_state) and distance_travelled > self.route_length * self.num_laps )
10
245
54
299
# Copyright (C) 2020. Huawei Technologies Co., Ltd. All rights reserved. # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal # in the Software without restriction, including without limitation the rights # to us...
# Copyright (C) 2020. Huawei Technologies Co., Ltd. All rights reserved. # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal # in the Software without restriction, including without limitation the rights # to us...
47,845
/home/hieuvd/dung_repo/raw/stars_03/huawei-noah_SMARTS/SMARTS
/home/hieuvd/dung_repo/raw/stars_03/huawei-noah_SMARTS/SMARTS/smarts/core/plan.py
255,261
215,285
random_endless_mission
NavigationMission
262,278
261,278
@dataclass(frozen=True) class NavigationMission: """A navigation mission describing a desired trip.""" # XXX: Note that this Mission differs from sstudio.sstypes.Mission in that # this can be less specific as to the particular route taken to the goal, # whereas sstudio.type.Mission includes a specific,...
@dataclass(frozen=True) class NavigationMission: """A navigation mission describing a desired trip.""" # XXX: Note that this Mission differs from sstudio.sstypes.Mission in that # this can be less specific as to the particular route taken to the goal, # whereas sstudio.type.Mission includes a specific,...
assert min_range_along_lane > 0 # Need to start further than beginning of lane assert max_range_along_lane < 1 # Cannot start past end of lane assert min_range_along_lane < max_range_along_lane # Min must be less than max road = road_map.random_route(1).roads[0] n_lane = rand...
"""A mission that starts from a random location and continues indefinitely.""" assert min_range_along_lane > 0 # Need to start further than beginning of lane assert max_range_along_lane < 1 # Cannot start past end of lane assert min_range_along_lane < max_range_along_lane # Min must b...
78
635
263
898
# Copyright (C) 2020. Huawei Technologies Co., Ltd. All rights reserved. # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal # in the Software without restriction, including without limitation the rights # to us...
# Copyright (C) 2020. Huawei Technologies Co., Ltd. All rights reserved. # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal # in the Software without restriction, including without limitation the rights # to us...
47,846
/home/hieuvd/dung_repo/raw/stars_03/huawei-noah_SMARTS/SMARTS
/home/hieuvd/dung_repo/raw/stars_03/huawei-noah_SMARTS/SMARTS/smarts/core/plan.py
359,365
323,449
create_route
Plan
379,436
365,436
class Plan: """Describes a navigation plan (route) to fulfill a mission.""" def __init__( self, road_map: RoadMap, mission: Optional[NavigationMission] = None, find_route: bool = True, ): self._road_map = road_map self._mission = mission self._route =...
class Plan: """Describes a navigation plan (route) to fulfill a mission.""" def __init__( self, road_map: RoadMap, mission: Optional[NavigationMission] = None, find_route: bool = True, ): self._road_map = road_map self._mission = mission self._route =...
assert not self._route or not len( self._route.road_ids ), "Already called create_route()." self._mission = mission or NavigationMission.random_endless_mission( self._road_map ) if not self._mission.requires_route: self._route = self._road_map...
"""Generates a route that conforms to a mission. Args: mission (Mission): A mission the agent should follow. Defaults to endless if `None`. start_lane_radius (Optional[float]): Radius (meter) to find the nearest starting lane for the given ...
219
681
730
1,411
# Copyright (C) 2020. Huawei Technologies Co., Ltd. All rights reserved. # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal # in the Software without restriction, including without limitation the rights # to us...
# Copyright (C) 2020. Huawei Technologies Co., Ltd. All rights reserved. # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal # in the Software without restriction, including without limitation the rights # to us...
47,847
/home/hieuvd/dung_repo/raw/stars_03/huawei-noah_SMARTS/SMARTS
/home/hieuvd/dung_repo/raw/stars_03/huawei-noah_SMARTS/SMARTS/smarts/core/plan.py
317,319
310,323
empty
PlanFrame
320,323
319,323
@dataclass class PlanFrame: """Describes a plan that is serializable.""" road_ids: List[str] mission: Optional[NavigationMission] @classmethod def empty(cls: Type[PlanFrame]): FILL_FUNC_BODY
@dataclass class PlanFrame: """Describes a plan that is serializable.""" road_ids: List[str] mission: Optional[NavigationMission] @classmethod def empty(cls: Type[PlanFrame]): """Creates an empty plan frame.""" FILL_FUNC_BODY
return cls(road_ids=[], mission=None)
"""Creates an empty plan frame.""" return cls(road_ids=[], mission=None)
3
83
21
104
# Copyright (C) 2020. Huawei Technologies Co., Ltd. All rights reserved. # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal # in the Software without restriction, including without limitation the rights # to us...
# Copyright (C) 2020. Huawei Technologies Co., Ltd. All rights reserved. # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal # in the Software without restriction, including without limitation the rights # to us...
47,848
/home/hieuvd/dung_repo/raw/stars_03/huawei-noah_SMARTS/SMARTS
/home/hieuvd/dung_repo/raw/stars_03/huawei-noah_SMARTS/SMARTS/smarts/core/plan.py
136,137
104,143
is_reached
PositionalGoal
137,143
137,143
@dataclass(frozen=True, unsafe_hash=True) class PositionalGoal(Goal): """A goal that can be completed by reaching an end area.""" position: Point # target_heading: Heading radius: float @classmethod def from_road( cls, road_id: str, road_map: RoadMap, lane_index...
@dataclass(frozen=True, unsafe_hash=True) class PositionalGoal(Goal): """A goal that can be completed by reaching an end area.""" position: Point # target_heading: Heading radius: float @classmethod def from_road( cls, road_id: str, road_map: RoadMap, lane_index...
a = vehicle_state.pose.position b = self.position sqr_dist = (a[0] - b.x) ** 2 + (a[1] - b.y) ** 2 return sqr_dist <= self.radius**2
a = vehicle_state.pose.position b = self.position sqr_dist = (a[0] - b.x) ** 2 + (a[1] - b.y) ** 2 return sqr_dist <= self.radius**2
23
316
73
389
# Copyright (C) 2020. Huawei Technologies Co., Ltd. All rights reserved. # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal # in the Software without restriction, including without limitation the rights # to us...
# Copyright (C) 2020. Huawei Technologies Co., Ltd. All rights reserved. # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal # in the Software without restriction, including without limitation the rights # to us...
47,849
/home/hieuvd/dung_repo/raw/stars_03/huawei-noah_SMARTS/SMARTS
/home/hieuvd/dung_repo/raw/stars_03/huawei-noah_SMARTS/SMARTS/smarts/core/plan.py
61,63
48,84
from_pose
Start
64,70
63,70
@dataclass(frozen=True) class Start: """A starting state for a route or mission.""" position: np.ndarray heading: Heading from_front_bumper: Optional[bool] = True @property def point(self) -> Point: """The coordinate of this starting location.""" return Point.from_np_array(self...
@dataclass(frozen=True) class Start: """A starting state for a route or mission.""" position: np.ndarray heading: Heading from_front_bumper: Optional[bool] = True @property def point(self) -> Point: """The coordinate of this starting location.""" return Point.from_np_array(self...
return cls( position=pose.as_position2d(), heading=pose.heading, from_front_bumper=False, )
"""Convert to a starting location from a pose.""" return cls( position=pose.as_position2d(), heading=pose.heading, from_front_bumper=False, )
6
232
47
279
# Copyright (C) 2020. Huawei Technologies Co., Ltd. All rights reserved. # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal # in the Software without restriction, including without limitation the rights # to us...
# Copyright (C) 2020. Huawei Technologies Co., Ltd. All rights reserved. # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal # in the Software without restriction, including without limitation the rights # to us...
47,850
/home/hieuvd/dung_repo/raw/stars_03/huawei-noah_SMARTS/SMARTS
/home/hieuvd/dung_repo/raw/stars_03/huawei-noah_SMARTS/SMARTS/smarts/core/plan.py
163,164
143,183
_drove_off_map
TraverseGoal
164,183
164,183
@dataclass(frozen=True, unsafe_hash=True) class TraverseGoal(Goal): """A TraverseGoal is satisfied whenever an Agent-driven vehicle successfully finishes traversing a non-closed (acyclic) map It's a way for the vehicle to exit the simulation successfully, for example, driving across from one side to the...
@dataclass(frozen=True, unsafe_hash=True) class TraverseGoal(Goal): """A TraverseGoal is satisfied whenever an Agent-driven vehicle successfully finishes traversing a non-closed (acyclic) map It's a way for the vehicle to exit the simulation successfully, for example, driving across from one side to the...
# try to determine if the vehicle "exited" the map by driving beyond the end of a dead-end lane. nearest_lanes = self.road_map.nearest_lanes(veh_pos) if not nearest_lanes: return False # we can't tell anything here nl, dist = nearest_lanes[0] offset = nl.to_lane_coor...
# try to determine if the vehicle "exited" the map by driving beyond the end of a dead-end lane. nearest_lanes = self.road_map.nearest_lanes(veh_pos) if not nearest_lanes: return False # we can't tell anything here nl, dist = nearest_lanes[0] offset = nl.to_lane_coor...
133
263
352
615
# Copyright (C) 2020. Huawei Technologies Co., Ltd. All rights reserved. # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal # in the Software without restriction, including without limitation the rights # to us...
# Copyright (C) 2020. Huawei Technologies Co., Ltd. All rights reserved. # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal # in the Software without restriction, including without limitation the rights # to us...
47,851
/home/hieuvd/dung_repo/raw/stars_03/huawei-noah_SMARTS/SMARTS
/home/hieuvd/dung_repo/raw/stars_03/huawei-noah_SMARTS/SMARTS/smarts/core/provider.py
234,236
221,355
recovery_flags
Provider
237,239
236,239
class Provider: """A Provider manages a (sub)set of actors (e.g., vehicles) that all share the same action space(s). This is a base class (interface) from which all Providers should inherit.""" @property def recovery_flags(self) -> ProviderRecoveryFlags: """Flags specifying what this provider s...
class Provider: """A Provider manages a (sub)set of actors (e.g., vehicles) that all share the same action space(s). This is a base class (interface) from which all Providers should inherit.""" @property def recovery_flags(self) -> ProviderRecoveryFlags: """Flags specifying what this provider s...
raise NotImplementedError
"""Setter to allow recovery flags to be changed.""" raise NotImplementedError
2
1,321
11
1,332
# Copyright (C) 2020. Huawei Technologies Co., Ltd. All rights reserved. # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal # in the Software without restriction, including without limitation the rights # to us...
# Copyright (C) 2020. Huawei Technologies Co., Ltd. All rights reserved. # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal # in the Software without restriction, including without limitation the rights # to us...
47,852
/home/hieuvd/dung_repo/raw/stars_03/huawei-noah_SMARTS/SMARTS
/home/hieuvd/dung_repo/raw/stars_03/huawei-noah_SMARTS/SMARTS/smarts/core/provider.py
179,184
112,221
transition_to_provider
ProviderManager
195,208
184,208
class ProviderManager: """Interface to be implemented by a class that manages a set of Providers that jointly control a set of actors, such that they can hand these off to each other when necessary. Actors can only be passed among Providers that are managed by the same ProviderManager. Providers can c...
class ProviderManager: """Interface to be implemented by a class that manages a set of Providers that jointly control a set of actors, such that they can hand these off to each other when necessary. Actors can only be passed among Providers that are managed by the same ProviderManager. Providers can c...
if actor_provider_transition.current_provider is new_provider: return new_provider if new_provider.can_accept_actor(actor_provider_transition.actor_state): new_provider.add_actor( actor_provider_transition.actor_state, actor_provider_transition.cur...
"""Passes a released actor to a new provider. This depends on `provider_relinquishing_actor`. Args: new_provider (Provider): The provider to transition to. actor_provider_transition (ActorProviderTransition): The released actor information. ...
20
1,078
143
1,221
# Copyright (C) 2020. Huawei Technologies Co., Ltd. All rights reserved. # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal # in the Software without restriction, including without limitation the rights # to us...
# Copyright (C) 2020. Huawei Technologies Co., Ltd. All rights reserved. # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal # in the Software without restriction, including without limitation the rights # to us...
47,853
/home/hieuvd/dung_repo/raw/stars_03/huawei-noah_SMARTS/SMARTS
/home/hieuvd/dung_repo/raw/stars_03/huawei-noah_SMARTS/SMARTS/smarts/core/provider.py
78,79
49,112
filter
ProviderState
80,89
79,89
@dataclass class ProviderState: """State information from a provider.""" actors: List[ActorState] = field(default_factory=list) dt: Optional[float] = None # most Providers can leave this blank def merge(self, other: ProviderState): """Merge state with another provider's state.""" our_...
@dataclass class ProviderState: """State information from a provider.""" actors: List[ActorState] = field(default_factory=list) dt: Optional[float] = None # most Providers can leave this blank def merge(self, other: ProviderState): """Merge state with another provider's state.""" our_...
provider_actor_ids = [a.actor_id for a in self.actors] for a_id in actor_ids: try: index = provider_actor_ids.index(a_id) del provider_actor_ids[index] del self.actors[index] except ValueError: continue
"""Filter actor states down to the given actors.""" provider_actor_ids = [a.actor_id for a in self.actors] for a_id in actor_ids: try: index = provider_actor_ids.index(a_id) del provider_actor_ids[index] del self.actors[index] ...
22
661
93
754
# Copyright (C) 2020. Huawei Technologies Co., Ltd. All rights reserved. # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal # in the Software without restriction, including without limitation the rights # to us...
# Copyright (C) 2020. Huawei Technologies Co., Ltd. All rights reserved. # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal # in the Software without restriction, including without limitation the rights # to us...
47,854
/home/hieuvd/dung_repo/raw/stars_03/huawei-noah_SMARTS/SMARTS
/home/hieuvd/dung_repo/raw/stars_03/huawei-noah_SMARTS/SMARTS/smarts/core/renderer_base.py
60,62
54,108
wait_for_ram_image
OffscreenCamera
63,73
62,73
@dataclass class OffscreenCamera(metaclass=ABCMeta): """A camera used for rendering images to a graphics buffer.""" renderer: RendererBase @abstractmethod def wait_for_ram_image(self, img_format: str, retries=100): FILL_FUNC_BODY @abstractmethod def update(self, *args, **kwargs): """Upd...
@dataclass class OffscreenCamera(metaclass=ABCMeta): """A camera used for rendering images to a graphics buffer.""" renderer: RendererBase @abstractmethod def wait_for_ram_image(self, img_format: str, retries=100): """Attempt to acquire a graphics buffer.""" FILL_FUNC_BODY @abstractmethod ...
# Rarely, we see dropped frames where an image is not available # for our observation calculations. # # We've seen this happen fairly reliable when we are initializing # a multi-agent + multi-instance simulation. # # To deal with this, we can try to force a render...
"""Attempt to acquire a graphics buffer.""" # Rarely, we see dropped frames where an image is not available # for our observation calculations. # # We've seen this happen fairly reliable when we are initializing # a multi-agent + multi-instance simulation. # ...
69
340
115
455
# Copyright (C) 2020. Huawei Technologies Co., Ltd. All rights reserved. # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal # in the Software without restriction, including without limitation the rights # to us...
# Copyright (C) 2020. Huawei Technologies Co., Ltd. All rights reserved. # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal # in the Software without restriction, including without limitation the rights # to us...
47,855
/home/hieuvd/dung_repo/raw/stars_03/huawei-noah_SMARTS/SMARTS
/home/hieuvd/dung_repo/raw/stars_03/huawei-noah_SMARTS/SMARTS/smarts/core/renderer_base.py
195,197
165,281
setup
RendererBase
198,200
197,200
class RendererBase(metaclass=ABCMeta): """The base class for rendering Returns: RendererBase: """ @property @abstractmethod def id(self): """The id of the simulation rendered.""" raise NotImplementedError @property @abstractmethod def is_setup(self) -> bool...
class RendererBase(metaclass=ABCMeta): """The base class for rendering Returns: RendererBase: """ @property @abstractmethod def id(self): """The id of the simulation rendered.""" raise NotImplementedError @property @abstractmethod def is_setup(self) -> bool...
raise NotImplementedError
"""Initialize this renderer.""" raise NotImplementedError
2
879
11
890
# Copyright (C) 2020. Huawei Technologies Co., Ltd. All rights reserved. # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal # in the Software without restriction, including without limitation the rights # to us...
# Copyright (C) 2020. Huawei Technologies Co., Ltd. All rights reserved. # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal # in the Software without restriction, including without limitation the rights # to us...
47,859
/home/hieuvd/dung_repo/raw/stars_03/huawei-noah_SMARTS/SMARTS
/home/hieuvd/dung_repo/raw/stars_03/huawei-noah_SMARTS/SMARTS/smarts/core/sensor.py
175,176
115,200
_follow_actor
CameraSensor
176,185
176,185
class CameraSensor(Sensor): """The base for a sensor that renders images.""" def __init__( self, vehicle_state: VehicleState, renderer: RendererBase, name: str, mask: int, width: int, height: int, resolution: float, build_camera: bool = Tr...
class CameraSensor(Sensor): """The base for a sensor that renders images.""" def __init__( self, vehicle_state: VehicleState, renderer: RendererBase, name: str, mask: int, width: int, height: int, resolution: float, build_camera: bool = Tr...
if not renderer: return camera = renderer.camera_for_id(self._camera_name) pose = actor_state.get_pose() dimensions = actor_state.get_dimensions() if pose == None or dimensions == None: return camera.update(pose, dimensions.height + 10)
if not renderer: return camera = renderer.camera_for_id(self._camera_name) pose = actor_state.get_pose() dimensions = actor_state.get_dimensions() if pose == None or dimensions == None: return camera.update(pose, dimensions.height + 10)
26
671
95
766
# MIT License # # Copyright (C) 2023. Huawei Technologies Co., Ltd. All rights reserved. # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal # in the Software without restriction, including without limitation th...
# MIT License # # Copyright (C) 2023. Huawei Technologies Co., Ltd. All rights reserved. # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal # in the Software without restriction, including without limitation th...
47,860
/home/hieuvd/dung_repo/raw/stars_03/huawei-noah_SMARTS/SMARTS
/home/hieuvd/dung_repo/raw/stars_03/huawei-noah_SMARTS/SMARTS/smarts/core/sensor.py
476,477
439,585
has_required
CustomRenderSensor
477,485
477,485
class CustomRenderSensor(CameraSensor): """Defines a configurable image sensor.""" def __init__( self, vehicle_state: VehicleState, width: int, height: int, resolution: float, renderer: RendererBase, fragment_shader_path: str, render_dependencies:...
class CustomRenderSensor(CameraSensor): """Defines a configurable image sensor.""" def __init__( self, vehicle_state: VehicleState, width: int, height: int, resolution: float, renderer: RendererBase, fragment_shader_path: str, render_dependencies:...
if dependency_name == required_name: if sensor: return True raise UserWarning( f"Custom render depency requires `{d.name}` but the sensor is not attached in the interface." ) return False
if dependency_name == required_name: if sensor: return True raise UserWarning( f"Custom render depency requires `{d.name}` but the sensor is not attached in the interface." ) return False
27
1,441
68
1,509
# MIT License # # Copyright (C) 2023. Huawei Technologies Co., Ltd. All rights reserved. # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal # in the Software without restriction, including without limitation th...
# MIT License # # Copyright (C) 2023. Huawei Technologies Co., Ltd. All rights reserved. # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal # in the Software without restriction, including without limitation th...
47,861
/home/hieuvd/dung_repo/raw/stars_03/huawei-noah_SMARTS/SMARTS
/home/hieuvd/dung_repo/raw/stars_03/huawei-noah_SMARTS/SMARTS/smarts/core/sensor.py
656,662
628,681
distance_travelled
DrivenPathSensor
663,681
662,681
class DrivenPathSensor(Sensor): """Tracks the driven path as a series of positions (regardless if the vehicle is following the route or not). For performance reasons it only keeps the last N=max_path_length path segments. """ def __init__(self, max_path_length: int = 500): self._driven_path...
class DrivenPathSensor(Sensor): """Tracks the driven path as a series of positions (regardless if the vehicle is following the route or not). For performance reasons it only keeps the last N=max_path_length path segments. """ def __init__(self, max_path_length: int = 500): self._driven_path...
if last_n_seconds is None and last_n_steps is None: raise ValueError("Either last N seconds or last N steps must be provided") if last_n_steps is not None: n = last_n_steps + 1 # to factor in the current step we're on filtered_pos = [x.position for x in self._driven...
"""Find the amount of distance travelled over the last # of seconds XOR steps""" if last_n_seconds is None and last_n_steps is None: raise ValueError("Either last N seconds or last N steps must be provided") if last_n_steps is not None: n = last_n_steps + 1 # to factor ...
96
386
267
653
# MIT License # # Copyright (C) 2023. Huawei Technologies Co., Ltd. All rights reserved. # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal # in the Software without restriction, including without limitation th...
# MIT License # # Copyright (C) 2023. Huawei Technologies Co., Ltd. All rights reserved. # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal # in the Software without restriction, including without limitation th...
47,862
/home/hieuvd/dung_repo/raw/stars_03/huawei-noah_SMARTS/SMARTS
/home/hieuvd/dung_repo/raw/stars_03/huawei-noah_SMARTS/SMARTS/smarts/core/sensor.py
971,973
956,976
mutable
LanePositionSensor
973,976
973,976
class LanePositionSensor(Sensor): """Tracks lane-relative RefLine (Frenet) coordinates.""" def __init__(self): pass def __call__(self, lane: RoadMap.Lane, vehicle_state: VehicleState): return lane.to_lane_coord(vehicle_state.pose.point) def __eq__(self, __value: object) -> bool: ...
class LanePositionSensor(Sensor): """Tracks lane-relative RefLine (Frenet) coordinates.""" def __init__(self): pass def __call__(self, lane: RoadMap.Lane, vehicle_state: VehicleState): return lane.to_lane_coord(vehicle_state.pose.point) def __eq__(self, __value: object) -> bool: ...
return False
return False
2
153
9
162
# MIT License # # Copyright (C) 2023. Huawei Technologies Co., Ltd. All rights reserved. # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal # in the Software without restriction, including without limitation th...
# MIT License # # Copyright (C) 2023. Huawei Technologies Co., Ltd. All rights reserved. # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal # in the Software without restriction, including without limitation th...
47,863
/home/hieuvd/dung_repo/raw/stars_03/huawei-noah_SMARTS/SMARTS
/home/hieuvd/dung_repo/raw/stars_03/huawei-noah_SMARTS/SMARTS/smarts/core/sensor.py
617,619
585,622
serializable
LidarSensor
619,622
619,622
class LidarSensor(Sensor): """A lidar sensor.""" def __init__( self, vehicle_state: VehicleState, sensor_params: Optional[SensorParams] = None, lidar_offset=(0, 0, 1), ): self._lidar_offset = np.array(lidar_offset) self._lidar = Lidar( vehicle_st...
class LidarSensor(Sensor): """A lidar sensor.""" def __init__( self, vehicle_state: VehicleState, sensor_params: Optional[SensorParams] = None, lidar_offset=(0, 0, 1), ): self._lidar_offset = np.array(lidar_offset) self._lidar = Lidar( vehicle_st...
return False
return False
2
351
9
360
# MIT License # # Copyright (C) 2023. Huawei Technologies Co., Ltd. All rights reserved. # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal # in the Software without restriction, including without limitation th...
# MIT License # # Copyright (C) 2023. Huawei Technologies Co., Ltd. All rights reserved. # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal # in the Software without restriction, including without limitation th...
47,864
/home/hieuvd/dung_repo/raw/stars_03/huawei-noah_SMARTS/SMARTS
/home/hieuvd/dung_repo/raw/stars_03/huawei-noah_SMARTS/SMARTS/smarts/core/sensor.py
800,802
773,805
mutable
NeighborhoodVehiclesSensor
802,805
802,805
class NeighborhoodVehiclesSensor(Sensor): """Detects other vehicles around the sensor equipped vehicle.""" def __init__(self, radius: Optional[float] = None): self._radius = radius @property def radius(self) -> float: """Radius to check for nearby vehicles.""" return self._radi...
class NeighborhoodVehiclesSensor(Sensor): """Detects other vehicles around the sensor equipped vehicle.""" def __init__(self, radius: Optional[float] = None): self._radius = radius @property def radius(self) -> float: """Radius to check for nearby vehicles.""" return self._radi...
return False
return False
2
259
9
268
# MIT License # # Copyright (C) 2023. Huawei Technologies Co., Ltd. All rights reserved. # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal # in the Software without restriction, including without limitation th...
# MIT License # # Copyright (C) 2023. Huawei Technologies Co., Ltd. All rights reserved. # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal # in the Software without restriction, including without limitation th...
47,865
/home/hieuvd/dung_repo/raw/stars_03/huawei-noah_SMARTS/SMARTS
/home/hieuvd/dung_repo/raw/stars_03/huawei-noah_SMARTS/SMARTS/smarts/core/sensor.py
401,402
328,439
_follow_actor
OcclusionMapSensor
402,412
402,412
class OcclusionMapSensor(CameraSensor): """A sensor that demonstrates only the areas that can be seen by the vehicle.""" def __init__( self, vehicle_state: VehicleState, width: int, height: int, resolution: float, renderer: RendererBase, ogm_sensor: OGMSe...
class OcclusionMapSensor(CameraSensor): """A sensor that demonstrates only the areas that can be seen by the vehicle.""" def __init__( self, vehicle_state: VehicleState, width: int, height: int, resolution: float, renderer: RendererBase, ogm_sensor: OGMSe...
if not renderer: return for effect_name in self._effect_cameras: pose = actor_state.get_pose() dimensions = actor_state.get_dimensions() if pose == None or dimensions == None: continue camera = renderer.camera_for_id(effect_name...
if not renderer: return for effect_name in self._effect_cameras: pose = actor_state.get_pose() dimensions = actor_state.get_dimensions() if pose == None or dimensions == None: continue camera = renderer.camera_for_id(effect_name...
28
1,054
105
1,159
# MIT License # # Copyright (C) 2023. Huawei Technologies Co., Ltd. All rights reserved. # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal # in the Software without restriction, including without limitation th...
# MIT License # # Copyright (C) 2023. Huawei Technologies Co., Ltd. All rights reserved. # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal # in the Software without restriction, including without limitation th...
47,866
/home/hieuvd/dung_repo/raw/stars_03/huawei-noah_SMARTS/SMARTS
/home/hieuvd/dung_repo/raw/stars_03/huawei-noah_SMARTS/SMARTS/smarts/core/sensor.py
857,864
832,900
_paths_for_lane
RoadWaypointsSensor
865,889
864,889
class RoadWaypointsSensor(Sensor): """Detects waypoints from all paths nearby the vehicle.""" def __init__(self, horizon: int = 32): self._horizon = horizon def __call__( self, vehicle_state: VehicleState, plan: Plan, road_map: RoadMap ) -> RoadWaypoints: veh_pt = vehicle_state...
class RoadWaypointsSensor(Sensor): """Detects waypoints from all paths nearby the vehicle.""" def __init__(self, horizon: int = 32): self._horizon = horizon def __call__( self, vehicle_state: VehicleState, plan: Plan, road_map: RoadMap ) -> RoadWaypoints: veh_pt = vehicle_state...
# XXX: the following assumes waypoint spacing is 1m if overflow_offset is None: offset = lane.offset_along_lane(vehicle_state.pose.point) start_offset = offset - self._horizon else: start_offset = lane.length + overflow_offset incoming_lanes = lane.in...
"""Gets waypoint paths along the given lane.""" # XXX: the following assumes waypoint spacing is 1m if overflow_offset is None: offset = lane.offset_along_lane(vehicle_state.pose.point) start_offset = offset - self._horizon else: start_offset = lane.le...
76
424
314
738
# MIT License # # Copyright (C) 2023. Huawei Technologies Co., Ltd. All rights reserved. # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal # in the Software without restriction, including without limitation th...
# MIT License # # Copyright (C) 2023. Huawei Technologies Co., Ltd. All rights reserved. # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal # in the Software without restriction, including without limitation th...
47,867
/home/hieuvd/dung_repo/raw/stars_03/huawei-noah_SMARTS/SMARTS
/home/hieuvd/dung_repo/raw/stars_03/huawei-noah_SMARTS/SMARTS/smarts/core/sensor.py
109,111
89,115
serializable
Sensor
112,115
111,115
class Sensor(metaclass=abc.ABCMeta): """The sensor base class.""" def step(self, sim_frame: SimulationFrame, **kwargs): """Update sensor state.""" @abc.abstractmethod def teardown(self, **kwargs): """Clean up internal resources""" raise NotImplementedError @abc.abstractmet...
class Sensor(metaclass=abc.ABCMeta): """The sensor base class.""" def step(self, sim_frame: SimulationFrame, **kwargs): """Update sensor state.""" @abc.abstractmethod def teardown(self, **kwargs): """Clean up internal resources""" raise NotImplementedError @abc.abstractmet...
return True
"""If this sensor can be serialized.""" return True
2
196
9
205
# MIT License # # Copyright (C) 2023. Huawei Technologies Co., Ltd. All rights reserved. # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal # in the Software without restriction, including without limitation th...
# MIT License # # Copyright (C) 2023. Huawei Technologies Co., Ltd. All rights reserved. # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal # in the Software without restriction, including without limitation th...
47,868
/home/hieuvd/dung_repo/raw/stars_03/huawei-noah_SMARTS/SMARTS
/home/hieuvd/dung_repo/raw/stars_03/huawei-noah_SMARTS/SMARTS/smarts/core/sensor.py
1111,1118
1041,1132
_find_signals_ahead
SignalsSensor
1118,1130
1118,1130
class SignalsSensor(Sensor): """Reports state of traffic signals (lights) in the lanes ahead of vehicle.""" def __init__(self, lookahead: float): self._lookahead = lookahead def __eq__(self, __value: object) -> bool: return ( isinstance(__value, SignalsSensor) and self._lookahe...
class SignalsSensor(Sensor): """Reports state of traffic signals (lights) in the lanes ahead of vehicle.""" def __init__(self, lookahead: float): self._lookahead = lookahead def __eq__(self, __value: object) -> bool: return ( isinstance(__value, SignalsSensor) and self._lookahe...
if lookahead <= 0: return for ogl in lane.outgoing_lanes: if route and route.road_length > 0 and ogl.road not in route.roads: continue upcoming_signals += [ feat for feat in ogl.features if self._is_signal_type(feat) ] ...
if lookahead <= 0: return for ogl in lane.outgoing_lanes: if route and route.road_length > 0 and ogl.road not in route.roads: continue upcoming_signals += [ feat for feat in ogl.features if self._is_signal_type(feat) ] ...
40
794
133
927
# MIT License # # Copyright (C) 2023. Huawei Technologies Co., Ltd. All rights reserved. # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal # in the Software without restriction, including without limitation th...
# MIT License # # Copyright (C) 2023. Huawei Technologies Co., Ltd. All rights reserved. # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal # in the Software without restriction, including without limitation th...
47,869
/home/hieuvd/dung_repo/raw/stars_03/huawei-noah_SMARTS/SMARTS
/home/hieuvd/dung_repo/raw/stars_03/huawei-noah_SMARTS/SMARTS/smarts/core/sensor.py
746,753
681,773
_compute_additional_dist_travelled
TripMeterSensor
753,763
753,763
class TripMeterSensor(Sensor): """Tracks distance travelled along the route (in meters). Meters driven while off-route are not counted as part of the total. """ def __init__(self): self._wps_for_distance: List[Waypoint] = [] self._dist_travelled = 0.0 self._last_dist_travelled =...
class TripMeterSensor(Sensor): """Tracks distance travelled along the route (in meters). Meters driven while off-route are not counted as part of the total. """ def __init__(self): self._wps_for_distance: List[Waypoint] = [] self._dist_travelled = 0.0 self._last_dist_travelled =...
# old waypoint minus current ahead waypoint wp_disp_vec = new_waypoint.pos - recent_wp.pos # make unit vector wp_unit_vec = wp_disp_vec / (np.linalg.norm(wp_disp_vec) or 1) # vehicle position minus last vehicle position position_disp_vec = vehicle_position[:2] - last_vehi...
# old waypoint minus current ahead waypoint wp_disp_vec = new_waypoint.pos - recent_wp.pos # make unit vector wp_unit_vec = wp_disp_vec / (np.linalg.norm(wp_disp_vec) or 1) # vehicle position minus last vehicle position position_disp_vec = vehicle_position[:2] - last_vehi...
50
940
160
1,100
# MIT License # # Copyright (C) 2023. Huawei Technologies Co., Ltd. All rights reserved. # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal # in the Software without restriction, including without limitation th...
# MIT License # # Copyright (C) 2023. Huawei Technologies Co., Ltd. All rights reserved. # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal # in the Software without restriction, including without limitation th...
47,870
/home/hieuvd/dung_repo/raw/stars_03/huawei-noah_SMARTS/SMARTS
/home/hieuvd/dung_repo/raw/stars_03/huawei-noah_SMARTS/SMARTS/smarts/core/sensor.py
998,1000
976,1041
closest_point_on_lane
ViaSensor
1000,1003
1000,1003
class ViaSensor(Sensor): """Tracks collection of ViaPoint collectibles""" def __init__(self, lane_acquisition_range, speed_accuracy): self._consumed_via_points = set() self._acquisition_range = lane_acquisition_range self._speed_accuracy = speed_accuracy def __eq__(self, __value: o...
class ViaSensor(Sensor): """Tracks collection of ViaPoint collectibles""" def __init__(self, lane_acquisition_range, speed_accuracy): self._consumed_via_points = set() self._acquisition_range = lane_acquisition_range self._speed_accuracy = speed_accuracy def __eq__(self, __value: o...
lane = road_map.lane_by_id(lane_id) return lane.center_at_point(position)
lane = road_map.lane_by_id(lane_id) return lane.center_at_point(position)
5
685
37
722
# MIT License # # Copyright (C) 2023. Huawei Technologies Co., Ltd. All rights reserved. # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal # in the Software without restriction, including without limitation th...
# MIT License # # Copyright (C) 2023. Huawei Technologies Co., Ltd. All rights reserved. # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal # in the Software without restriction, including without limitation th...
47,871
/home/hieuvd/dung_repo/raw/stars_03/huawei-noah_SMARTS/SMARTS
/home/hieuvd/dung_repo/raw/stars_03/huawei-noah_SMARTS/SMARTS/smarts/core/sensor.py
827,829
805,832
mutable
WaypointsSensor
829,832
829,832
class WaypointsSensor(Sensor): """Detects waypoints leading forward along the vehicle plan.""" def __init__(self, lookahead: int = 32): self._lookahead = lookahead def __call__(self, vehicle_state: VehicleState, plan: Plan, road_map: RoadMap): return road_map.waypoint_paths( po...
class WaypointsSensor(Sensor): """Detects waypoints leading forward along the vehicle plan.""" def __init__(self, lookahead: int = 32): self._lookahead = lookahead def __call__(self, vehicle_state: VehicleState, plan: Plan, road_map: RoadMap): return road_map.waypoint_paths( po...
return False
return False
2
225
9
234
# MIT License # # Copyright (C) 2023. Huawei Technologies Co., Ltd. All rights reserved. # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal # in the Software without restriction, including without limitation th...
# MIT License # # Copyright (C) 2023. Huawei Technologies Co., Ltd. All rights reserved. # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal # in the Software without restriction, including without limitation th...
47,872
/home/hieuvd/dung_repo/raw/stars_03/huawei-noah_SMARTS/SMARTS
/home/hieuvd/dung_repo/raw/stars_03/huawei-noah_SMARTS/SMARTS/smarts/core/sensors/local_sensor_resolver.py
47,55
44,113
observe
LocalSensorResolver
55,95
55,95
class LocalSensorResolver(SensorResolver): """This implementation of the sensor resolver completes observations serially.""" def observe( self, sim_frame: SimulationFrame, sim_local_constants: SimulationLocalConstants, agent_ids: Set[str], renderer: Optional[RendererBase...
class LocalSensorResolver(SensorResolver): """This implementation of the sensor resolver completes observations serially.""" def observe( self, sim_frame: SimulationFrame, sim_local_constants: SimulationLocalConstants, agent_ids: Set[str], renderer: Optional[RendererBase...
# If render buffer sensors: # Call serializable sensors # Call unserializable non-render results # Collect unserializable non-render results # Collect serializable results # Update renderable sensor buffers # Render # Collect renderable sensors # e...
# If render buffer sensors: # Call serializable sensors # Call unserializable non-render results # Collect unserializable non-render results # Collect serializable results # Update renderable sensor buffers # Render # Collect renderable sensors # e...
119
311
425
736
# MIT License # # Copyright (C) 2023. Huawei Technologies Co., Ltd. All rights reserved. # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal # in the Software without restriction, including without limitation th...
# MIT License # # Copyright (C) 2023. Huawei Technologies Co., Ltd. All rights reserved. # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal # in the Software without restriction, including without limitation th...
47,873
/home/hieuvd/dung_repo/raw/stars_03/huawei-noah_SMARTS/SMARTS
/home/hieuvd/dung_repo/raw/stars_03/huawei-noah_SMARTS/SMARTS/smarts/core/sensors/parallel_sensor_resolver.py
61,69
51,230
observe
ParallelSensorResolver
82,138
69,138
class ParallelSensorResolver(SensorResolver): """This implementation of the sensor resolver completes observations in parallel.""" def __init__(self, process_count_override: Optional[int] = None) -> None: super().__init__() self._logger: logging.Logger = logging.getLogger("Sensors") sel...
class ParallelSensorResolver(SensorResolver): """This implementation of the sensor resolver completes observations in parallel.""" def __init__(self, process_count_override: Optional[int] = None) -> None: super().__init__() self._logger: logging.Logger = logging.getLogger("Sensors") sel...
observations, dones, updated_sensors = {}, {}, defaultdict(dict) num_spare_cpus = max(0, psutil.cpu_count(logical=False) - 1) used_processes = ( min( config()("core", "observation_workers", default=8, cast=int), num_spare_cpus, ) ...
"""Runs observations in parallel where possible. Args: sim_frame (SimulationFrame): The current state from the simulation. sim_local_constants (SimulationLocalConstants): The values that should stay the same for a simulation over a reset. ...
150
1,366
655
2,021
# MIT License # # Copyright (C) 2023. Huawei Technologies Co., Ltd. All rights reserved. # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal # in the Software without restriction, including without limitation th...
# MIT License # # Copyright (C) 2023. Huawei Technologies Co., Ltd. All rights reserved. # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal # in the Software without restriction, including without limitation th...
47,874
/home/hieuvd/dung_repo/raw/stars_03/huawei-noah_SMARTS/SMARTS
/home/hieuvd/dung_repo/raw/stars_03/huawei-noah_SMARTS/SMARTS/smarts/core/sensors/parallel_sensor_resolver.py
358,360
256,369
running
ProcessWorker
361,363
360,363
class ProcessWorker: """A utility class that defines a persistent worker which will continue to operate in the background.""" class WorkerDone: """The done signal for a worker.""" pass @dataclass class Request: """A request to made to the process worker""" id: Any ...
class ProcessWorker: """A utility class that defines a persistent worker which will continue to operate in the background.""" class WorkerDone: """The done signal for a worker.""" pass @dataclass class Request: """A request to made to the process worker""" id: Any ...
return self._proc is not None and self._proc.exitcode is None
"""If this current worker is still running.""" return self._proc is not None and self._proc.exitcode is None
9
978
21
999
# MIT License # # Copyright (C) 2023. Huawei Technologies Co., Ltd. All rights reserved. # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal # in the Software without restriction, including without limitation th...
# MIT License # # Copyright (C) 2023. Huawei Technologies Co., Ltd. All rights reserved. # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal # in the Software without restriction, including without limitation th...
47,875
/home/hieuvd/dung_repo/raw/stars_03/huawei-noah_SMARTS/SMARTS
/home/hieuvd/dung_repo/raw/stars_03/huawei-noah_SMARTS/SMARTS/smarts/core/sensors/parallel_sensor_resolver.py
382,384
376,406
_do_work
SensorsWorker
384,386
384,386
class SensorsWorker(ProcessWorker): """A worker for sensors.""" def __init__(self) -> None: super().__init__() @classmethod def _do_work(cls, state): FILL_FUNC_BODY @classmethod def _on_request(cls, state: Dict, request: ProcessWorker.Request) -> bool: assert request.data is Non...
class SensorsWorker(ProcessWorker): """A worker for sensors.""" def __init__(self) -> None: super().__init__() @classmethod def _do_work(cls, state): FILL_FUNC_BODY @classmethod def _on_request(cls, state: Dict, request: ProcessWorker.Request) -> bool: assert request.data is Non...
return cls.local(state=state)
return cls.local(state=state)
2
317
15
332
# MIT License # # Copyright (C) 2023. Huawei Technologies Co., Ltd. All rights reserved. # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal # in the Software without restriction, including without limitation th...
# MIT License # # Copyright (C) 2023. Huawei Technologies Co., Ltd. All rights reserved. # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal # in the Software without restriction, including without limitation th...
47,876
/home/hieuvd/dung_repo/raw/stars_03/huawei-noah_SMARTS/SMARTS
/home/hieuvd/dung_repo/raw/stars_03/huawei-noah_SMARTS/SMARTS/smarts/core/sensors/parallel_sensor_resolver.py
242,244
230,256
_serialize
WorkerKwargs
244,248
244,248
class WorkerKwargs: """Used to serialize arguments for a worker upfront.""" def __init__(self, **kwargs) -> None: self.kwargs = self._serialize(kwargs) def merged(self, o_worker_kwargs: "WorkerKwargs") -> "WorkerKwargs": """Merge two worker arguments and return a new copy.""" new =...
class WorkerKwargs: """Used to serialize arguments for a worker upfront.""" def __init__(self, **kwargs) -> None: self.kwargs = self._serialize(kwargs) def merged(self, o_worker_kwargs: "WorkerKwargs") -> "WorkerKwargs": """Merge two worker arguments and return a new copy.""" new =...
return { k: serializer.dumps(a) if a is not None else a for k, a in kwargs.items() }
return { k: serializer.dumps(a) if a is not None else a for k, a in kwargs.items() }
17
224
42
266
# MIT License # # Copyright (C) 2023. Huawei Technologies Co., Ltd. All rights reserved. # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal # in the Software without restriction, including without limitation th...
# MIT License # # Copyright (C) 2023. Huawei Technologies Co., Ltd. All rights reserved. # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal # in the Software without restriction, including without limitation th...
47,877
/home/hieuvd/dung_repo/raw/stars_03/huawei-noah_SMARTS/SMARTS
/home/hieuvd/dung_repo/raw/stars_03/huawei-noah_SMARTS/SMARTS/smarts/core/serialization/default.py
28,29
1,89
dumps
30,42
29,42
# MIT License # # Copyright (C) 2022. Huawei Technologies Co., Ltd. All rights reserved. # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal # in the Software without restriction, including without limitation th...
# MIT License # # Copyright (C) 2022. Huawei Technologies Co., Ltd. All rights reserved. # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal # in the Software without restriction, including without limitation th...
import cloudpickle _lazy_init() r = __o type_ = type(__o) # TODO: Add a formatter parameter instead of handling proxies internal to serialization proxy_func = _proxies.get(type_) if proxy_func: r = proxy_func(__o) return cloudpickle.dumps(r)
"""Serializes the given object.""" import cloudpickle _lazy_init() r = __o type_ = type(__o) # TODO: Add a formatter parameter instead of handling proxies internal to serialization proxy_func = _proxies.get(type_) if proxy_func: r = proxy_func(__o) return cloudpickle.dumps(r...
32
837
110
947
# MIT License # # Copyright (C) 2022. Huawei Technologies Co., Ltd. All rights reserved. # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal # in the Software without restriction, including without limitation th...
# MIT License # # Copyright (C) 2022. Huawei Technologies Co., Ltd. All rights reserved. # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal # in the Software without restriction, including without limitation th...
47,878
/home/hieuvd/dung_repo/raw/stars_03/huawei-noah_SMARTS/SMARTS
/home/hieuvd/dung_repo/raw/stars_03/huawei-noah_SMARTS/SMARTS/smarts/core/serialization/default.py
55,56
52,60
deproxy
Proxy
57,60
56,60
class Proxy: """Defines a proxy object used to facilitate serialization of a non-serializable object.""" def deproxy(self): FILL_FUNC_BODY
class Proxy: """Defines a proxy object used to facilitate serialization of a non-serializable object.""" def deproxy(self): """Convert the proxy back into the original object.""" FILL_FUNC_BODY
raise NotImplementedError()
"""Convert the proxy back into the original object.""" raise NotImplementedError()
2
57
14
71
# MIT License # # Copyright (C) 2022. Huawei Technologies Co., Ltd. All rights reserved. # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal # in the Software without restriction, including without limitation th...
# MIT License # # Copyright (C) 2022. Huawei Technologies Co., Ltd. All rights reserved. # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal # in the Software without restriction, including without limitation th...
47,879
/home/hieuvd/dung_repo/raw/stars_03/huawei-noah_SMARTS/SMARTS
/home/hieuvd/dung_repo/raw/stars_03/huawei-noah_SMARTS/SMARTS/smarts/core/serialization/default.py
70,71
60,79
deproxy
_SimulationLocalConstantsProxy
71,79
71,79
@dataclass(frozen=True) class _SimulationLocalConstantsProxy(Proxy): road_map_spec: Any road_map_hash: int def __eq__(self, __o: object) -> bool: if __o is None: return False return self.road_map_hash == getattr(__o, "road_map_hash") def deproxy(self): FILL_FUNC_BODY
@dataclass(frozen=True) class _SimulationLocalConstantsProxy(Proxy): road_map_spec: Any road_map_hash: int def __eq__(self, __o: object) -> bool: if __o is None: return False return self.road_map_hash == getattr(__o, "road_map_hash") def deproxy(self): FILL_FUNC_BODY
import smarts.sstudio.sstypes from smarts.core.simulation_local_constants import SimulationLocalConstants assert isinstance(self.road_map_spec, smarts.sstudio.sstypes.MapSpec) road_map, _ = self.road_map_spec.builder_fn(self.road_map_spec) return SimulationLocalConstants(road_ma...
import smarts.sstudio.sstypes from smarts.core.simulation_local_constants import SimulationLocalConstants assert isinstance(self.road_map_spec, smarts.sstudio.sstypes.MapSpec) road_map, _ = self.road_map_spec.builder_fn(self.road_map_spec) return SimulationLocalConstants(road_ma...
16
113
120
233
# MIT License # # Copyright (C) 2022. Huawei Technologies Co., Ltd. All rights reserved. # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal # in the Software without restriction, including without limitation th...
# MIT License # # Copyright (C) 2022. Huawei Technologies Co., Ltd. All rights reserved. # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal # in the Software without restriction, including without limitation th...
47,880
/home/hieuvd/dung_repo/raw/stars_03/huawei-noah_SMARTS/SMARTS
/home/hieuvd/dung_repo/raw/stars_03/huawei-noah_SMARTS/SMARTS/smarts/core/shape.py
82,88
1,166
line_offset_with_minimum_distance_to_point
90,104
88,104
# Copyright (C) 2022. Huawei Technologies Co., Ltd. All rights reserved. # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal # in the Software without restriction, including without limitation the rights # to us...
# Copyright (C) 2022. Huawei Technologies Co., Ltd. All rights reserved. # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal # in the Software without restriction, including without limitation the rights # to us...
p = point p1 = line_start p2 = line_end d = euclidean_distance(p1, p2) u = ((p[0] - p1[0]) * (p2[0] - p1[0])) + ((p[1] - p1[1]) * (p2[1] - p1[1])) if u < 0.0: return 0.0 if d == 0.0 or u > d * d: if perpendicular: return -1 return d return u / d
"""Return the offset from line (line_start, line_end) where the distance to point is minimal""" p = point p1 = line_start p2 = line_end d = euclidean_distance(p1, p2) u = ((p[0] - p1[0]) * (p2[0] - p1[0])) + ((p[1] - p1[1]) * (p2[1] - p1[1])) if u < 0.0: return 0.0 if d == 0....
56
1,763
156
1,919
# Copyright (C) 2022. Huawei Technologies Co., Ltd. All rights reserved. # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal # in the Software without restriction, including without limitation the rights # to us...
# Copyright (C) 2022. Huawei Technologies Co., Ltd. All rights reserved. # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal # in the Software without restriction, including without limitation the rights # to us...
47,881
/home/hieuvd/dung_repo/raw/stars_03/huawei-noah_SMARTS/SMARTS
/home/hieuvd/dung_repo/raw/stars_03/huawei-noah_SMARTS/SMARTS/smarts/core/signal_provider.py
60,61
30,122
setup
SignalProvider
61,82
61,82
class SignalProvider(Provider): """A SignalProvider manages traffic light signals.""" def __init__(self): self._my_signals: Dict[str, SignalState] = dict() # start with the default recovery flags... self._recovery_flags = super().recovery_flags self._road_map = None @proper...
class SignalProvider(Provider): """A SignalProvider manages traffic light signals.""" def __init__(self): self._my_signals: Dict[str, SignalState] = dict() # start with the default recovery flags... self._recovery_flags = super().recovery_flags self._road_map = None @proper...
self._road_map = scenario.road_map # we only need to control map signals that won't be controlled by other providers . # XXX: we assume that if there is a history provider, it will provide the signal state, # XXX: and if sumo traffic is supported then SumoTrafficSimulation is being use...
self._road_map = scenario.road_map # we only need to control map signals that won't be controlled by other providers . # XXX: we assume that if there is a history provider, it will provide the signal state, # XXX: and if sumo traffic is supported then SumoTrafficSimulation is being use...
92
739
324
1,063
# Copyright (C) 2022. Huawei Technologies Co., Ltd. All rights reserved. # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal # in the Software without restriction, including without limitation the rights # to us...
# Copyright (C) 2022. Huawei Technologies Co., Ltd. All rights reserved. # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal # in the Software without restriction, including without limitation the rights # to us...
47,882
/home/hieuvd/dung_repo/raw/stars_03/huawei-noah_SMARTS/SMARTS
/home/hieuvd/dung_repo/raw/stars_03/huawei-noah_SMARTS/SMARTS/smarts/core/signals.py
47,48
1,70
signal_state_to_color
49,59
48,59
# Copyright (C) 2022. Huawei Technologies Co., Ltd. All rights reserved. # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal # in the Software without restriction, including without limitation the rights # to us...
# Copyright (C) 2022. Huawei Technologies Co., Ltd. All rights reserved. # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal # in the Software without restriction, including without limitation the rights # to us...
if state == SignalLightState.STOP: return SceneColors.SignalStop elif state == SignalLightState.CAUTION: return SceneColors.SignalCaution elif state == SignalLightState.GO: return SceneColors.SignalGo else: return SceneColors.SignalUnknown
"""Maps a signal state to a color.""" if state == SignalLightState.STOP: return SceneColors.SignalStop elif state == SignalLightState.CAUTION: return SceneColors.SignalCaution elif state == SignalLightState.GO: return SceneColors.SignalGo else: return SceneColors.Sign...
21
658
100
758
# Copyright (C) 2022. Huawei Technologies Co., Ltd. All rights reserved. # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal # in the Software without restriction, including without limitation the rights # to us...
# Copyright (C) 2022. Huawei Technologies Co., Ltd. All rights reserved. # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal # in the Software without restriction, including without limitation the rights # to us...
47,883
/home/hieuvd/dung_repo/raw/stars_03/huawei-noah_SMARTS/SMARTS
/home/hieuvd/dung_repo/raw/stars_03/huawei-noah_SMARTS/SMARTS/smarts/core/tire_models.py
246,247
174,274
apply_tire_forces
LinearTireForces
248,274
247,274
class LinearTireForces(TireForces): """A linear forces implementation of a tire model.""" def _calculate_tire_forces(self, chassis, client, action): tire_angles = self._calculate_tire_angles(chassis, client, action) ( fl_slip_angle, fr_slip_angle, rl_slip_a...
class LinearTireForces(TireForces): """A linear forces implementation of a tire model.""" def _calculate_tire_forces(self, chassis, client, action): tire_angles = self._calculate_tire_angles(chassis, client, action) ( fl_slip_angle, fr_slip_angle, rl_slip_a...
wheel_index = [2, 4, 5, 6] wheel_positions = [ np.array(client.getLinkState(chassis.bullet_id, wheel_idx)[0]) for wheel_idx in wheel_index ] # Final Bounds for forces at wheels for cases # that the rise and fall filters are used at wheels. bounds ...
"""Applies linear tire forces""" wheel_index = [2, 4, 5, 6] wheel_positions = [ np.array(client.getLinkState(chassis.bullet_id, wheel_idx)[0]) for wheel_idx in wheel_index ] # Final Bounds for forces at wheels for cases # that the rise and fall fi...
67
925
279
1,204
# Copyright (C) 2020. Huawei Technologies Co., Ltd. All rights reserved. # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal # in the Software without restriction, including without limitation the rights # to us...
# Copyright (C) 2020. Huawei Technologies Co., Ltd. All rights reserved. # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal # in the Software without restriction, including without limitation the rights # to us...
47,884
/home/hieuvd/dung_repo/raw/stars_03/huawei-noah_SMARTS/SMARTS
/home/hieuvd/dung_repo/raw/stars_03/huawei-noah_SMARTS/SMARTS/smarts/core/tire_models.py
43,45
26,174
_calculate_slip_angles
TireForces
45,119
45,119
class TireForces: """Tire forces utility""" def __init__(self, stiffness, road_friction): self.c_alpha_front, self.c_alpha_rear, self.c_x_front, self.c_x_rear = stiffness self.road_friction = road_friction @staticmethod def _calculate_tire_angles(chassis, client, action): # Cu...
class TireForces: """Tire forces utility""" def __init__(self, stiffness, road_friction): self.c_alpha_front, self.c_alpha_rear, self.c_x_front, self.c_x_rear = stiffness self.road_friction = road_friction @staticmethod def _calculate_tire_angles(chassis, client, action): # Cu...
steering_angles_corners = [ -chassis.steering, -chassis.steering, 0, 0, ] slip_angles = np.zeros(4) relative_corner_vector = [ np.array( [ chassis.front_rear_axle_CG_distance[0], ...
steering_angles_corners = [ -chassis.steering, -chassis.steering, 0, 0, ] slip_angles = np.zeros(4) relative_corner_vector = [ np.array( [ chassis.front_rear_axle_CG_distance[0], ...
137
950
717
1,667
# Copyright (C) 2020. Huawei Technologies Co., Ltd. All rights reserved. # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal # in the Software without restriction, including without limitation the rights # to us...
# Copyright (C) 2020. Huawei Technologies Co., Ltd. All rights reserved. # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal # in the Software without restriction, including without limitation the rights # to us...
47,886
/home/hieuvd/dung_repo/raw/stars_03/huawei-noah_SMARTS/SMARTS
/home/hieuvd/dung_repo/raw/stars_03/huawei-noah_SMARTS/SMARTS/smarts/core/traffic_history.py
286,288
267,305
axle_start_position
TrafficHistoryVehicleWindow
289,292
288,292
class TrafficHistoryVehicleWindow(NamedTuple): """General information about a vehicle between a time window.""" vehicle_id: int vehicle_type: str vehicle_length: float vehicle_width: float vehicle_height: float start_position_x: float start_position_y...
class TrafficHistoryVehicleWindow(NamedTuple): """General information about a vehicle between a time window.""" vehicle_id: int vehicle_type: str vehicle_length: float vehicle_width: float vehicle_height: float start_position_x: float start_position_y...
hhx, hhy = radians_to_vec(self.start_heading) * (0.5 * self.vehicle_length) return [self.start_position_x + hhx, self.start_position_y + hhy]
"""The start position of the vehicle from the axle.""" hhx, hhy = radians_to_vec(self.start_heading) * (0.5 * self.vehicle_length) return [self.start_position_x + hhx, self.start_position_y + hhy]
15
340
67
407
# Copyright (C) 2020. Huawei Technologies Co., Ltd. All rights reserved. # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal # in the Software without restriction, including without limitation the rights # to us...
# Copyright (C) 2020. Huawei Technologies Co., Ltd. All rights reserved. # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal # in the Software without restriction, including without limitation the rights # to us...
47,888
/home/hieuvd/dung_repo/raw/stars_03/huawei-noah_SMARTS/SMARTS
/home/hieuvd/dung_repo/raw/stars_03/huawei-noah_SMARTS/SMARTS/smarts/core/traffic_provider.py
56,57
30,67
vehicle_dest_road
TrafficProvider
58,60
57,60
class TrafficProvider(Provider): """A TrafficProvider is a Provider that controls/owns a (sub)set of vehicles that all share the same action space.""" def reserve_traffic_location_for_vehicle( self, vehicle_id: str, reserved_location: Polygon, ): """Reserve an area aroun...
class TrafficProvider(Provider): """A TrafficProvider is a Provider that controls/owns a (sub)set of vehicles that all share the same action space.""" def reserve_traffic_location_for_vehicle( self, vehicle_id: str, reserved_location: Polygon, ): """Reserve an area aroun...
raise NotImplementedError
"""Get the final road_id in the route of the given vehicle.""" raise NotImplementedError
2
377
11
388
# Copyright (C) 2022. Huawei Technologies Co., Ltd. All rights reserved. # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal # in the Software without restriction, including without limitation the rights # to us...
# Copyright (C) 2022. Huawei Technologies Co., Ltd. All rights reserved. # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal # in the Software without restriction, including without limitation the rights # to us...
47,889
/home/hieuvd/dung_repo/raw/stars_03/huawei-noah_SMARTS/SMARTS
/home/hieuvd/dung_repo/raw/stars_03/huawei-noah_SMARTS/SMARTS/smarts/core/trap_manager.py
68,69
45,81
patience_expired
Trap
70,73
69,73
@dataclass class Trap: """Caches geometry and temporal information to use to capture actors for social agents""" geometry: Polygon """The trap area within which actors are considered for capture.""" mission: NavigationMission """The mission that this trap should assign the captured actor.""" ac...
@dataclass class Trap: """Caches geometry and temporal information to use to capture actors for social agents""" geometry: Polygon """The trap area within which actors are considered for capture.""" mission: NavigationMission """The mission that this trap should assign the captured actor.""" ac...
expiry_time = self.activation_time + self.patience return expiry_time < sim_time and not math.isclose(expiry_time, sim_time)
"""If the trap has expired and should no longer capture a vehicle.""" expiry_time = self.activation_time + self.patience return expiry_time < sim_time and not math.isclose(expiry_time, sim_time)
13
340
49
389
# Copyright (C) 2020. Huawei Technologies Co., Ltd. All rights reserved. # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal # in the Software without restriction, including without limitation the rights # to us...
# Copyright (C) 2020. Huawei Technologies Co., Ltd. All rights reserved. # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal # in the Software without restriction, including without limitation the rights # to us...
47,891
/home/hieuvd/dung_repo/raw/stars_03/huawei-noah_SMARTS/SMARTS
/home/hieuvd/dung_repo/raw/stars_03/huawei-noah_SMARTS/SMARTS/smarts/core/utils/cache.py
125,126
1,139
clear_cache
127,139
126,139
# Copyright (C) 2020. Huawei Technologies Co., Ltd. All rights reserved. # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal # in the Software without restriction, including without limitation the rights # to us...
# Copyright (C) 2020. Huawei Technologies Co., Ltd. All rights reserved. # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal # in the Software without restriction, including without limitation the rights # to us...
def _clear_caches(self): for key in self.__dict__: if key.startswith(_CACHE_KEY_PREFIX): _CacheCallable.external_clear_cache(self, key) @functools.wraps(func) def wrapper(self, *args, **kwargs): _clear_caches(self) return func(self, *args, **kwargs) ...
"""A decorator that clears `@cache` type caches.""" def _clear_caches(self): for key in self.__dict__: if key.startswith(_CACHE_KEY_PREFIX): _CacheCallable.external_clear_cache(self, key) @functools.wraps(func) def wrapper(self, *args, **kwargs): _clear_cach...
22
1,410
123
1,533
# Copyright (C) 2020. Huawei Technologies Co., Ltd. All rights reserved. # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal # in the Software without restriction, including without limitation the rights # to us...
# Copyright (C) 2020. Huawei Technologies Co., Ltd. All rights reserved. # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal # in the Software without restriction, including without limitation the rights # to us...
47,892
/home/hieuvd/dung_repo/raw/stars_03/huawei-noah_SMARTS/SMARTS
/home/hieuvd/dung_repo/raw/stars_03/huawei-noah_SMARTS/SMARTS/smarts/core/utils/cache.py
107,109
81,113
external_clear_cache
_CacheCallable
110,113
109,113
class _CacheCallable: def __init__(self, cache_key: str, method: FunctionType, instance: Any): self._method = method self._instance = instance self._cache = instance.__dict__ self._cache_key = cache_key self._lock = RLock() def __call__(self, *args, **kwargs) -> Any: ...
class _CacheCallable: def __init__(self, cache_key: str, method: FunctionType, instance: Any): self._method = method self._instance = instance self._cache = instance.__dict__ self._cache_key = cache_key self._lock = RLock() def __call__(self, *args, **kwargs) -> Any: ...
setattr(instance, cache_key, {})
"""Clears the cache on the given instance.""" setattr(instance, cache_key, {})
3
310
18
328
# Copyright (C) 2020. Huawei Technologies Co., Ltd. All rights reserved. # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal # in the Software without restriction, including without limitation the rights # to us...
# Copyright (C) 2020. Huawei Technologies Co., Ltd. All rights reserved. # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal # in the Software without restriction, including without limitation the rights # to us...
47,893
/home/hieuvd/dung_repo/raw/stars_03/huawei-noah_SMARTS/SMARTS
/home/hieuvd/dung_repo/raw/stars_03/huawei-noah_SMARTS/SMARTS/smarts/core/utils/class_factory.py
32,33
1,172
is_valid_locator
34,38
33,38
# Copyright (C) 2020. Huawei Technologies Co., Ltd. All rights reserved. # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal # in the Software without restriction, including without limitation the rights # to us...
# Copyright (C) 2020. Huawei Technologies Co., Ltd. All rights reserved. # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal # in the Software without restriction, including without limitation the rights # to us...
# Handle non-URL-based agents (e.g. open_agent-v0) return NAME_CONSTRAINT_REGEX.search(locator)
"""Validate the given locator.""" # Handle non-URL-based agents (e.g. open_agent-v0) return NAME_CONSTRAINT_REGEX.search(locator)
8
1,798
45
1,843
# Copyright (C) 2020. Huawei Technologies Co., Ltd. All rights reserved. # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal # in the Software without restriction, including without limitation the rights # to us...
# Copyright (C) 2020. Huawei Technologies Co., Ltd. All rights reserved. # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal # in the Software without restriction, including without limitation the rights # to us...
47,894
/home/hieuvd/dung_repo/raw/stars_03/huawei-noah_SMARTS/SMARTS
/home/hieuvd/dung_repo/raw/stars_03/huawei-noah_SMARTS/SMARTS/smarts/core/utils/class_factory.py
63,64
50,87
make
ClassFactory
67,79
64,79
class ClassFactory: """A named factory that can preconfigure generation of objects.""" def __init__(self, name, entrypoint=None, **kwargs): self.name = name self.entrypoint = entrypoint self._kwargs = kwargs if self.entrypoint is None: raise EnvironmentError( ...
class ClassFactory: """A named factory that can preconfigure generation of objects.""" def __init__(self, name, entrypoint=None, **kwargs): self.name = name self.entrypoint = entrypoint self._kwargs = kwargs if self.entrypoint is None: raise EnvironmentError( ...
if self.entrypoint is None: raise AttributeError(f"Entry-point does not exist for name `{self.name}`") _kwargs = self._kwargs.copy() _kwargs.update(kwargs) if callable(self.entrypoint): instance = self.entrypoint(**_kwargs) else: type_spec = fi...
"""Provides an object from the entrypoint. Overriding predefined keyword arguments with the given keyword arguments. """ if self.entrypoint is None: raise AttributeError(f"Entry-point does not exist for name `{self.name}`") _kwargs = self._kwargs.copy() _kwarg...
30
213
130
343
# Copyright (C) 2020. Huawei Technologies Co., Ltd. All rights reserved. # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal # in the Software without restriction, including without limitation the rights # to us...
# Copyright (C) 2020. Huawei Technologies Co., Ltd. All rights reserved. # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal # in the Software without restriction, including without limitation the rights # to us...
47,895
/home/hieuvd/dung_repo/raw/stars_03/huawei-noah_SMARTS/SMARTS
/home/hieuvd/dung_repo/raw/stars_03/huawei-noah_SMARTS/SMARTS/smarts/core/utils/class_factory.py
93,94
87,172
register
ClassRegister
100,107
94,107
class ClassRegister: """A listing of key named class factories.""" def __init__(self): self.index: Dict[str, ClassFactory] = {} def register(self, name, entry_point=None, **kwargs): FILL_FUNC_BODY def find_factory(self, locator): """Locates a factory given a locator.""" self._ra...
class ClassRegister: """A listing of key named class factories.""" def __init__(self): self.index: Dict[str, ClassFactory] = {} def register(self, name, entry_point=None, **kwargs): """Registers a new factory with the given locator as the key. Args: locator: The key val...
if name in self.index: warnings.warn( f"Resident named '{name}' was already registered. Overwriting existing registration." ) self.index[name] = ClassFactory(name, entry_point, **kwargs)
"""Registers a new factory with the given locator as the key. Args: locator: The key value of the factory. entry_point: The factory method. kwargs: Predefined arguments to the factory method. """ if name in self.index: warnings.warn( ...
20
790
68
858
# Copyright (C) 2020. Huawei Technologies Co., Ltd. All rights reserved. # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal # in the Software without restriction, including without limitation the rights # to us...
# Copyright (C) 2020. Huawei Technologies Co., Ltd. All rights reserved. # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal # in the Software without restriction, including without limitation the rights # to us...
47,898
/home/hieuvd/dung_repo/raw/stars_03/huawei-noah_SMARTS/SMARTS
/home/hieuvd/dung_repo/raw/stars_03/huawei-noah_SMARTS/SMARTS/smarts/core/utils/core_math.py
36,38
27,56
from_list
CubicPolynomial
44,51
38,51
@dataclass(frozen=True) class CubicPolynomial: """A cubic polynomial.""" a: float b: float c: float d: float @classmethod def from_list(cls, coefficients: List[float]): FILL_FUNC_BODY def eval(self, ds: float) -> float: """Evaluate a value along the polynomial.""" return...
@dataclass(frozen=True) class CubicPolynomial: """A cubic polynomial.""" a: float b: float c: float d: float @classmethod def from_list(cls, coefficients: List[float]): """Generates CubicPolynomial. Args: coefficients: The list of coefficients [a, b, c, d] ...
return cls( a=coefficients[0], b=coefficients[1], c=coefficients[2], d=coefficients[3], )
"""Generates CubicPolynomial. Args: coefficients: The list of coefficients [a, b, c, d] Returns: A new CubicPolynomial. """ return cls( a=coefficients[0], b=coefficients[1], c=coefficients[2], d=coefficients[...
7
190
57
247
# Copyright (C) 2020. Huawei Technologies Co., Ltd. All rights reserved. # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal # in the Software without restriction, including without limitation the rights # to us...
# Copyright (C) 2020. Huawei Technologies Co., Ltd. All rights reserved. # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal # in the Software without restriction, including without limitation the rights # to us...
47,899
/home/hieuvd/dung_repo/raw/stars_03/huawei-noah_SMARTS/SMARTS
/home/hieuvd/dung_repo/raw/stars_03/huawei-noah_SMARTS/SMARTS/smarts/core/utils/custom_exceptions.py
49,51
46,57
required_to
OpenDriveException
52,57
51,57
class OpenDriveException(Exception): """An exception raised if `opendrive` utilities are required but not available.""" @classmethod def required_to(cls, thing): FILL_FUNC_BODY
class OpenDriveException(Exception): """An exception raised if `opendrive` utilities are required but not available.""" @classmethod def required_to(cls, thing): """Generate an instance of this exception that describes what can be done to remove the exception""" FILL_FUNC_BODY
return cls( f"""OpenDRIVE Package is required to {thing}. You may not have installed the [opendrive] dependencies required to run the OpenDRIVE dependent example. Install them first using the command `pip install -e .[opendrive]` at the source directory to install the n...
"""Generate an instance of this exception that describes what can be done to remove the exception""" return cls( f"""OpenDRIVE Package is required to {thing}. You may not have installed the [opendrive] dependencies required to run the OpenDRIVE dependent example. ...
43
77
82
159
# Copyright (C) 2020. Huawei Technologies Co., Ltd. All rights reserved. # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal # in the Software without restriction, including without limitation the rights # to us...
# Copyright (C) 2020. Huawei Technologies Co., Ltd. All rights reserved. # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal # in the Software without restriction, including without limitation the rights # to us...
47,900
/home/hieuvd/dung_repo/raw/stars_03/huawei-noah_SMARTS/SMARTS
/home/hieuvd/dung_repo/raw/stars_03/huawei-noah_SMARTS/SMARTS/smarts/core/utils/custom_exceptions.py
36,38
33,46
required_to
RayException
39,46
38,46
class RayException(Exception): """An exception raised if ray package is required but not available.""" @classmethod def required_to(cls, thing): FILL_FUNC_BODY
class RayException(Exception): """An exception raised if ray package is required but not available.""" @classmethod def required_to(cls, thing): """Generate a `RayException` requiring a render to do `thing`.""" FILL_FUNC_BODY
return cls( f"""Ray Package is required to {thing}. You may not have installed the [rllib] or [train] dependencies required to run the ray dependent example. Install them first using the command `pip install -e .[train, rllib]` at the source directory to install the pac...
"""Generate a `RayException` requiring a render to do `thing`.""" return cls( f"""Ray Package is required to {thing}. You may not have installed the [rllib] or [train] dependencies required to run the ray dependent example. Install them first using the command `...
46
69
103
172
# Copyright (C) 2020. Huawei Technologies Co., Ltd. All rights reserved. # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal # in the Software without restriction, including without limitation the rights # to us...
# Copyright (C) 2020. Huawei Technologies Co., Ltd. All rights reserved. # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal # in the Software without restriction, including without limitation the rights # to us...
47,901
/home/hieuvd/dung_repo/raw/stars_03/huawei-noah_SMARTS/SMARTS
/home/hieuvd/dung_repo/raw/stars_03/huawei-noah_SMARTS/SMARTS/smarts/core/utils/custom_exceptions.py
25,27
22,33
required_to
RendererException
28,33
27,33
class RendererException(Exception): """An exception raised if a renderer is required but not available.""" @classmethod def required_to(cls, thing: str) -> "RendererException": FILL_FUNC_BODY
class RendererException(Exception): """An exception raised if a renderer is required but not available.""" @classmethod def required_to(cls, thing: str) -> "RendererException": """Generate a `RenderException` requiring a render to do `thing`.""" FILL_FUNC_BODY
return cls( f"""A renderer is required to {thing}. You may not have installed the [camera-obs] dependencies required to render the camera sensor observations. Install them first using the command `pip install -e .[camera-obs]` at the source directory.""" )
"""Generate a `RenderException` requiring a render to do `thing`.""" return cls( f"""A renderer is required to {thing}. You may not have installed the [camera-obs] dependencies required to render the camera sensor observations. Install them first using the command `pip install -e .[camera-ob...
38
79
74
153
# Copyright (C) 2020. Huawei Technologies Co., Ltd. All rights reserved. # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal # in the Software without restriction, including without limitation the rights # to us...
# Copyright (C) 2020. Huawei Technologies Co., Ltd. All rights reserved. # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal # in the Software without restriction, including without limitation the rights # to us...
47,904
/home/hieuvd/dung_repo/raw/stars_03/huawei-noah_SMARTS/SMARTS
/home/hieuvd/dung_repo/raw/stars_03/huawei-noah_SMARTS/SMARTS/smarts/core/utils/episodes.py
206,207
200,218
continues
Episode
208,218
207,218
class Episode: """An episode recording object""" def __init__(self, episodes: Episodes): self._episodes = episodes def continues(self, observation, reward, terminated, truncated, info) -> bool: FILL_FUNC_BODY
class Episode: """An episode recording object""" def __init__(self, episodes: Episodes): self._episodes = episodes def continues(self, observation, reward, terminated, truncated, info) -> bool: """Determine if the current episode can continue.""" FILL_FUNC_BODY
self._episodes.current_step += 1 if self._episodes.current_step >= self._episodes.max_steps: return False if isinstance(terminated, dict): return not terminated.get("__all__", all(terminated.values())) return not terminated
"""Determine if the current episode can continue.""" self._episodes.current_step += 1 if self._episodes.current_step >= self._episodes.max_steps: return False if isinstance(terminated, dict): return not terminated.get("__all__", all(terminated.values())) ...
19
84
91
175
# Copyright (C) 2020. Huawei Technologies Co., Ltd. All rights reserved. # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal # in the Software without restriction, including without limitation the rights # to us...
# Copyright (C) 2020. Huawei Technologies Co., Ltd. All rights reserved. # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal # in the Software without restriction, including without limitation the rights # to us...
47,905
/home/hieuvd/dung_repo/raw/stars_03/huawei-noah_SMARTS/SMARTS
/home/hieuvd/dung_repo/raw/stars_03/huawei-noah_SMARTS/SMARTS/smarts/core/utils/episodes.py
144,145
102,175
record_step
EpisodeLog
146,166
145,166
@dataclass class EpisodeLog: """An episode logging tool.""" index: int = 0 start_time: float = field(default_factory=lambda: time.time()) fixed_timestep_sec: float = 0 scores: dict = field(default_factory=lambda: defaultdict(lambda: 0)) steps: int = 0 scenario_map: str = "" scenario_tra...
@dataclass class EpisodeLog: """An episode logging tool.""" index: int = 0 start_time: float = field(default_factory=lambda: time.time()) fixed_timestep_sec: float = 0 scores: dict = field(default_factory=lambda: defaultdict(lambda: 0)) steps: int = 0 scenario_map: str = "" scenario_tra...
self.steps += 1 if not isinstance(terminateds, dict): ( observations, rewards, terminateds, truncateds, infos, ) = self._convert_to_dict( observations, rewards, terminateds, truncated...
"""Record a step end.""" self.steps += 1 if not isinstance(terminateds, dict): ( observations, rewards, terminateds, truncateds, infos, ) = self._convert_to_dict( observations...
53
591
194
785
# Copyright (C) 2020. Huawei Technologies Co., Ltd. All rights reserved. # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal # in the Software without restriction, including without limitation the rights # to us...
# Copyright (C) 2020. Huawei Technologies Co., Ltd. All rights reserved. # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal # in the Software without restriction, including without limitation the rights # to us...
47,906
/home/hieuvd/dung_repo/raw/stars_03/huawei-noah_SMARTS/SMARTS
/home/hieuvd/dung_repo/raw/stars_03/huawei-noah_SMARTS/SMARTS/smarts/core/utils/episodes.py
50,51
30,102
_write_row
EpisodeLogs
51,75
51,75
class EpisodeLogs: """An episode logging utility.""" def __init__(self, col_width, total_episodes: Union[str, int] = "?") -> None: self._col_width = col_width self._table = self.context(col_width) self._current_episode: Optional[EpisodeLog] = None self._total_episodes = total_ep...
class EpisodeLogs: """An episode logging utility.""" def __init__(self, col_width, total_episodes: Union[str, int] = "?") -> None: self._col_width = col_width self._table = self.context(col_width) self._current_episode: Optional[EpisodeLog] = None self._total_episodes = total_ep...
assert isinstance(self._current_episode, EpisodeLog) e = self._current_episode row = ( f"{e.index + 1}/{self._total_episodes}", f"{e.sim2wall_ratio:.2f}", e.steps, f"{e.steps_per_second:.2f}", os.path.basename(e.scenario_map)[: self._co...
assert isinstance(self._current_episode, EpisodeLog) e = self._current_episode row = ( f"{e.index + 1}/{self._total_episodes}", f"{e.sim2wall_ratio:.2f}", e.steps, f"{e.steps_per_second:.2f}", os.path.basename(e.scenario_map)[: self._co...
61
397
307
704
# Copyright (C) 2020. Huawei Technologies Co., Ltd. All rights reserved. # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal # in the Software without restriction, including without limitation the rights # to us...
# Copyright (C) 2020. Huawei Technologies Co., Ltd. All rights reserved. # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal # in the Software without restriction, including without limitation the rights # to us...
47,908
/home/hieuvd/dung_repo/raw/stars_03/huawei-noah_SMARTS/SMARTS
/home/hieuvd/dung_repo/raw/stars_03/huawei-noah_SMARTS/SMARTS/smarts/core/utils/frame_monitor.py
68,69
47,82
stop
FrameMonitor
72,82
69,82
class FrameMonitor: """A tool for requiring a minimum frame rate.""" def __init__(self, desired_fps=10): self._desired_fps = int(desired_fps) self._maximum_frame_time_ms = round(1 / self._desired_fps, 3) * 1000 self._start_time_ms = None def __enter__(self): self.start() ...
class FrameMonitor: """A tool for requiring a minimum frame rate.""" def __init__(self, desired_fps=10): self._desired_fps = int(desired_fps) self._maximum_frame_time_ms = round(1 / self._desired_fps, 3) * 1000 self._start_time_ms = None def __enter__(self): self.start() ...
if self._start_time_ms is None: print("The monitor has not started yet.") return -1 now = self._time_now() delta = now - self._start_time_ms actual_fps = round(1000 / delta, 2) if actual_fps < self._desired_fps: raise FramerateException.below_...
"""Ends timing the frame. Throws an exception if the frame duration is greater than desired fps. """ if self._start_time_ms is None: print("The monitor has not started yet.") return -1 now = self._time_now() delta = now - self._start_time_ms ...
35
241
128
369
# MIT License # # Copyright (C) 2021. Huawei Technologies Co., Ltd. All rights reserved. # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal # in the Software without restriction, including without limitation th...
# MIT License # # Copyright (C) 2021. Huawei Technologies Co., Ltd. All rights reserved. # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal # in the Software without restriction, including without limitation th...
47,909
/home/hieuvd/dung_repo/raw/stars_03/huawei-noah_SMARTS/SMARTS
/home/hieuvd/dung_repo/raw/stars_03/huawei-noah_SMARTS/SMARTS/smarts/core/utils/frame_monitor.py
32,34
26,47
below_threshold
FramerateException
41,47
34,47
class FramerateException(Exception): """An exception raised if frame rate has increased higher than the desired threshold.""" def __str__(self): return "The monitor has not started yet." @classmethod def below_threshold(cls, desired_fps, delta): FILL_FUNC_BODY
class FramerateException(Exception): """An exception raised if frame rate has increased higher than the desired threshold.""" def __str__(self): return "The monitor has not started yet." @classmethod def below_threshold(cls, desired_fps, delta): """Generate a frame-rate exception. ...
return cls( f"The frame rate decreased, lower than the desired threshold, \ desired: {desired_fps} fps, actual: {round(1000 / delta, 2)} fps." )
"""Generate a frame-rate exception. Args: desired_fps: The intended fps. delta: The frame time taken. Returns: A new frame-rate exception. """ return cls( f"The frame rate decreased, lower than the desired threshold, \ ...
22
132
65
197
# MIT License # # Copyright (C) 2021. Huawei Technologies Co., Ltd. All rights reserved. # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal # in the Software without restriction, including without limitation th...
# MIT License # # Copyright (C) 2021. Huawei Technologies Co., Ltd. All rights reserved. # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal # in the Software without restriction, including without limitation th...
47,910
/home/hieuvd/dung_repo/raw/stars_03/huawei-noah_SMARTS/SMARTS
/home/hieuvd/dung_repo/raw/stars_03/huawei-noah_SMARTS/SMARTS/smarts/core/utils/geometry.py
26,27
1,51
buffered_shape
28,43
27,43
# Copyright (C) 2020. Huawei Technologies Co., Ltd. All rights reserved. # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal # in the Software without restriction, including without limitation the rights # to us...
# Copyright (C) 2020. Huawei Technologies Co., Ltd. All rights reserved. # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal # in the Software without restriction, including without limitation the rights # to us...
ls = LineString(shape).buffer( width / 2, 1, cap_style=CAP_STYLE.flat, join_style=JOIN_STYLE.round, mitre_limit=5.0, ) if isinstance(ls, MultiPolygon): # Sometimes it oddly outputs a MultiPolygon and then we need to turn it into a convex hull ls = ls.c...
"""Generates a shape with a buffer of `width` around the original shape.""" ls = LineString(shape).buffer( width / 2, 1, cap_style=CAP_STYLE.flat, join_style=JOIN_STYLE.round, mitre_limit=5.0, ) if isinstance(ls, MultiPolygon): # Sometimes it oddly outputs...
48
535
164
699
# Copyright (C) 2020. Huawei Technologies Co., Ltd. All rights reserved. # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal # in the Software without restriction, including without limitation the rights # to us...
# Copyright (C) 2020. Huawei Technologies Co., Ltd. All rights reserved. # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal # in the Software without restriction, including without limitation the rights # to us...
47,911
/home/hieuvd/dung_repo/raw/stars_03/huawei-noah_SMARTS/SMARTS
/home/hieuvd/dung_repo/raw/stars_03/huawei-noah_SMARTS/SMARTS/smarts/core/utils/id.py
45,47
27,62
parse
Id
48,56
47,56
class Id(str): """An id utility.""" def __init__(self, dtype: str, identifier: str): self._dtype = dtype self._identifier = identifier def __new__(cls, dtype: str, identifier: str): return super(Id, cls).__new__(cls, f"{dtype}-{identifier}") def __getnewargs__(self): r...
class Id(str): """An id utility.""" def __init__(self, dtype: str, identifier: str): self._dtype = dtype self._identifier = identifier def __new__(cls, dtype: str, identifier: str): return super(Id, cls).__new__(cls, f"{dtype}-{identifier}") def __getnewargs__(self): r...
split = -8 - 1 # should be "-" if id_[split] != "-": raise ValueError( f"id={id_} is invalid, format should be <type>-<8_char_uuid>" ) return cls(dtype=id_[:split], identifier=id_[split + 1 :])
"""Parses the id from a string.""" split = -8 - 1 # should be "-" if id_[split] != "-": raise ValueError( f"id={id_} is invalid, format should be <type>-<8_char_uuid>" ) return cls(dtype=id_[:split], identifier=id_[split + 1 :])
29
258
98
356
# MIT License # # Copyright (C) 2021. Huawei Technologies Co., Ltd. All rights reserved. # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal # in the Software without restriction, including without limitation th...
# MIT License # # Copyright (C) 2021. Huawei Technologies Co., Ltd. All rights reserved. # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal # in the Software without restriction, including without limitation th...
47,912
/home/hieuvd/dung_repo/raw/stars_03/huawei-noah_SMARTS/SMARTS
/home/hieuvd/dung_repo/raw/stars_03/huawei-noah_SMARTS/SMARTS/smarts/core/utils/id.py
72,74
62,76
new
SocialAgentId
74,76
74,76
class SocialAgentId(Id): """ >>> SocialAgentId.new("keep-lane", group="all") 'social-agent-all-keep-lane' >>> isinstance(SocialAgentId.new("keep-lane"), str) True """ DTYPE = "social-agent" @classmethod def new(cls, name: str, group: Optional[str] = None): FILL_FUNC_BODY
class SocialAgentId(Id): """ >>> SocialAgentId.new("keep-lane", group="all") 'social-agent-all-keep-lane' >>> isinstance(SocialAgentId.new("keep-lane"), str) True """ DTYPE = "social-agent" @classmethod def new(cls, name: str, group: Optional[str] = None): FILL_FUNC_BODY
identifier = "-".join([group, name]) if group is not None else name return cls(dtype=SocialAgentId.DTYPE, identifier=identifier)
identifier = "-".join([group, name]) if group is not None else name return cls(dtype=SocialAgentId.DTYPE, identifier=identifier)
14
116
41
157
# MIT License # # Copyright (C) 2021. Huawei Technologies Co., Ltd. All rights reserved. # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal # in the Software without restriction, including without limitation th...
# MIT License # # Copyright (C) 2021. Huawei Technologies Co., Ltd. All rights reserved. # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal # in the Software without restriction, including without limitation th...
47,913
/home/hieuvd/dung_repo/raw/stars_03/huawei-noah_SMARTS/SMARTS
/home/hieuvd/dung_repo/raw/stars_03/huawei-noah_SMARTS/SMARTS/smarts/core/utils/import_utils.py
27,28
1,37
import_module_from_file
29,37
28,37
# MIT License # # Copyright (C) 2021. Huawei Technologies Co., Ltd. All rights reserved. # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal # in the Software without restriction, including without limitation th...
# MIT License # # Copyright (C) 2021. Huawei Technologies Co., Ltd. All rights reserved. # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal # in the Software without restriction, including without limitation th...
path = str(path) # Get one directory up if path not in sys.path: sys.path.append(path) spec = importlib.util.spec_from_file_location(module_name, f"{path}") module = importlib.util.module_from_spec(spec) sys.modules[module_name] = module spec.loader.exec_module(module) # pytype: disab...
"""Attempt to load a module dynamically from a path as `module_name`.""" path = str(path) # Get one directory up if path not in sys.path: sys.path.append(path) spec = importlib.util.spec_from_file_location(module_name, f"{path}") module = importlib.util.module_from_spec(spec) sys.modul...
28
413
121
534
# MIT License # # Copyright (C) 2021. Huawei Technologies Co., Ltd. All rights reserved. # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal # in the Software without restriction, including without limitation th...
# MIT License # # Copyright (C) 2021. Huawei Technologies Co., Ltd. All rights reserved. # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal # in the Software without restriction, including without limitation th...
47,914
/home/hieuvd/dung_repo/raw/stars_03/huawei-noah_SMARTS/SMARTS
/home/hieuvd/dung_repo/raw/stars_03/huawei-noah_SMARTS/SMARTS/smarts/core/utils/iteration_tools.py
25,26
1,38
duplicates
27,38
26,38
# MIT License # # Copyright (C) 2023. Huawei Technologies Co., Ltd. All rights reserved. # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal # in the Software without restriction, including without limitation th...
# MIT License # # Copyright (C) 2023. Huawei Technologies Co., Ltd. All rights reserved. # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal # in the Software without restriction, including without limitation th...
seen = set() matcher = iterable if key is not None: matcher = map(key, iterable) for v, m in zip(iterable, matcher): if m in seen: yield m, v else: seen.add(m)
"""Finds all values that are duplicates.""" seen = set() matcher = iterable if key is not None: matcher = map(key, iterable) for v, m in zip(iterable, matcher): if m in seen: yield m, v else: seen.add(m)
30
395
86
481
# MIT License # # Copyright (C) 2023. Huawei Technologies Co., Ltd. All rights reserved. # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal # in the Software without restriction, including without limitation th...
# MIT License # # Copyright (C) 2023. Huawei Technologies Co., Ltd. All rights reserved. # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal # in the Software without restriction, including without limitation th...
47,915
/home/hieuvd/dung_repo/raw/stars_03/huawei-noah_SMARTS/SMARTS
/home/hieuvd/dung_repo/raw/stars_03/huawei-noah_SMARTS/SMARTS/smarts/core/utils/key_wrapper.py
39,40
25,42
insert
KeyWrapper
41,42
40,42
class KeyWrapper(Sequence): """A sequence that transforms the selected in an underlying sequence using the given transformation key.""" def __init__(self, iterable, key): self.it = iterable self.key = key def __getitem__(self, i: int): return self.key(self.it[i]) def __len...
class KeyWrapper(Sequence): """A sequence that transforms the selected in an underlying sequence using the given transformation key.""" def __init__(self, iterable, key): self.it = iterable self.key = key def __getitem__(self, i: int): return self.key(self.it[i]) def __len...
self.it.insert(index, item)
"""Insert an item into the sequence.""" self.it.insert(index, item)
2
137
13
150
# MIT License # # Copyright (C) 2021. Huawei Technologies Co., Ltd. All rights reserved. # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal # in the Software without restriction, including without limitation th...
# MIT License # # Copyright (C) 2021. Huawei Technologies Co., Ltd. All rights reserved. # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal # in the Software without restriction, including without limitation th...
47,916
/home/hieuvd/dung_repo/raw/stars_03/huawei-noah_SMARTS/SMARTS
/home/hieuvd/dung_repo/raw/stars_03/huawei-noah_SMARTS/SMARTS/smarts/core/utils/kinematics.py
24,25
1,85
time_to_cover
33,55
25,55
# Copyright (C) 2021. Huawei Technologies Co., Ltd. All rights reserved. # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal # in the Software without restriction, including without limitation the rights # to us...
# Copyright (C) 2021. Huawei Technologies Co., Ltd. All rights reserved. # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal # in the Software without restriction, including without limitation the rights # to us...
if dist == 0: return 0 if abs(acc) < 1e-9: if speed == 0: return math.inf t = dist / speed return t if t >= 0 else math.inf discriminant = speed**2 + 2 * acc * dist if discriminant < 0: return math.inf rad = math.sqrt(discriminant) t1 = (rad - ...
""" Returns the time for a moving object traveling at speed and accelerating at acc to cover distance dist. Assumes that all units are consistent (for example, if distance is in meters, speed is in m/s). The returned value will be non-negative (but may be math.inf under some circumstances). ...
83
795
207
1,002
# Copyright (C) 2021. Huawei Technologies Co., Ltd. All rights reserved. # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal # in the Software without restriction, including without limitation the rights # to us...
# Copyright (C) 2021. Huawei Technologies Co., Ltd. All rights reserved. # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal # in the Software without restriction, including without limitation the rights # to us...
47,917
/home/hieuvd/dung_repo/raw/stars_03/huawei-noah_SMARTS/SMARTS
/home/hieuvd/dung_repo/raw/stars_03/huawei-noah_SMARTS/SMARTS/smarts/core/utils/networking.py
25,26
1,31
find_free_port
27,31
26,31
# Copyright (C) 2020. Huawei Technologies Co., Ltd. All rights reserved. # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal # in the Software without restriction, including without limitation the rights # to us...
# Copyright (C) 2020. Huawei Technologies Co., Ltd. All rights reserved. # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal # in the Software without restriction, including without limitation the rights # to us...
with closing(socket.socket(socket.AF_INET, socket.SOCK_STREAM)) as s: s.bind(("", 0)) s.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1) return s.getsockname()[1]
"""Attempt to find an open networking port.""" with closing(socket.socket(socket.AF_INET, socket.SOCK_STREAM)) as s: s.bind(("", 0)) s.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1) return s.getsockname()[1]
12
403
84
487
# Copyright (C) 2020. Huawei Technologies Co., Ltd. All rights reserved. # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal # in the Software without restriction, including without limitation the rights # to us...
# Copyright (C) 2020. Huawei Technologies Co., Ltd. All rights reserved. # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal # in the Software without restriction, including without limitation the rights # to us...
47,918
/home/hieuvd/dung_repo/raw/stars_03/huawei-noah_SMARTS/SMARTS
/home/hieuvd/dung_repo/raw/stars_03/huawei-noah_SMARTS/SMARTS/smarts/core/utils/observations.py
105,106
1,125
rotate_axes
116,125
106,125
# MIT License # # Copyright (C) 2023. Huawei Technologies Co., Ltd. All rights reserved. # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal # in the Software without restriction, including without limitation th...
# MIT License # # Copyright (C) 2023. Huawei Technologies Co., Ltd. All rights reserved. # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal # in the Software without restriction, including without limitation th...
# fmt: off theta = (theta + np.pi) % (2 * np.pi) - np.pi ct, st = np.cos(theta), np.sin(theta) R = np.array([[ ct, st, 0], [-st, ct, 0], [ 0, 0, 1]]) rotated_points = (R.dot(points.T)).T return rotated_points # fmt: on
"""A counterclockwise rotation of the x-y axes by an angle theta θ about the z-axis. Args: points (np.ndarray): x,y,z coordinates in original axes. Shape = (n,3). theta (np.float): Axes rotation angle in radians. Returns: np.ndarray: x,y,z coordinates in rotated axes. Shape = (...
40
1,563
131
1,694
# MIT License # # Copyright (C) 2023. Huawei Technologies Co., Ltd. All rights reserved. # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal # in the Software without restriction, including without limitation th...
# MIT License # # Copyright (C) 2023. Huawei Technologies Co., Ltd. All rights reserved. # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal # in the Software without restriction, including without limitation th...
47,919
/home/hieuvd/dung_repo/raw/stars_03/huawei-noah_SMARTS/SMARTS
/home/hieuvd/dung_repo/raw/stars_03/huawei-noah_SMARTS/SMARTS/smarts/core/utils/pybullet.py
94,95
67,114
wrapper
BulletClientMACOS
95,98
95,98
class BulletClientMACOS: """This wrapper class is a hack for `macOS` where running PyBullet in GUI mode, alongside Panda3D segfaults. It seems due to running two OpenGL applications in the same process. Here we spawn a process to run PyBullet and forward all calls to it over unix pipes. N.B. This c...
class BulletClientMACOS: """This wrapper class is a hack for `macOS` where running PyBullet in GUI mode, alongside Panda3D segfaults. It seems due to running two OpenGL applications in the same process. Here we spawn a process to run PyBullet and forward all calls to it over unix pipes. N.B. This c...
self._parent_conn.send((name, args, kwargs)) return self._parent_conn.recv()
self._parent_conn.send((name, args, kwargs)) return self._parent_conn.recv()
5
463
34
497
# Copyright (C) 2020. Huawei Technologies Co., Ltd. All rights reserved. # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal # in the Software without restriction, including without limitation the rights # to us...
# Copyright (C) 2020. Huawei Technologies Co., Ltd. All rights reserved. # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal # in the Software without restriction, including without limitation the rights # to us...
47,920
/home/hieuvd/dung_repo/raw/stars_03/huawei-noah_SMARTS/SMARTS
/home/hieuvd/dung_repo/raw/stars_03/huawei-noah_SMARTS/SMARTS/smarts/core/utils/strings.py
25,26
1,38
truncate
32,38
26,38
# MIT License # # Copyright (C) 2021. Huawei Technologies Co., Ltd. All rights reserved. # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal # in the Software without restriction, including without limitation th...
# MIT License # # Copyright (C) 2021. Huawei Technologies Co., Ltd. All rights reserved. # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal # in the Software without restriction, including without limitation th...
if len(str_) <= length: return str_ start = math.ceil((length - len(separator)) / 2) end = math.floor((length - len(separator)) / 2) return f"{str_[:start]}{separator}{str_[len(str_) - end:]}"
"""Truncates a string to the given length by removing internal characters. :param str_: The string to truncate. :param length: The length to truncate the string to. :param separator: The intermediary characters that replaces removed characters. """ if len(str_) <= length: return str_ ...
24
441
86
527
# MIT License # # Copyright (C) 2021. Huawei Technologies Co., Ltd. All rights reserved. # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal # in the Software without restriction, including without limitation th...
# MIT License # # Copyright (C) 2021. Huawei Technologies Co., Ltd. All rights reserved. # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal # in the Software without restriction, including without limitation th...
47,922
/home/hieuvd/dung_repo/raw/stars_03/huawei-noah_SMARTS/SMARTS
/home/hieuvd/dung_repo/raw/stars_03/huawei-noah_SMARTS/SMARTS/smarts/core/utils/type_operations.py
208,209
181,325
insert
TypeSuite
214,221
209,221
class TypeSuite(Generic[T]): """A utility that manages sub-classes of the given base type. Args: base_type (Type[T]): The base type this suite will manage. """ def __init__(self, base_type: Type[T]) -> None: self._type_groups: Dict[Type[T], _TypeGroup] = defaultdict(_TypeGroup) ...
class TypeSuite(Generic[T]): """A utility that manages sub-classes of the given base type. Args: base_type (Type[T]): The base type this suite will manage. """ def __init__(self, base_type: Type[T]) -> None: self._type_groups: Dict[Type[T], _TypeGroup] = defaultdict(_TypeGroup) ...
t = instance.__class__ if t not in self._associated_groups: types = get_type_chain(t, self._base_type) self._associated_groups[t] = types for group_type in self._associated_groups[t]: self._type_groups[group_type].insert(instance)
"""Adds the instance to the suite of managed instances. Args: instance (T): The instance to add. """ t = instance.__class__ if t not in self._associated_groups: types = get_type_chain(t, self._base_type) self._associated_groups[t] = types ...
20
1,372
92
1,464
# MIT License # # Copyright (C) 2023. Huawei Technologies Co., Ltd. All rights reserved. # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal # in the Software without restriction, including without limitation th...
# MIT License # # Copyright (C) 2023. Huawei Technologies Co., Ltd. All rights reserved. # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal # in the Software without restriction, including without limitation th...
47,923
/home/hieuvd/dung_repo/raw/stars_03/huawei-noah_SMARTS/SMARTS
/home/hieuvd/dung_repo/raw/stars_03/huawei-noah_SMARTS/SMARTS/smarts/core/utils/type_operations.py
109,110
86,181
remove
_TypeGroup
115,125
110,125
class _TypeGroup(Generic[T]): def __init__(self) -> None: self._instances = [] self._instances_by_type = {} self._instances_by_id = {} def insert(self, instance: T): """Inserts the given instance into the set of managed instances. This must be a sub-class of the type tha...
class _TypeGroup(Generic[T]): def __init__(self) -> None: self._instances = [] self._instances_by_type = {} self._instances_by_id = {} def insert(self, instance: T): """Inserts the given instance into the set of managed instances. This must be a sub-class of the type tha...
try: self._instances.remove(instance) self._instances_by_type.pop(instance.__class__) # pytype: disable=attribute-error self._instances_by_id.pop(instance.__class__.__name__) # pytype: enable=attribute-error except (KeyError, ValueError): ...
"""Removes the given instance from this type group. Args: instance (T): The instance to remove. """ try: self._instances.remove(instance) self._instances_by_type.pop(instance.__class__) # pytype: disable=attribute-error self._i...
17
803
103
906
# MIT License # # Copyright (C) 2023. Huawei Technologies Co., Ltd. All rights reserved. # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal # in the Software without restriction, including without limitation th...
# MIT License # # Copyright (C) 2023. Huawei Technologies Co., Ltd. All rights reserved. # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal # in the Software without restriction, including without limitation th...
47,925
/home/hieuvd/dung_repo/raw/stars_03/huawei-noah_SMARTS/SMARTS
/home/hieuvd/dung_repo/raw/stars_03/huawei-noah_SMARTS/SMARTS/smarts/core/vehicle_state.py
155,164
108,197
bounding_box_points
VehicleState
165,182
164,182
@dataclass class VehicleState(ActorState): """Vehicle state information.""" vehicle_config_type: Optional[str] = None # key into VEHICLE_CONFIGS pose: Optional[Pose] = None dimensions: Optional[Dimensions] = None speed: float = 0.0 steering: Optional[float] = None yaw_rate: Optional[float]...
@dataclass class VehicleState(ActorState): """Vehicle state information.""" vehicle_config_type: Optional[str] = None # key into VEHICLE_CONFIGS pose: Optional[Pose] = None dimensions: Optional[Dimensions] = None speed: float = 0.0 steering: Optional[float] = None yaw_rate: Optional[float]...
# Assuming the position is the center, # calculate the corner coordinates of the bounding_box origin = self.pose.position[:2] dimensions = np.array([self.dimensions.width, self.dimensions.length]) corners = np.array([(-1, 1), (1, 1), (1, -1), (-1, -1)]) / 2 heading = self...
"""The minimum fitting heading aligned bounding box. Four 2D points representing the minimum fitting box.""" # Assuming the position is the center, # calculate the corner coordinates of the bounding_box origin = self.pose.position[:2] dimensions = np.array([self.dimensions.width,...
55
722
188
910
# MIT License # # Copyright (C) 2022. Huawei Technologies Co., Ltd. All rights reserved. # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal # in the Software without restriction, including without limitation th...
# MIT License # # Copyright (C) 2022. Huawei Technologies Co., Ltd. All rights reserved. # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal # in the Software without restriction, including without limitation th...
47,927
/home/hieuvd/dung_repo/raw/stars_03/huawei-noah_SMARTS/SMARTS
/home/hieuvd/dung_repo/raw/stars_03/huawei-noah_SMARTS/SMARTS/smarts/diagnostic/10_agents_to_n_roads/10_roads/scenario.py
34,35
1,57
gen_actors
35,44
35,44
# Copyright (C) 2022. Huawei Technologies Co., Ltd. All rights reserved. # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal # in the Software without restriction, including without limitation the rights # to us...
# Copyright (C) 2022. Huawei Technologies Co., Ltd. All rights reserved. # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal # in the Software without restriction, including without limitation the rights # to us...
return [ SocialAgentActor( name=f"non-interactive-agent-50-v0_{id_}", agent_locator="zoo.policies:non-interactive-agent-v0", policy_kwargs={"speed": 50}, ) ]
return [ SocialAgentActor( name=f"non-interactive-agent-50-v0_{id_}", agent_locator="zoo.policies:non-interactive-agent-v0", policy_kwargs={"speed": 50}, ) ]
9
542
89
631
# Copyright (C) 2022. Huawei Technologies Co., Ltd. All rights reserved. # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal # in the Software without restriction, including without limitation the rights # to us...
# Copyright (C) 2022. Huawei Technologies Co., Ltd. All rights reserved. # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal # in the Software without restriction, including without limitation the rights # to us...
47,928
/home/hieuvd/dung_repo/raw/stars_03/huawei-noah_SMARTS/SMARTS
/home/hieuvd/dung_repo/raw/stars_03/huawei-noah_SMARTS/SMARTS/smarts/diagnostic/10_agents_to_n_roads/1_roads/scenario.py
34,35
1,59
gen_actors
35,44
35,44
# Copyright (C) 2022. Huawei Technologies Co., Ltd. All rights reserved. # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal # in the Software without restriction, including without limitation the rights # to us...
# Copyright (C) 2022. Huawei Technologies Co., Ltd. All rights reserved. # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal # in the Software without restriction, including without limitation the rights # to us...
return [ SocialAgentActor( name=f"non-interactive-agent-50-v0_{id_}", agent_locator="zoo.policies:non-interactive-agent-v0", policy_kwargs={"speed": 50}, ) ]
return [ SocialAgentActor( name=f"non-interactive-agent-50-v0_{id_}", agent_locator="zoo.policies:non-interactive-agent-v0", policy_kwargs={"speed": 50}, ) ]
9
547
89
636
# Copyright (C) 2022. Huawei Technologies Co., Ltd. All rights reserved. # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal # in the Software without restriction, including without limitation the rights # to us...
# Copyright (C) 2022. Huawei Technologies Co., Ltd. All rights reserved. # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal # in the Software without restriction, including without limitation the rights # to us...
47,929
/home/hieuvd/dung_repo/raw/stars_03/huawei-noah_SMARTS/SMARTS
/home/hieuvd/dung_repo/raw/stars_03/huawei-noah_SMARTS/SMARTS/smarts/diagnostic/10_agents_to_n_roads/20_roads/scenario.py
44,45
1,57
to_missions
45,53
45,53
# Copyright (C) 2022. Huawei Technologies Co., Ltd. All rights reserved. # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal # in the Software without restriction, including without limitation the rights # to us...
# Copyright (C) 2022. Huawei Technologies Co., Ltd. All rights reserved. # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal # in the Software without restriction, including without limitation the rights # to us...
missions = {} for i in range(0, agent_num): missions[f"group-{i}"] = tuple( (gen_actors(i), [Mission(route=RandomRoute())]), ) return missions
missions = {} for i in range(0, agent_num): missions[f"group-{i}"] = tuple( (gen_actors(i), [Mission(route=RandomRoute())]), ) return missions
16
559
71
630
# Copyright (C) 2022. Huawei Technologies Co., Ltd. All rights reserved. # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal # in the Software without restriction, including without limitation the rights # to us...
# Copyright (C) 2022. Huawei Technologies Co., Ltd. All rights reserved. # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal # in the Software without restriction, including without limitation the rights # to us...
47,930
/home/hieuvd/dung_repo/raw/stars_03/huawei-noah_SMARTS/SMARTS
/home/hieuvd/dung_repo/raw/stars_03/huawei-noah_SMARTS/SMARTS/smarts/diagnostic/10_agents_to_n_roads/50_roads/scenario.py
34,35
1,57
gen_actors
35,44
35,44
# Copyright (C) 2022. Huawei Technologies Co., Ltd. All rights reserved. # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal # in the Software without restriction, including without limitation the rights # to us...
# Copyright (C) 2022. Huawei Technologies Co., Ltd. All rights reserved. # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal # in the Software without restriction, including without limitation the rights # to us...
return [ SocialAgentActor( name=f"non-interactive-agent-50-v0_{id_}", agent_locator="zoo.policies:non-interactive-agent-v0", policy_kwargs={"speed": 50}, ) ]
return [ SocialAgentActor( name=f"non-interactive-agent-50-v0_{id_}", agent_locator="zoo.policies:non-interactive-agent-v0", policy_kwargs={"speed": 50}, ) ]
9
542
89
631
# Copyright (C) 2022. Huawei Technologies Co., Ltd. All rights reserved. # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal # in the Software without restriction, including without limitation the rights # to us...
# Copyright (C) 2022. Huawei Technologies Co., Ltd. All rights reserved. # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal # in the Software without restriction, including without limitation the rights # to us...
47,931
/home/hieuvd/dung_repo/raw/stars_03/huawei-noah_SMARTS/SMARTS
/home/hieuvd/dung_repo/raw/stars_03/huawei-noah_SMARTS/SMARTS/smarts/diagnostic/10_agents_with_replay/10_replays/scenario.py
37,38
1,50
to_missions
38,46
38,46
# Copyright (C) 2022. Huawei Technologies Co., Ltd. All rights reserved. # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal # in the Software without restriction, including without limitation the rights # to us...
# Copyright (C) 2022. Huawei Technologies Co., Ltd. All rights reserved. # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal # in the Software without restriction, including without limitation the rights # to us...
missions = {} for i in range(0, agent_num): missions[f"group-{i}"] = tuple( (gen_actors(i), [Mission(route=RandomRoute())]), ) return missions
missions = {} for i in range(0, agent_num): missions[f"group-{i}"] = tuple( (gen_actors(i), [Mission(route=RandomRoute())]), ) return missions
16
540
71
611
# Copyright (C) 2022. Huawei Technologies Co., Ltd. All rights reserved. # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal # in the Software without restriction, including without limitation the rights # to us...
# Copyright (C) 2022. Huawei Technologies Co., Ltd. All rights reserved. # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal # in the Software without restriction, including without limitation the rights # to us...
47,932
/home/hieuvd/dung_repo/raw/stars_03/huawei-noah_SMARTS/SMARTS
/home/hieuvd/dung_repo/raw/stars_03/huawei-noah_SMARTS/SMARTS/smarts/diagnostic/10_agents_with_replay/1_replay/scenario.py
37,38
1,52
to_missions
38,46
38,46
# Copyright (C) 2022. Huawei Technologies Co., Ltd. All rights reserved. # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal # in the Software without restriction, including without limitation the rights # to us...
# Copyright (C) 2022. Huawei Technologies Co., Ltd. All rights reserved. # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal # in the Software without restriction, including without limitation the rights # to us...
missions = {} for i in range(0, agent_num): missions[f"group-{i}"] = tuple( (gen_actors(i), [Mission(route=RandomRoute())]), ) return missions
missions = {} for i in range(0, agent_num): missions[f"group-{i}"] = tuple( (gen_actors(i), [Mission(route=RandomRoute())]), ) return missions
16
545
71
616
# Copyright (C) 2022. Huawei Technologies Co., Ltd. All rights reserved. # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal # in the Software without restriction, including without limitation the rights # to us...
# Copyright (C) 2022. Huawei Technologies Co., Ltd. All rights reserved. # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal # in the Software without restriction, including without limitation the rights # to us...
47,933
/home/hieuvd/dung_repo/raw/stars_03/huawei-noah_SMARTS/SMARTS
/home/hieuvd/dung_repo/raw/stars_03/huawei-noah_SMARTS/SMARTS/smarts/diagnostic/10_agents_with_replay/20_replays/scenario.py
37,38
1,50
to_missions
38,46
38,46
# Copyright (C) 2022. Huawei Technologies Co., Ltd. All rights reserved. # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal # in the Software without restriction, including without limitation the rights # to us...
# Copyright (C) 2022. Huawei Technologies Co., Ltd. All rights reserved. # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal # in the Software without restriction, including without limitation the rights # to us...
missions = {} for i in range(0, agent_num): missions[f"group-{i}"] = tuple( (gen_actors(i), [Mission(route=RandomRoute())]), ) return missions
missions = {} for i in range(0, agent_num): missions[f"group-{i}"] = tuple( (gen_actors(i), [Mission(route=RandomRoute())]), ) return missions
16
540
71
611
# Copyright (C) 2022. Huawei Technologies Co., Ltd. All rights reserved. # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal # in the Software without restriction, including without limitation the rights # to us...
# Copyright (C) 2022. Huawei Technologies Co., Ltd. All rights reserved. # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal # in the Software without restriction, including without limitation the rights # to us...
47,934
/home/hieuvd/dung_repo/raw/stars_03/huawei-noah_SMARTS/SMARTS
/home/hieuvd/dung_repo/raw/stars_03/huawei-noah_SMARTS/SMARTS/smarts/diagnostic/10_agents_with_replay/50_replays/scenario.py
37,38
1,50
to_missions
38,46
38,46
# Copyright (C) 2022. Huawei Technologies Co., Ltd. All rights reserved. # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal # in the Software without restriction, including without limitation the rights # to us...
# Copyright (C) 2022. Huawei Technologies Co., Ltd. All rights reserved. # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal # in the Software without restriction, including without limitation the rights # to us...
missions = {} for i in range(0, agent_num): missions[f"group-{i}"] = tuple( (gen_actors(i), [Mission(route=RandomRoute())]), ) return missions
missions = {} for i in range(0, agent_num): missions[f"group-{i}"] = tuple( (gen_actors(i), [Mission(route=RandomRoute())]), ) return missions
16
540
71
611
# Copyright (C) 2022. Huawei Technologies Co., Ltd. All rights reserved. # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal # in the Software without restriction, including without limitation the rights # to us...
# Copyright (C) 2022. Huawei Technologies Co., Ltd. All rights reserved. # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal # in the Software without restriction, including without limitation the rights # to us...
47,935
/home/hieuvd/dung_repo/raw/stars_03/huawei-noah_SMARTS/SMARTS
/home/hieuvd/dung_repo/raw/stars_03/huawei-noah_SMARTS/SMARTS/smarts/diagnostic/n_agents/10_agents/scenario.py
38,39
1,51
to_missions
39,47
39,47
# Copyright (C) 2022. Huawei Technologies Co., Ltd. All rights reserved. # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal # in the Software without restriction, including without limitation the rights # to us...
# Copyright (C) 2022. Huawei Technologies Co., Ltd. All rights reserved. # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal # in the Software without restriction, including without limitation the rights # to us...
missions = {} for i in range(0, agent_num): missions[f"group-{i}"] = tuple( (gen_actors(i), [Mission(route=RandomRoute())]), ) return missions
missions = {} for i in range(0, agent_num): missions[f"group-{i}"] = tuple( (gen_actors(i), [Mission(route=RandomRoute())]), ) return missions
16
555
71
626
# Copyright (C) 2022. Huawei Technologies Co., Ltd. All rights reserved. # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal # in the Software without restriction, including without limitation the rights # to us...
# Copyright (C) 2022. Huawei Technologies Co., Ltd. All rights reserved. # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal # in the Software without restriction, including without limitation the rights # to us...
47,936
/home/hieuvd/dung_repo/raw/stars_03/huawei-noah_SMARTS/SMARTS
/home/hieuvd/dung_repo/raw/stars_03/huawei-noah_SMARTS/SMARTS/smarts/diagnostic/n_agents/1_agents/scenario.py
38,39
1,51
to_missions
39,47
39,47
# Copyright (C) 2022. Huawei Technologies Co., Ltd. All rights reserved. # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal # in the Software without restriction, including without limitation the rights # to us...
# Copyright (C) 2022. Huawei Technologies Co., Ltd. All rights reserved. # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal # in the Software without restriction, including without limitation the rights # to us...
missions = {} for i in range(0, agent_num): missions[f"group-{i}"] = tuple( (gen_actors(i), [Mission(route=RandomRoute())]), ) return missions
missions = {} for i in range(0, agent_num): missions[f"group-{i}"] = tuple( (gen_actors(i), [Mission(route=RandomRoute())]), ) return missions
16
554
71
625
# Copyright (C) 2022. Huawei Technologies Co., Ltd. All rights reserved. # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal # in the Software without restriction, including without limitation the rights # to us...
# Copyright (C) 2022. Huawei Technologies Co., Ltd. All rights reserved. # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal # in the Software without restriction, including without limitation the rights # to us...
47,937
/home/hieuvd/dung_repo/raw/stars_03/huawei-noah_SMARTS/SMARTS
/home/hieuvd/dung_repo/raw/stars_03/huawei-noah_SMARTS/SMARTS/smarts/diagnostic/n_agents/20_agents/scenario.py
27,28
1,51
gen_actors
28,38
28,38
# Copyright (C) 2022. Huawei Technologies Co., Ltd. All rights reserved. # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal # in the Software without restriction, including without limitation the rights # to us...
# Copyright (C) 2022. Huawei Technologies Co., Ltd. All rights reserved. # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal # in the Software without restriction, including without limitation the rights # to us...
return [ SocialAgentActor( name=f"non-interactive-agent-{speed}-v0_{id_}", agent_locator="zoo.policies:non-interactive-agent-v0", policy_kwargs={"speed": speed}, ) for speed in [10, 30, 80] ]
return [ SocialAgentActor( name=f"non-interactive-agent-{speed}-v0_{id_}", agent_locator="zoo.policies:non-interactive-agent-v0", policy_kwargs={"speed": speed}, ) for speed in [10, 30, 80] ]
15
523
105
628
# Copyright (C) 2022. Huawei Technologies Co., Ltd. All rights reserved. # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal # in the Software without restriction, including without limitation the rights # to us...
# Copyright (C) 2022. Huawei Technologies Co., Ltd. All rights reserved. # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal # in the Software without restriction, including without limitation the rights # to us...
47,938
/home/hieuvd/dung_repo/raw/stars_03/huawei-noah_SMARTS/SMARTS
/home/hieuvd/dung_repo/raw/stars_03/huawei-noah_SMARTS/SMARTS/smarts/diagnostic/n_agents/50_agents/scenario.py
38,39
1,51
to_missions
39,47
39,47
# Copyright (C) 2022. Huawei Technologies Co., Ltd. All rights reserved. # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal # in the Software without restriction, including without limitation the rights # to us...
# Copyright (C) 2022. Huawei Technologies Co., Ltd. All rights reserved. # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal # in the Software without restriction, including without limitation the rights # to us...
missions = {} for i in range(0, agent_num): missions[f"group-{i}"] = tuple( (gen_actors(i), [Mission(route=RandomRoute())]), ) return missions
missions = {} for i in range(0, agent_num): missions[f"group-{i}"] = tuple( (gen_actors(i), [Mission(route=RandomRoute())]), ) return missions
16
555
71
626
# Copyright (C) 2022. Huawei Technologies Co., Ltd. All rights reserved. # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal # in the Software without restriction, including without limitation the rights # to us...
# Copyright (C) 2022. Huawei Technologies Co., Ltd. All rights reserved. # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal # in the Software without restriction, including without limitation the rights # to us...
47,942
/home/hieuvd/dung_repo/raw/stars_03/huawei-noah_SMARTS/SMARTS
/home/hieuvd/dung_repo/raw/stars_03/huawei-noah_SMARTS/SMARTS/smarts/env/gymnasium/wrappers/metric/formula.py
79,80
63,95
score
Formula
89,95
80,95
class Formula(FormulaBase): """Sets the (i) cost function parameters, and (ii) score computation formula, for an environment. """ def __init__(self): pass def params(self) -> Params: """Return parameters to configure and initialize cost functions. Returns: Para...
class Formula(FormulaBase): """Sets the (i) cost function parameters, and (ii) score computation formula, for an environment. """ def __init__(self): pass def params(self) -> Params: """Return parameters to configure and initialize cost functions. Returns: Para...
agent_weight = agent_weights(records=records) agent_score = agent_scores(records=records, func=costs_to_score) return weighted_score(scores=agent_score, weights=agent_weight)
"""Computes sub-component scores and one total combined score named "Overall" on the wrapped environment. Args: records (Dict[str, Dict[str, Record]]): Records. Returns: Score: "Overall" score and other sub-component scores. """ agent_weight = a...
10
213
72
285
# MIT License # Copyright (C) 2023. Huawei Technologies Co., Ltd. All rights reserved. # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal # in the Software without restriction, including without limitation the ...
# MIT License # Copyright (C) 2023. Huawei Technologies Co., Ltd. All rights reserved. # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal # in the Software without restriction, including without limitation the ...
47,943
/home/hieuvd/dung_repo/raw/stars_03/huawei-noah_SMARTS/SMARTS
/home/hieuvd/dung_repo/raw/stars_03/huawei-noah_SMARTS/SMARTS/smarts/env/gymnasium/wrappers/metric/formula.py
42,43
34,63
params
FormulaBase
48,50
43,50
class FormulaBase: """Interface, for cost function parameters and score computation formula, to be implemented by other formula classes. """ def __init__(self): pass def params(self) -> Params: FILL_FUNC_BODY def score(self, records: Dict[str, Dict[str, Record]]) -> Score: """Co...
class FormulaBase: """Interface, for cost function parameters and score computation formula, to be implemented by other formula classes. """ def __init__(self): pass def params(self) -> Params: """Return parameters to configure and initialize cost functions. Returns: ...
raise NotImplementedError
"""Return parameters to configure and initialize cost functions. Returns: Params: Cost function parameters. """ raise NotImplementedError
2
207
11
218
# MIT License # Copyright (C) 2023. Huawei Technologies Co., Ltd. All rights reserved. # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal # in the Software without restriction, including without limitation the ...
# MIT License # Copyright (C) 2023. Huawei Technologies Co., Ltd. All rights reserved. # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal # in the Software without restriction, including without limitation the ...
47,945
/home/hieuvd/dung_repo/raw/stars_03/huawei-noah_SMARTS/SMARTS
/home/hieuvd/dung_repo/raw/stars_03/huawei-noah_SMARTS/SMARTS/smarts/env/gymnasium/wrappers/metric/utils.py
160,161
144,193
move
SlidingWindow
167,183
161,183
class SlidingWindow: """A sliding window which moves to the right by accepting new elements. The maximum value within the sliding window can be queried at anytime by calling the max() method. """ def __init__(self, size: int): """ Args: size (int): Size of the sliding wi...
class SlidingWindow: """A sliding window which moves to the right by accepting new elements. The maximum value within the sliding window can be queried at anytime by calling the max() method. """ def __init__(self, size: int): """ Args: size (int): Size of the sliding wi...
self._time += 1 # When values deque is full, remove head element of max_candidates deque # if it matches head element of values deque. if len(self._values) == self._size: if self._values[0][0] == self._max_candidates[0][0]: self._max_candidates.popleft() ...
"""Moves the sliding window one step to the right by appending the new element x and discarding the oldest element on the left. Args: x (Union[int,float]): New element input to the sliding window. """ self._time += 1 # When values deque is full, remove head ...
68
309
230
539
# MIT License # Copyright (C) 2023. Huawei Technologies Co., Ltd. All rights reserved. # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal # in the Software without restriction, including without limitation the ...
# MIT License # Copyright (C) 2023. Huawei Technologies Co., Ltd. All rights reserved. # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal # in the Software without restriction, including without limitation the ...
47,947
/home/hieuvd/dung_repo/raw/stars_03/huawei-noah_SMARTS/SMARTS
/home/hieuvd/dung_repo/raw/stars_03/huawei-noah_SMARTS/SMARTS/smarts/env/utils/scenario.py
26,27
1,54
get_scenario_specs
35,54
27,54
# MIT License # Copyright (C) 2023. Huawei Technologies Co., Ltd. All rights reserved. # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal # in the Software without restriction, including without limitation the ...
# MIT License # Copyright (C) 2023. Huawei Technologies Co., Ltd. All rights reserved. # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal # in the Software without restriction, including without limitation the ...
if os.path.isdir(scenario): import re regexp_agent = re.compile(r"agents_\d+") regexp_num = re.compile(r"\d+") matches_agent = regexp_agent.search(scenario) if not matches_agent: raise Exception( f"Scenario path should match regexp of 'agents_\\d...
"""Returns the appropriate scenario specification. Args: scenario (str): Scenario Returns: Dict[str, Any]: A parameter dictionary. """ if os.path.isdir(scenario): import re regexp_agent = re.compile(r"agents_\d+") regexp_num = re.compile(r"\d+") ma...
44
419
215
634
# MIT License # Copyright (C) 2023. Huawei Technologies Co., Ltd. All rights reserved. # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal # in the Software without restriction, including without limitation the ...
# MIT License # Copyright (C) 2023. Huawei Technologies Co., Ltd. All rights reserved. # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal # in the Software without restriction, including without limitation the ...
47,948
/home/hieuvd/dung_repo/raw/stars_03/huawei-noah_SMARTS/SMARTS
/home/hieuvd/dung_repo/raw/stars_03/huawei-noah_SMARTS/SMARTS/smarts/ros/__main__.py
27,28
1,80
_usage_error
28,37
28,37
# Copyright (C) 2021. Huawei Technologies Co., Ltd. All rights reserved. # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal # in the Software without restriction, including without limitation the rights # to us...
# Copyright (C) 2021. Huawei Technologies Co., Ltd. All rights reserved. # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal # in the Software without restriction, including without limitation the rights # to us...
if msg: print(f"ERROR: {msg}") print("usage: python -m smarts.ros setup_node [install_path]") print( "\twhere install_path is an optional existing folder into which to put the node" ) sys.exit(-1)
if msg: print(f"ERROR: {msg}") print("usage: python -m smarts.ros setup_node [install_path]") print( "\twhere install_path is an optional existing folder into which to put the node" ) sys.exit(-1)
26
952
87
1,039
# Copyright (C) 2021. Huawei Technologies Co., Ltd. All rights reserved. # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal # in the Software without restriction, including without limitation the rights # to us...
# Copyright (C) 2021. Huawei Technologies Co., Ltd. All rights reserved. # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal # in the Software without restriction, including without limitation the rights # to us...
47,949
/home/hieuvd/dung_repo/raw/stars_03/huawei-noah_SMARTS/SMARTS
/home/hieuvd/dung_repo/raw/stars_03/huawei-noah_SMARTS/SMARTS/smarts/sstudio/generators.py
69,70
51,105
random_lane_index
RandomRouteGenerator
70,73
70,73
class RandomRouteGenerator: """Generates a random route out of the routes available in the road map. Args: road_map: A network of routes defined for vehicles of different kinds to travel on. """ def __init__(self, road_map: RoadMap): self._log = logging.getLogger(self.__cla...
class RandomRouteGenerator: """Generates a random route out of the routes available in the road map. Args: road_map: A network of routes defined for vehicles of different kinds to travel on. """ def __init__(self, road_map: RoadMap): self._log = logging.getLogger(self.__cla...
lanes = self._road_map.road_by_id(road_id).lanes return random.randint(0, len(lanes) - 1)
lanes = self._road_map.road_by_id(road_id).lanes return random.randint(0, len(lanes) - 1)
8
591
46
637
# Copyright (C) 2020. Huawei Technologies Co., Ltd. All rights reserved. # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal # in the Software without restriction, including without limitation the rights # to us...
# Copyright (C) 2020. Huawei Technologies Co., Ltd. All rights reserved. # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal # in the Software without restriction, including without limitation the rights # to us...
47,951
/home/hieuvd/dung_repo/raw/stars_03/huawei-noah_SMARTS/SMARTS
/home/hieuvd/dung_repo/raw/stars_03/huawei-noah_SMARTS/SMARTS/smarts/sstudio/graphics/heightfield.py
165,166
31,188
write_image
HeightField
167,173
166,173
class HeightField(ABC): """A utility for working with greyscale values.""" def __init__( self, data: np.ndarray, size: Union[Tuple[int, int], np.ndarray], metadata: Optional[Dict] = None, ) -> None: assert isinstance(data, np.ndarray), "Image must be a numpy array." ...
class HeightField(ABC): """A utility for working with greyscale values.""" def __init__( self, data: np.ndarray, size: Union[Tuple[int, int], np.ndarray], metadata: Optional[Dict] = None, ) -> None: assert isinstance(data, np.ndarray), "Image must be a numpy array." ...
from PIL import Image a = self.data.astype(np.uint8) im = Image.fromarray(a, "L") im.save(file)
"""Write this out to a greyscale image.""" from PIL import Image a = self.data.astype(np.uint8) im = Image.fromarray(a, "L") im.save(file)
12
1,761
53
1,814
# MIT License # # Copyright (C) 2023. Huawei Technologies Co., Ltd. All rights reserved. # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal # in the Software without restriction, including without limitation th...
# MIT License # # Copyright (C) 2023. Huawei Technologies Co., Ltd. All rights reserved. # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal # in the Software without restriction, including without limitation th...
47,952
/home/hieuvd/dung_repo/raw/stars_03/huawei-noah_SMARTS/SMARTS
/home/hieuvd/dung_repo/raw/stars_03/huawei-noah_SMARTS/SMARTS/smarts/sstudio/od2mesh.py
26,27
1,43
generate_glb_from_opendrive_file
28,33
27,33
# Copyright (C) 2020. Huawei Technologies Co., Ltd. All rights reserved. # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal # in the Software without restriction, including without limitation the rights # to us...
# Copyright (C) 2020. Huawei Technologies Co., Ltd. All rights reserved. # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal # in the Software without restriction, including without limitation the rights # to us...
map_spec = MapSpec(od_xodr_file) road_network = OpenDriveRoadNetwork.from_spec(map_spec) road_network.to_glb(out_glb_dir)
"""Creates a geometry file from an OpenDRIVE map file.""" map_spec = MapSpec(od_xodr_file) road_network = OpenDriveRoadNetwork.from_spec(map_spec) road_network.to_glb(out_glb_dir)
7
593
63
656
# Copyright (C) 2020. Huawei Technologies Co., Ltd. All rights reserved. # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal # in the Software without restriction, including without limitation the rights # to us...
# Copyright (C) 2020. Huawei Technologies Co., Ltd. All rights reserved. # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal # in the Software without restriction, including without limitation the rights # to us...
47,953
/home/hieuvd/dung_repo/raw/stars_03/huawei-noah_SMARTS/SMARTS
/home/hieuvd/dung_repo/raw/stars_03/huawei-noah_SMARTS/SMARTS/smarts/sstudio/scenario_builder.py
26,27
1,46
_build
27,36
27,36
# Copyright (C) 2023. Huawei Technologies Co., Ltd. All rights reserved. # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal # in the Software without restriction, including without limitation the rights # to us...
# Copyright (C) 2023. Huawei Technologies Co., Ltd. All rights reserved. # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal # in the Software without restriction, including without limitation the rights # to us...
# Make sure all the seed values are consistent before running the scenario script smarts_seed(seed) # Execute the scenario script, using the current globals that were set by the seed value with open(scenario_py, "rb") as source_file: code = compile(source_file.read(), scenario_py, "exec") ...
# Make sure all the seed values are consistent before running the scenario script smarts_seed(seed) # Execute the scenario script, using the current globals that were set by the seed value with open(scenario_py, "rb") as source_file: code = compile(source_file.read(), scenario_py, "exec") ...
44
503
111
614
# Copyright (C) 2023. Huawei Technologies Co., Ltd. All rights reserved. # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal # in the Software without restriction, including without limitation the rights # to us...
# Copyright (C) 2023. Huawei Technologies Co., Ltd. All rights reserved. # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal # in the Software without restriction, including without limitation the rights # to us...
47,954
/home/hieuvd/dung_repo/raw/stars_03/huawei-noah_SMARTS/SMARTS
/home/hieuvd/dung_repo/raw/stars_03/huawei-noah_SMARTS/SMARTS/smarts/sstudio/scenario_construction.py
35,41
1,200
build_scenario
42,68
41,68
# Copyright (C) 2022. Huawei Technologies Co., Ltd. All rights reserved. # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal # in the Software without restriction, including without limitation the rights # to us...
# Copyright (C) 2022. Huawei Technologies Co., Ltd. All rights reserved. # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal # in the Software without restriction, including without limitation the rights # to us...
log(f"Building: {scenario}") if clean: clean_scenario(scenario) scenario_root = Path(scenario) scenario_py = scenario_root / "scenario.py" if scenario_py.exists(): _install_requirements(scenario_root, log) try: subprocess.check_call( [ ...
"""Build a scenario.""" log(f"Building: {scenario}") if clean: clean_scenario(scenario) scenario_root = Path(scenario) scenario_py = scenario_root / "scenario.py" if scenario_py.exists(): _install_requirements(scenario_root, log) try: subprocess.check_cal...
33
1,720
210
1,930
# Copyright (C) 2022. Huawei Technologies Co., Ltd. All rights reserved. # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal # in the Software without restriction, including without limitation the rights # to us...
# Copyright (C) 2022. Huawei Technologies Co., Ltd. All rights reserved. # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal # in the Software without restriction, including without limitation the rights # to us...
47,955
/home/hieuvd/dung_repo/raw/stars_03/huawei-noah_SMARTS/SMARTS
/home/hieuvd/dung_repo/raw/stars_03/huawei-noah_SMARTS/SMARTS/smarts/sstudio/sstypes/actor/traffic_actor.py
70,72
33,74
id
TrafficActor
73,74
72,74
@dataclass(frozen=True) class TrafficActor(Actor): """Used as a description/spec for traffic actors (e.x. Vehicles, Pedestrians, etc). The defaults provided are for a car, but the name is not set to make it explicit that you actually want a car. """ accel: float = 2.6 """The maximum acceleratio...
@dataclass(frozen=True) class TrafficActor(Actor): """Used as a description/spec for traffic actors (e.x. Vehicles, Pedestrians, etc). The defaults provided are for a car, but the name is not set to make it explicit that you actually want a car. """ accel: float = 2.6 """The maximum acceleratio...
return "{}-{}".format(self.name, str(hash(self))[:6])
"""The identifier tag of the traffic actor.""" return "{}-{}".format(self.name, str(hash(self))[:6])
3
559
24
583
# MIT License # # Copyright (C) 2023. Huawei Technologies Co., Ltd. All rights reserved. # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal # in the Software without restriction, including without limitation th...
# MIT License # # Copyright (C) 2023. Huawei Technologies Co., Ltd. All rights reserved. # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal # in the Software without restriction, including without limitation th...
47,956
/home/hieuvd/dung_repo/raw/stars_03/huawei-noah_SMARTS/SMARTS
/home/hieuvd/dung_repo/raw/stars_03/huawei-noah_SMARTS/SMARTS/smarts/sstudio/sstypes/bubble.py
147,149
44,159
traffic_provider
Bubble
154,159
149,159
@dataclass(frozen=True) class Bubble: """A descriptor that defines a capture bubble for social agents. Bubbles consist of an airlock and hijack zone. The airlock is always the same size or larger than the hijack zone. A vehicle must first pass into the airlock and pass the conditions of the airlock to ...
@dataclass(frozen=True) class Bubble: """A descriptor that defines a capture bubble for social agents. Bubbles consist of an airlock and hijack zone. The airlock is always the same size or larger than the hijack zone. A vehicle must first pass into the airlock and pass the conditions of the airlock to ...
return ( self.actor.traffic_provider if isinstance(self.actor, TrafficEngineActor) else None )
"""The name of the traffic provider used if the actor is to be controlled by a traffic engine. Returns: (Optional[str]): The name of the traffic provider or `None`. """ return ( self.actor.traffic_provider if isinstance(self.actor, TrafficEngineActor)...
9
1,332
42
1,374
# MIT License # # Copyright (C) 2023. Huawei Technologies Co., Ltd. All rights reserved. # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal # in the Software without restriction, including without limitation th...
# MIT License # # Copyright (C) 2023. Huawei Technologies Co., Ltd. All rights reserved. # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal # in the Software without restriction, including without limitation th...
47,957
/home/hieuvd/dung_repo/raw/stars_03/huawei-noah_SMARTS/SMARTS
/home/hieuvd/dung_repo/raw/stars_03/huawei-noah_SMARTS/SMARTS/smarts/sstudio/sstypes/condition.py
551,552
521,615
evaluate
CompoundCondition
552,605
552,605
@dataclass(frozen=True) class CompoundCondition(Condition): """This compounds multiple conditions. The following cases are notable CONJUNCTION (A AND B) If both conditions evaluate TRUE the result is exclusively TRUE. Else if either condition evaluates EXPIRED the result will be...
@dataclass(frozen=True) class CompoundCondition(Condition): """This compounds multiple conditions. The following cases are notable CONJUNCTION (A AND B) If both conditions evaluate TRUE the result is exclusively TRUE. Else if either condition evaluates EXPIRED the result will be...
# Short circuits first_eval = self.first_condition.evaluate(**kwargs) if ( self.operator == ConditionOperator.CONJUNCTION and ConditionState.EXPIRED in first_eval ): return ConditionState.EXPIRED elif ( self.operator == ConditionOpe...
# Short circuits first_eval = self.first_condition.evaluate(**kwargs) if ( self.operator == ConditionOperator.CONJUNCTION and ConditionState.EXPIRED in first_eval ): return ConditionState.EXPIRED elif ( self.operator == ConditionOpe...
133
427
484
911
# MIT License # # Copyright (C) 2023. Huawei Technologies Co., Ltd. All rights reserved. # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal # in the Software without restriction, including without limitation th...
# MIT License # # Copyright (C) 2023. Huawei Technologies Co., Ltd. All rights reserved. # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal # in the Software without restriction, including without limitation th...