|
CARLA
|
LocalPlanner reproduces agents.navigation.local_planner.LocalPlanner.
More...
#include <LocalPlanner.h>
Classes | |
| struct | Options |
Aggregated configuration. Mirrors the opt_dict in local_planner.py. More... | |
Public Types | |
| using | PlanItem = std::pair< SharedPtr< client::Waypoint >, RoadOption > |
Public Member Functions | |
| bool | Done () const |
| True when the queue is empty. | |
| void | FollowSpeedLimits (bool value=true) |
| Toggle automatic following of road speed limits. | |
| std::pair< SharedPtr< client::Waypoint >, RoadOption > | GetIncomingWaypointAndDirection (int steps=3) const |
Peek steps ahead in the queue, falling back to the last entry if the queue is too short. | |
| const std::deque< PlanItem > & | GetPlan () const |
| Read-only view of the queued plan. | |
| LocalPlanner (SharedPtr< client::Vehicle > vehicle, const Options &opt=DefaultOptions(), SharedPtr< client::Map > map=nullptr) | |
| void | ResetVehicle () |
Drop the vehicle reference (mirrors reset_vehicle). | |
| rpc::VehicleControl | RunStep (bool debug=false) |
| Drive one tick. Returns the VehicleControl to apply. | |
| void | SetGlobalPlan (const std::vector< PlanItem > &plan, bool stop_waypoint_creation=true, bool clean_queue=true) |
| Replace (or append to) the waypoint queue. | |
| void | SetOffset (float offset) |
| Apply a lateral offset to the underlying PID controller. | |
| void | SetSpeed (float speed_kmh) |
| Override the target speed in km/h. | |
| RoadOption | TargetRoadOption () const |
Currently active target RoadOption (mirrors target_road_option). | |
| SharedPtr< client::Waypoint > | TargetWaypoint () const |
Currently active target waypoint (mirrors target_waypoint). | |
Static Public Member Functions | |
| static Options | DefaultOptions () |
| Construct a LocalPlanner. | |
Private Member Functions | |
| void | ComputeNextWaypoints (std::size_t k) |
Append up to k waypoints to the back of the queue, branching with random choice on intersections (mirrors _compute_next_waypoints). | |
| void | InitController () |
| Build the VehiclePIDController and seed the queue with the vehicle's current waypoint. | |
Private Attributes | |
| float | _base_min_distance |
| float | _distance_ratio |
| float | _dt |
| bool | _follow_speed_limits |
| VehiclePIDController::LateralArgs | _lateral_args |
| VehiclePIDController::LongitudinalArgs | _longitudinal_args |
| SharedPtr< client::Map > | _map |
| float | _max_brake |
| std::size_t | _max_queue_size = 10000 |
| float | _max_steering |
| float | _max_throttle |
| std::size_t | _min_queue_length = 100 |
| float | _offset |
| std::mt19937 | _rng |
| float | _sampling_radius |
| bool | _stop_waypoint_creation = false |
| RoadOption | _target_road_option = RoadOption::Void |
| float | _target_speed |
| SharedPtr< client::Waypoint > | _target_waypoint |
| SharedPtr< client::Vehicle > | _vehicle |
| std::unique_ptr< VehiclePIDController > | _vehicle_controller |
| std::deque< PlanItem > | _waypoints_queue |
LocalPlanner reproduces agents.navigation.local_planner.LocalPlanner.
It maintains a queue of (waypoint, RoadOption) pairs, refills it as needed, and drives the vehicle along it via a VehiclePIDController.
Definition at line 33 of file LocalPlanner.h.
| using carla::agents::navigation::LocalPlanner::PlanItem = std::pair<SharedPtr<client::Waypoint>, RoadOption> |
Definition at line 35 of file LocalPlanner.h.
| carla::agents::navigation::LocalPlanner::LocalPlanner | ( | SharedPtr< client::Vehicle > | vehicle, |
| const Options & | opt = DefaultOptions(), |
||
| SharedPtr< client::Map > | map = nullptr |
||
| ) |
Definition at line 80 of file LocalPlanner.cpp.
References _map, _vehicle, and InitController().
|
private |
Append up to k waypoints to the back of the queue, branching with random choice on intersections (mirrors _compute_next_waypoints).
Definition at line 141 of file LocalPlanner.cpp.
References _max_queue_size, _rng, _sampling_radius, _waypoints_queue, and carla::agents::navigation::LaneFollow.
Referenced by RunStep().
|
inlinestatic |
Construct a LocalPlanner.
If map is null we pull the map from the vehicle's world (matches the Python map_inst fallback). Returns a value-initialized Options. Defined out-of-line because GCC's default-arg parser refuses = {} / = Options() when the struct inherits from another aggregate with default member initializers.
Definition at line 148 of file LocalPlanner.h.
Referenced by TEST().
| bool carla::agents::navigation::LocalPlanner::Done | ( | ) | const |
True when the queue is empty.
Definition at line 285 of file LocalPlanner.cpp.
References _waypoints_queue.
| void carla::agents::navigation::LocalPlanner::FollowSpeedLimits | ( | bool | value = true | ) |
Toggle automatic following of road speed limits.
Definition at line 137 of file LocalPlanner.cpp.
References _follow_speed_limits.
| std::pair< SharedPtr< client::Waypoint >, RoadOption > carla::agents::navigation::LocalPlanner::GetIncomingWaypointAndDirection | ( | int | steps = 3 | ) | const |
Peek steps ahead in the queue, falling back to the last entry if the queue is too short.
Returns (nullptr, RoadOption::Void) when the queue is empty.
Definition at line 270 of file LocalPlanner.cpp.
References _waypoints_queue, and carla::agents::navigation::Void.
| const std::deque< LocalPlanner::PlanItem > & carla::agents::navigation::LocalPlanner::GetPlan | ( | ) | const |
Read-only view of the queued plan.
Definition at line 281 of file LocalPlanner.cpp.
References _waypoints_queue.
|
private |
Build the VehiclePIDController and seed the queue with the vehicle's current waypoint.
Called from the constructor.
Definition at line 107 of file LocalPlanner.cpp.
References _lateral_args, _longitudinal_args, _map, _max_brake, _max_steering, _max_throttle, _offset, _target_road_option, _target_waypoint, _vehicle, _vehicle_controller, _waypoints_queue, and carla::agents::navigation::LaneFollow.
Referenced by LocalPlanner().
| void carla::agents::navigation::LocalPlanner::ResetVehicle | ( | ) |
Drop the vehicle reference (mirrors reset_vehicle).
Definition at line 125 of file LocalPlanner.cpp.
References _vehicle.
| rpc::VehicleControl carla::agents::navigation::LocalPlanner::RunStep | ( | bool | debug = false | ) |
Drive one tick. Returns the VehicleControl to apply.
Definition at line 212 of file LocalPlanner.cpp.
References _base_min_distance, _distance_ratio, _follow_speed_limits, _min_queue_length, _stop_waypoint_creation, _target_road_option, _target_speed, _target_waypoint, _vehicle, _vehicle_controller, _waypoints_queue, carla::rpc::VehicleControl::brake, ComputeNextWaypoints(), carla::agents::navigation::DrawWaypoints(), carla::agents::navigation::GetSpeed(), carla::rpc::VehicleControl::hand_brake, carla::rpc::VehicleControl::manual_gear_shift, carla::rpc::VehicleControl::steer, and carla::rpc::VehicleControl::throttle.
| void carla::agents::navigation::LocalPlanner::SetGlobalPlan | ( | const std::vector< PlanItem > & | plan, |
| bool | stop_waypoint_creation = true, |
||
| bool | clean_queue = true |
||
| ) |
Replace (or append to) the waypoint queue.
Definition at line 183 of file LocalPlanner.cpp.
References _max_queue_size, _stop_waypoint_creation, and _waypoints_queue.
| void carla::agents::navigation::LocalPlanner::SetOffset | ( | float | offset | ) |
Apply a lateral offset to the underlying PID controller.
Definition at line 205 of file LocalPlanner.cpp.
References _offset, and _vehicle_controller.
| void carla::agents::navigation::LocalPlanner::SetSpeed | ( | float | speed_kmh | ) |
Override the target speed in km/h.
Definition at line 129 of file LocalPlanner.cpp.
References _follow_speed_limits, and _target_speed.
| RoadOption carla::agents::navigation::LocalPlanner::TargetRoadOption | ( | ) | const |
Currently active target RoadOption (mirrors target_road_option).
Definition at line 293 of file LocalPlanner.cpp.
References _target_road_option.
| SharedPtr< client::Waypoint > carla::agents::navigation::LocalPlanner::TargetWaypoint | ( | ) | const |
Currently active target waypoint (mirrors target_waypoint).
Definition at line 289 of file LocalPlanner.cpp.
References _target_waypoint.
|
private |
Definition at line 140 of file LocalPlanner.h.
Referenced by RunStep().
|
private |
Definition at line 141 of file LocalPlanner.h.
Referenced by RunStep().
|
private |
Definition at line 131 of file LocalPlanner.h.
|
private |
Definition at line 142 of file LocalPlanner.h.
Referenced by FollowSpeedLimits(), RunStep(), and SetSpeed().
|
private |
Definition at line 134 of file LocalPlanner.h.
Referenced by InitController().
|
private |
Definition at line 135 of file LocalPlanner.h.
Referenced by InitController().
|
private |
Definition at line 118 of file LocalPlanner.h.
Referenced by InitController(), and LocalPlanner().
|
private |
Definition at line 137 of file LocalPlanner.h.
Referenced by InitController().
|
private |
Definition at line 126 of file LocalPlanner.h.
Referenced by ComputeNextWaypoints(), and SetGlobalPlan().
|
private |
Definition at line 138 of file LocalPlanner.h.
Referenced by InitController().
|
private |
Definition at line 136 of file LocalPlanner.h.
Referenced by InitController().
|
private |
Definition at line 127 of file LocalPlanner.h.
Referenced by RunStep().
|
private |
Definition at line 139 of file LocalPlanner.h.
Referenced by InitController(), and SetOffset().
|
mutableprivate |
Definition at line 145 of file LocalPlanner.h.
Referenced by ComputeNextWaypoints().
|
private |
Definition at line 133 of file LocalPlanner.h.
Referenced by ComputeNextWaypoints().
|
private |
Definition at line 128 of file LocalPlanner.h.
Referenced by RunStep(), and SetGlobalPlan().
|
private |
Definition at line 123 of file LocalPlanner.h.
Referenced by InitController(), RunStep(), and TargetRoadOption().
|
private |
Definition at line 132 of file LocalPlanner.h.
Referenced by RunStep(), and SetSpeed().
|
private |
Definition at line 122 of file LocalPlanner.h.
Referenced by InitController(), RunStep(), and TargetWaypoint().
|
private |
Definition at line 117 of file LocalPlanner.h.
Referenced by InitController(), LocalPlanner(), ResetVehicle(), and RunStep().
|
private |
Definition at line 120 of file LocalPlanner.h.
Referenced by InitController(), RunStep(), and SetOffset().
|
private |
Definition at line 125 of file LocalPlanner.h.
Referenced by ComputeNextWaypoints(), Done(), GetIncomingWaypointAndDirection(), GetPlan(), InitController(), RunStep(), and SetGlobalPlan().