|
CARLA
|
C++ port of agents.navigation.basic_agent.BasicAgent. More...
#include <BasicAgent.h>
Inheritance diagram for carla::agents::navigation::BasicAgent:Classes | |
| struct | Options |
| Tunable knobs. More... | |
| struct | VehicleObstacle |
Public Member Functions | |
| rpc::VehicleControl | AddEmergencyStop (rpc::VehicleControl c) const |
| Overwrites throttle/brake to perform an emergency stop. | |
| BasicAgent (SharedPtr< client::Vehicle > vehicle, float target_speed_kmh=20.0f, const Options &options=DefaultOptions(), SharedPtr< client::Map > map=nullptr, SharedPtr< GlobalRoutePlanner > grp=nullptr) | |
| bool | Done () const |
| void | FollowSpeedLimits (bool value=true) |
| GlobalRoutePlanner * | GetGlobalPlanner () |
| LocalPlanner * | GetLocalPlanner () |
| void | IgnoreStopSigns (bool active=true) |
| void | IgnoreTrafficLights (bool active=true) |
| void | IgnoreVehicles (bool active=true) |
| void | LaneChange (const std::string &direction, float same_lane_time=0.0f, float other_lane_time=0.0f, float lane_change_time=2.0f) |
| Replaces the current plan with one that performs a lane change. | |
| virtual rpc::VehicleControl | RunStep () |
| void | SetDestination (const geom::Location &end, std::optional< geom::Location > start=std::nullopt) |
Computes a route from start (or the current target waypoint) to end and forwards it to the local planner. | |
| void | SetGlobalPlan (const std::vector< LocalPlanner::PlanItem > &plan, bool stop_waypoint_creation=true, bool clean_queue=true) |
| void | SetOffset (float offset) |
| void | SetTargetSpeed (float speed_kmh) |
| std::vector< LocalPlanner::PlanItem > | TraceRoute (SharedPtr< client::Waypoint > start, SharedPtr< client::Waypoint > end) |
| virtual | ~BasicAgent ()=default |
Static Public Member Functions | |
| static Options | DefaultOptions () |
| Out-of-line default factory; see LocalPlanner::DefaultOptions(). | |
Protected Member Functions | |
| std::pair< bool, SharedPtr< client::TrafficLight > > | AffectedByTrafficLight (SharedPtr< client::ActorList > lights=nullptr, std::optional< float > max_distance=std::nullopt) |
Returns (affected, light) similar to Python _affected_by_traffic_light. | |
| std::vector< LocalPlanner::PlanItem > | GenerateLaneChangePath (SharedPtr< client::Waypoint > waypoint, const std::string &direction="left", float distance_same_lane=10.0f, float distance_other_lane=25.0f, float lane_change_distance=25.0f, bool check=true, int lane_changes=1, float step_distance=2.0f) |
Mirrors Python _generate_lane_change_path. | |
| VehicleObstacle | VehicleObstacleDetected (SharedPtr< client::ActorList > vehicles=nullptr, std::optional< float > max_distance=std::nullopt, float up_angle_th=90.0f, float low_angle_th=0.0f, int lane_offset=0) |
Mirrors Python _vehicle_obstacle_detected. | |
Protected Attributes | |
| float | _base_tlight_threshold |
| float | _base_vehicle_threshold |
| SharedPtr< GlobalRoutePlanner > | _global_planner |
| bool | _ignore_stop_signs |
| bool | _ignore_traffic_lights |
| bool | _ignore_vehicles |
| SharedPtr< client::TrafficLight > | _last_traffic_light |
| SharedPtr< client::ActorList > | _lights_list |
| std::unordered_map< uint32_t, SharedPtr< client::Waypoint > > | _lights_map |
| std::unique_ptr< LocalPlanner > | _local_planner |
| SharedPtr< client::Map > | _map |
| float | _max_brake |
| float | _offset |
| float | _sampling_resolution |
| float | _speed_ratio |
| float | _target_speed |
| bool | _use_bbs_detection |
| SharedPtr< client::Vehicle > | _vehicle |
| SharedPtr< client::World > | _world |
C++ port of agents.navigation.basic_agent.BasicAgent.
Roams the scene following random or scripted waypoints while obeying traffic lights and avoiding other vehicles. Stop signs are ignored.
Definition at line 44 of file BasicAgent.h.
| carla::agents::navigation::BasicAgent::BasicAgent | ( | SharedPtr< client::Vehicle > | vehicle, |
| float | target_speed_kmh = 20.0f, |
||
| const Options & | options = DefaultOptions(), |
||
| SharedPtr< client::Map > | map = nullptr, |
||
| SharedPtr< GlobalRoutePlanner > | grp = nullptr |
||
| ) |
Definition at line 63 of file BasicAgent.cpp.
References _global_planner, _lights_list, _local_planner, _map, _sampling_resolution, _vehicle, _world, and carla::agents::navigation::LocalPlanner::Options::target_speed.
|
virtualdefault |
| rpc::VehicleControl carla::agents::navigation::BasicAgent::AddEmergencyStop | ( | rpc::VehicleControl | c | ) | const |
Overwrites throttle/brake to perform an emergency stop.
Steering is left intact so the agent doesn't drift mid-turn.
Definition at line 108 of file BasicAgent.cpp.
References _max_brake, carla::rpc::VehicleControl::brake, carla::rpc::VehicleControl::hand_brake, and carla::rpc::VehicleControl::throttle.
Referenced by RunStep().
|
protected |
Returns (affected, light) similar to Python _affected_by_traffic_light.
lights may be null — in which case all traffic_light actors are pulled from the world. max_distance defaults to _base_tlight_threshold.
Definition at line 242 of file BasicAgent.cpp.
References _base_tlight_threshold, _ignore_traffic_lights, _last_traffic_light, _lights_map, _map, _vehicle, _world, carla::agents::navigation::GetTrafficLightTriggerLocation(), carla::agents::navigation::IsWithinDistance(), and carla::rpc::Red.
Referenced by RunStep(), carla::agents::navigation::ConstantVelocityAgent::RunStep(), and carla::agents::navigation::BehaviorAgent::TrafficLightManager().
|
inlinestatic |
Out-of-line default factory; see LocalPlanner::DefaultOptions().
Definition at line 171 of file BasicAgent.h.
Referenced by TEST().
| bool carla::agents::navigation::BasicAgent::Done | ( | ) | const |
Definition at line 206 of file BasicAgent.cpp.
References _local_planner.
| void carla::agents::navigation::BasicAgent::FollowSpeedLimits | ( | bool | value = true | ) |
Definition at line 120 of file BasicAgent.cpp.
References _local_planner.
|
protected |
Mirrors Python _generate_lane_change_path.
Returns an empty vector if no valid path exists.
Definition at line 487 of file BasicAgent.cpp.
References carla::agents::navigation::ChangeLaneLeft, carla::agents::navigation::ChangeLaneRight, distance, and carla::agents::navigation::LaneFollow.
Referenced by LaneChange().
| GlobalRoutePlanner * carla::agents::navigation::BasicAgent::GetGlobalPlanner | ( | ) |
Definition at line 128 of file BasicAgent.cpp.
References _global_planner.
| LocalPlanner * carla::agents::navigation::BasicAgent::GetLocalPlanner | ( | ) |
Definition at line 124 of file BasicAgent.cpp.
References _local_planner.
| void carla::agents::navigation::BasicAgent::IgnoreStopSigns | ( | bool | active = true | ) |
Definition at line 211 of file BasicAgent.cpp.
References _ignore_stop_signs.
| void carla::agents::navigation::BasicAgent::IgnoreTrafficLights | ( | bool | active = true | ) |
Definition at line 210 of file BasicAgent.cpp.
References _ignore_traffic_lights.
| void carla::agents::navigation::BasicAgent::IgnoreVehicles | ( | bool | active = true | ) |
Definition at line 212 of file BasicAgent.cpp.
References _ignore_vehicles.
| void carla::agents::navigation::BasicAgent::LaneChange | ( | const std::string & | direction, |
| float | same_lane_time = 0.0f, |
||
| float | other_lane_time = 0.0f, |
||
| float | lane_change_time = 2.0f |
||
| ) |
Replaces the current plan with one that performs a lane change.
direction must be "left" or "right".
Definition at line 218 of file BasicAgent.cpp.
References _map, _sampling_resolution, _vehicle, GenerateLaneChangePath(), and SetGlobalPlan().
|
virtual |
Reimplemented in carla::agents::navigation::BehaviorAgent, and carla::agents::navigation::ConstantVelocityAgent.
Definition at line 175 of file BasicAgent.cpp.
References _base_tlight_threshold, _base_vehicle_threshold, _lights_list, _local_planner, _speed_ratio, _vehicle, _world, AddEmergencyStop(), AffectedByTrafficLight(), carla::agents::navigation::GetSpeed(), and VehicleObstacleDetected().
Referenced by carla::agents::navigation::ConstantVelocityAgent::RunStep().
| void carla::agents::navigation::BasicAgent::SetDestination | ( | const geom::Location & | end, |
| std::optional< geom::Location > | start = std::nullopt |
||
| ) |
Computes a route from start (or the current target waypoint) to end and forwards it to the local planner.
Definition at line 132 of file BasicAgent.cpp.
References _local_planner, _map, _vehicle, and TraceRoute().
Referenced by carla::agents::navigation::BehaviorAgent::Tailgating().
| void carla::agents::navigation::BasicAgent::SetGlobalPlan | ( | const std::vector< LocalPlanner::PlanItem > & | plan, |
| bool | stop_waypoint_creation = true, |
||
| bool | clean_queue = true |
||
| ) |
Definition at line 160 of file BasicAgent.cpp.
References _local_planner.
Referenced by LaneChange().
| void carla::agents::navigation::BasicAgent::SetOffset | ( | float | offset | ) |
Definition at line 214 of file BasicAgent.cpp.
References _local_planner.
| void carla::agents::navigation::BasicAgent::SetTargetSpeed | ( | float | speed_kmh | ) |
Definition at line 115 of file BasicAgent.cpp.
References _local_planner, and _target_speed.
| std::vector< LocalPlanner::PlanItem > carla::agents::navigation::BasicAgent::TraceRoute | ( | SharedPtr< client::Waypoint > | start, |
| SharedPtr< client::Waypoint > | end | ||
| ) |
Definition at line 167 of file BasicAgent.cpp.
References _global_planner.
Referenced by SetDestination().
|
protected |
Mirrors Python _vehicle_obstacle_detected.
Definition at line 331 of file BasicAgent.cpp.
References _base_vehicle_threshold, _ignore_vehicles, _local_planner, _map, _offset, _use_bbs_detection, _vehicle, _world, carla::agents::navigation::BasicAgent::VehicleObstacle::actor, carla::agents::navigation::BasicAgent::VehicleObstacle::affected, carla::agents::navigation::ComputeDistance(), carla::agents::navigation::BasicAgent::VehicleObstacle::distance, carla::geom::Transform::GetForwardVector(), carla::agents::navigation::IsWithinDistance(), carla::geom::Transform::location, carla::geom::Vector3D::x, carla::geom::Vector3D::y, and carla::geom::Vector3D::z.
Referenced by carla::agents::navigation::BehaviorAgent::CollisionAndCarAvoidManager(), carla::agents::navigation::BehaviorAgent::PedestrianAvoidManager(), RunStep(), carla::agents::navigation::ConstantVelocityAgent::RunStep(), and carla::agents::navigation::BehaviorAgent::Tailgating().
|
protected |
Definition at line 164 of file BasicAgent.h.
Referenced by AffectedByTrafficLight(), RunStep(), and carla::agents::navigation::ConstantVelocityAgent::RunStep().
|
protected |
Definition at line 165 of file BasicAgent.h.
Referenced by RunStep(), carla::agents::navigation::ConstantVelocityAgent::RunStep(), and VehicleObstacleDetected().
|
protected |
Definition at line 154 of file BasicAgent.h.
Referenced by BasicAgent(), GetGlobalPlanner(), and TraceRoute().
|
protected |
Definition at line 159 of file BasicAgent.h.
Referenced by IgnoreStopSigns().
|
protected |
Definition at line 158 of file BasicAgent.h.
Referenced by AffectedByTrafficLight(), and IgnoreTrafficLights().
|
protected |
Definition at line 160 of file BasicAgent.h.
Referenced by IgnoreVehicles(), and VehicleObstacleDetected().
|
protected |
Definition at line 152 of file BasicAgent.h.
Referenced by AffectedByTrafficLight().
|
protected |
Definition at line 155 of file BasicAgent.h.
Referenced by BasicAgent(), and RunStep().
|
protected |
Definition at line 156 of file BasicAgent.h.
Referenced by AffectedByTrafficLight().
|
protected |
Definition at line 153 of file BasicAgent.h.
Referenced by BasicAgent(), carla::agents::navigation::BehaviorAgent::CarFollowingManager(), Done(), FollowSpeedLimits(), GetLocalPlanner(), RunStep(), carla::agents::navigation::ConstantVelocityAgent::RunStep(), carla::agents::navigation::BehaviorAgent::RunStep(), SetDestination(), SetGlobalPlan(), SetOffset(), SetTargetSpeed(), carla::agents::navigation::ConstantVelocityAgent::SetTargetSpeed(), carla::agents::navigation::BehaviorAgent::Tailgating(), carla::agents::navigation::BehaviorAgent::UpdateInformation(), and VehicleObstacleDetected().
|
protected |
Definition at line 151 of file BasicAgent.h.
Referenced by AffectedByTrafficLight(), BasicAgent(), LaneChange(), carla::agents::navigation::BehaviorAgent::RunStep(), SetDestination(), and VehicleObstacleDetected().
|
protected |
Definition at line 167 of file BasicAgent.h.
Referenced by AddEmergencyStop(), and carla::agents::navigation::BehaviorAgent::EmergencyStop().
|
protected |
Definition at line 168 of file BasicAgent.h.
Referenced by VehicleObstacleDetected().
|
protected |
Definition at line 163 of file BasicAgent.h.
Referenced by BasicAgent(), carla::agents::navigation::BehaviorAgent::BehaviorAgent(), and LaneChange().
|
protected |
Definition at line 166 of file BasicAgent.h.
Referenced by RunStep().
|
protected |
Definition at line 162 of file BasicAgent.h.
Referenced by SetTargetSpeed().
|
protected |
Definition at line 161 of file BasicAgent.h.
Referenced by VehicleObstacleDetected().
|
protected |
Definition at line 149 of file BasicAgent.h.
Referenced by AffectedByTrafficLight(), BasicAgent(), LaneChange(), RunStep(), carla::agents::navigation::ConstantVelocityAgent::RunStep(), carla::agents::navigation::BehaviorAgent::RunStep(), carla::agents::navigation::ConstantVelocityAgent::SetCollisionSensor(), carla::agents::navigation::ConstantVelocityAgent::SetConstantVelocity(), SetDestination(), carla::agents::navigation::ConstantVelocityAgent::StopConstantVelocity(), carla::agents::navigation::BehaviorAgent::UpdateInformation(), and VehicleObstacleDetected().
|
protected |
Definition at line 150 of file BasicAgent.h.
Referenced by AffectedByTrafficLight(), BasicAgent(), carla::agents::navigation::BehaviorAgent::CollisionAndCarAvoidManager(), carla::agents::navigation::BehaviorAgent::PedestrianAvoidManager(), RunStep(), carla::agents::navigation::ConstantVelocityAgent::RunStep(), carla::agents::navigation::ConstantVelocityAgent::SetCollisionSensor(), carla::agents::navigation::ConstantVelocityAgent::StopConstantVelocity(), carla::agents::navigation::BehaviorAgent::Tailgating(), carla::agents::navigation::BehaviorAgent::TrafficLightManager(), and VehicleObstacleDetected().