CARLA
Loading...
Searching...
No Matches
Classes | Public Member Functions | Static Public Member Functions | Private Member Functions | Private Attributes | List of all members
carla::agents::navigation::ConstantVelocityAgent Class Reference

C++ port of agents.navigation.constant_velocity_agent.ConstantVelocityAgent. More...

#include <ConstantVelocityAgent.h>

+ Inheritance diagram for carla::agents::navigation::ConstantVelocityAgent:

Classes

struct  ConstantOptions
 

Public Member Functions

 ConstantVelocityAgent (SharedPtr< client::Vehicle > vehicle, float target_speed_kmh=20.0f, const ConstantOptions &opts=DefaultConstantOptions(), SharedPtr< client::Map > map=nullptr, SharedPtr< GlobalRoutePlanner > grp=nullptr)
 
void DestroySensor ()
 Tear down the collision sensor (called from the destructor too).
 
void RestartConstantVelocity ()
 Re-enable constant velocity at the current _target_speed_ms.
 
rpc::VehicleControl RunStep () override
 
void SetTargetSpeed (float speed_kmh)
 Hides BasicAgent::SetTargetSpeed; converts km/h to m/s for the internal _target_speed_ms and forwards to the planner.
 
void StopConstantVelocity ()
 Disables constant velocity mode and stamps the stop time.
 
 ~ConstantVelocityAgent () override
 
- Public Member Functions inherited from carla::agents::navigation::BasicAgent
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.
 
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 ConstantOptions DefaultConstantOptions ()
 Out-of-line default factory; see LocalPlanner::DefaultOptions().
 
- Static Public Member Functions inherited from carla::agents::navigation::BasicAgent
static Options DefaultOptions ()
 Out-of-line default factory; see LocalPlanner::DefaultOptions().
 

Private Member Functions

void SetCollisionSensor ()
 
void SetConstantVelocity (float speed_ms)
 

Private Attributes

SharedPtr< client::Sensor > _collision_sensor
 
double _constant_velocity_stop_time
 
bool _has_stop_timestamp
 
bool _is_constant_velocity_active
 
float _restart_time
 
float _target_speed_ms
 
bool _use_basic_behavior
 

Additional Inherited Members

- Protected Member Functions inherited from carla::agents::navigation::BasicAgent
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 inherited from carla::agents::navigation::BasicAgent
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
 

Detailed Description

C++ port of agents.navigation.constant_velocity_agent.ConstantVelocityAgent.

Drives the ego at a fixed velocity, using BasicAgent's planner just to keep the wheels rotating. A collision sensor is attached on construction and a collision flips the agent into a "stopped" state.

Definition at line 32 of file ConstantVelocityAgent.h.

Constructor & Destructor Documentation

◆ ConstantVelocityAgent()

carla::agents::navigation::ConstantVelocityAgent::ConstantVelocityAgent ( SharedPtr< client::Vehicle >  vehicle,
float  target_speed_kmh = 20.0f,
const ConstantOptions &  opts = DefaultConstantOptions(),
SharedPtr< client::Map >  map = nullptr,
SharedPtr< GlobalRoutePlanner >  grp = nullptr 
)

◆ ~ConstantVelocityAgent()

carla::agents::navigation::ConstantVelocityAgent::~ConstantVelocityAgent ( )
override

Definition at line 49 of file ConstantVelocityAgent.cpp.

References DestroySensor().

Member Function Documentation

◆ DefaultConstantOptions()

ConstantVelocityAgent::ConstantOptions carla::agents::navigation::ConstantVelocityAgent::DefaultConstantOptions ( )
inlinestatic

Out-of-line default factory; see LocalPlanner::DefaultOptions().

Definition at line 84 of file ConstantVelocityAgent.h.

Referenced by TEST().

◆ DestroySensor()

void carla::agents::navigation::ConstantVelocityAgent::DestroySensor ( )

Tear down the collision sensor (called from the destructor too).

Definition at line 159 of file ConstantVelocityAgent.cpp.

References _collision_sensor.

Referenced by ~ConstantVelocityAgent().

◆ RestartConstantVelocity()

void carla::agents::navigation::ConstantVelocityAgent::RestartConstantVelocity ( )

Re-enable constant velocity at the current _target_speed_ms.

Definition at line 66 of file ConstantVelocityAgent.cpp.

References _is_constant_velocity_active, _target_speed_ms, and SetConstantVelocity().

Referenced by RunStep().

◆ RunStep()

rpc::VehicleControl carla::agents::navigation::ConstantVelocityAgent::RunStep ( )
overridevirtual

◆ SetCollisionSensor()

void carla::agents::navigation::ConstantVelocityAgent::SetCollisionSensor ( )
private

◆ SetConstantVelocity()

void carla::agents::navigation::ConstantVelocityAgent::SetConstantVelocity ( float  speed_ms)
private

◆ SetTargetSpeed()

void carla::agents::navigation::ConstantVelocityAgent::SetTargetSpeed ( float  speed_kmh)

Hides BasicAgent::SetTargetSpeed; converts km/h to m/s for the internal _target_speed_ms and forwards to the planner.

Definition at line 53 of file ConstantVelocityAgent.cpp.

References carla::agents::navigation::BasicAgent::_local_planner, and _target_speed_ms.

◆ StopConstantVelocity()

void carla::agents::navigation::ConstantVelocityAgent::StopConstantVelocity ( )

Disables constant velocity mode and stamps the stop time.

The agent will sit idle until restart_time has elapsed (then auto-restart) or RestartConstantVelocity is called manually.

Definition at line 58 of file ConstantVelocityAgent.cpp.

References _constant_velocity_stop_time, _has_stop_timestamp, _is_constant_velocity_active, carla::agents::navigation::BasicAgent::_vehicle, and carla::agents::navigation::BasicAgent::_world.

Referenced by SetCollisionSensor().

Member Data Documentation

◆ _collision_sensor

SharedPtr<client::Sensor> carla::agents::navigation::ConstantVelocityAgent::_collision_sensor
private

Definition at line 80 of file ConstantVelocityAgent.h.

Referenced by DestroySensor(), and SetCollisionSensor().

◆ _constant_velocity_stop_time

double carla::agents::navigation::ConstantVelocityAgent::_constant_velocity_stop_time
private

Definition at line 77 of file ConstantVelocityAgent.h.

Referenced by RunStep(), and StopConstantVelocity().

◆ _has_stop_timestamp

bool carla::agents::navigation::ConstantVelocityAgent::_has_stop_timestamp
private

Definition at line 78 of file ConstantVelocityAgent.h.

Referenced by RunStep(), and StopConstantVelocity().

◆ _is_constant_velocity_active

bool carla::agents::navigation::ConstantVelocityAgent::_is_constant_velocity_active
private

Definition at line 76 of file ConstantVelocityAgent.h.

Referenced by RestartConstantVelocity(), RunStep(), and StopConstantVelocity().

◆ _restart_time

float carla::agents::navigation::ConstantVelocityAgent::_restart_time
private

Definition at line 75 of file ConstantVelocityAgent.h.

Referenced by RunStep().

◆ _target_speed_ms

float carla::agents::navigation::ConstantVelocityAgent::_target_speed_ms
private

◆ _use_basic_behavior

bool carla::agents::navigation::ConstantVelocityAgent::_use_basic_behavior
private

Definition at line 73 of file ConstantVelocityAgent.h.

Referenced by RunStep().


The documentation for this class was generated from the following files: