Exposed target speed
This commit is contained in:
parent
015f1c6d43
commit
e425eef843
|
@ -66,6 +66,12 @@ class BasicAgent(Agent):
|
|||
|
||||
return control
|
||||
|
||||
def set_target_speed(self, speed):
|
||||
"""
|
||||
Changes the target speed of the agent
|
||||
"""
|
||||
self._local_planner.set_speed(speed)
|
||||
|
||||
def get_local_planner(self):
|
||||
"""
|
||||
Get method for protected member local planner
|
||||
|
@ -76,15 +82,35 @@ class BasicAgent(Agent):
|
|||
"""
|
||||
This method creates a list of waypoints from agent's position to destination location
|
||||
based on the route returned by the global router
|
||||
|
||||
:param end_location: final location of the route
|
||||
:param start_location: starting location of the route
|
||||
"""
|
||||
if not start_location:
|
||||
start_location = self._vehicle.get_location()
|
||||
clean_queue = True
|
||||
else:
|
||||
clean_queue = False
|
||||
|
||||
start_waypoint = self._map.get_waypoint(self._vehicle.get_location())
|
||||
end_waypoint = self._map.get_waypoint(end_location)
|
||||
|
||||
route_trace = self._trace_route(start_waypoint, end_waypoint)
|
||||
self._local_planner.set_global_plan(route_trace)
|
||||
self._local_planner.set_global_plan(route_trace, clean_queue=clean_queue)
|
||||
|
||||
def set_global_plan(self, plan, stop_waypoint_creation=True, clean_queue=True):
|
||||
"""
|
||||
Adds a specific plan to the agent.
|
||||
|
||||
:param stop_waypoint_creation: stops the automatic creation of waypoints
|
||||
:param clean_queue: resets the current agent's plan
|
||||
"""
|
||||
self._local_planner.set_global_plan(
|
||||
plan,
|
||||
stop_waypoint_creation=stop_waypoint_creation,
|
||||
clean_queue=clean_queue
|
||||
)
|
||||
|
||||
|
||||
def _trace_route(self, start_waypoint, end_waypoint):
|
||||
"""
|
||||
|
|
|
@ -142,7 +142,6 @@ class LocalPlanner(object):
|
|||
print("WARNING: The max speed is currently set to follow the speed limits. "
|
||||
"Use 'follow_speed_limits' to deactivate this")
|
||||
self._target_speed = speed
|
||||
# TODO: Change the sampling distance too?
|
||||
|
||||
|
||||
def follow_speed_limits(self, value=True):
|
||||
|
@ -154,6 +153,7 @@ class LocalPlanner(object):
|
|||
"""
|
||||
self._follow_speed_limits = value
|
||||
|
||||
|
||||
def _compute_next_waypoints(self, k=1):
|
||||
"""
|
||||
Add new waypoints to the trajectory queue.
|
||||
|
@ -185,6 +185,7 @@ class LocalPlanner(object):
|
|||
|
||||
self._waypoints_queue.append((next_waypoint, road_option))
|
||||
|
||||
|
||||
def set_global_plan(self, current_plan, stop_waypoint_creation=True, clean_queue=True):
|
||||
"""
|
||||
Adds a new plan to the local planner.
|
||||
|
@ -204,6 +205,7 @@ class LocalPlanner(object):
|
|||
|
||||
self._stop_waypoint_creation = stop_waypoint_creation
|
||||
|
||||
|
||||
def run_step(self, debug=False):
|
||||
"""
|
||||
Execute one step of local planning which involves running the longitudinal and lateral PID controllers to
|
||||
|
@ -250,6 +252,7 @@ class LocalPlanner(object):
|
|||
|
||||
return control
|
||||
|
||||
|
||||
def get_incoming_waypoint_and_direction(self, steps=3):
|
||||
"""
|
||||
Returns direction and waypoint at a distance ahead defined by the user.
|
||||
|
@ -266,6 +269,7 @@ class LocalPlanner(object):
|
|||
except IndexError as i:
|
||||
return None, RoadOption.VOID
|
||||
|
||||
|
||||
def done(self):
|
||||
"""
|
||||
Returns whether or not the planner has finished
|
||||
|
@ -274,6 +278,7 @@ class LocalPlanner(object):
|
|||
"""
|
||||
return len(self._waypoints_queue) == 0
|
||||
|
||||
|
||||
def _retrieve_options(list_waypoints, current_waypoint):
|
||||
"""
|
||||
Compute the type of connection between the current active waypoint and the multiple waypoints present in
|
||||
|
|
Loading…
Reference in New Issue