Skip to content

Commit 2616c63

Browse files
committed
Added location and current waypoint to live_info
1 parent 377d702 commit 2616c63

File tree

2 files changed

+15
-3
lines changed

2 files changed

+15
-3
lines changed

PythonAPI/carla/agents/conf/agent_settings_backend.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,8 +165,10 @@ def to_nested_config(self, simple_overwrites:dict=None) -> AgentConfig:
165165
class LiveInfo(AgentConfig):
166166
current_speed : float = MISSING
167167
current_speed_limit : float = MISSING
168-
direction : RoadOption = MISSING
169168
velocity_vector : "carla.Vector3D" = MISSING
169+
direction : RoadOption = MISSING
170+
current_location : "carla.Location" = MISSING
171+
current_waypoint : "carla.Waypoint" = MISSING
170172

171173
# NOTE: Not ported to OmegaConf
172174
@property

PythonAPI/carla/agents/navigation/behavior_agent.py

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,15 +75,25 @@ def _update_information(self):
7575
This method updates the information regarding the ego
7676
vehicle based on the surrounding world.
7777
"""
78+
# Speed
7879
self.config.live_info.current_speed = get_speed(self._vehicle)
7980
self.config.live_info.current_speed_limit = self._vehicle.get_speed_limit()
8081
self._local_planner.set_speed(self.config.live_info.current_speed_limit) # note: currently redundant, but will print warning.
82+
83+
# Location
84+
self.config.live_info.current_location = self._vehicle.get_location()
85+
self.config.live_info.current_waypoint = self._map.get_waypoint(self.config.live_info.current_location)
86+
87+
# Direction
88+
# NOTE: This is set at local_planner.run_step and the executed direction from the *last* step
8189
self._direction = self._local_planner.target_road_option
8290
if self._direction is None:
8391
self._direction = RoadOption.LANEFOLLOW
8492

93+
# Upcoming direction
8594
self._look_ahead_steps = int((self.config.live_info.current_speed_limit) / 10)
8695

96+
# Will take the direction that is a few meters in front of the vehicle depending on the speed
8797
self._incoming_waypoint, self._incoming_direction = self._local_planner.get_incoming_waypoint_and_direction(
8898
steps=self._look_ahead_steps)
8999
if self._incoming_direction is None:
@@ -266,8 +276,8 @@ def run_step(self, debug=False):
266276
if self._tailgate_counter > 0:
267277
self._tailgate_counter -= 1
268278

269-
ego_vehicle_loc = self._vehicle.get_location()
270-
ego_vehicle_wp = self._map.get_waypoint(ego_vehicle_loc)
279+
ego_vehicle_loc = self.config.live_info.current_location
280+
ego_vehicle_wp = self.config.live_info.current_waypoint
271281

272282
# 1: Red lights and stops behavior
273283
if self.traffic_light_manager():

0 commit comments

Comments
 (0)