CARLA
Toggle main menu visibility
Loading...
Searching...
No Matches
LibCarla
source
carla
agents
navigation
ConstantVelocityAgent.h
Go to the documentation of this file.
1
// Copyright (c) 2018-2020 CVC.
2
//
3
// This work is licensed under the terms of the MIT license.
4
// For a copy, see <https://opensource.org/licenses/MIT>.
5
6
#pragma once
7
8
#include "
carla/Memory.h
"
9
#include "
carla/agents/navigation/BasicAgent.h
"
10
#include "
carla/rpc/VehicleControl.h
"
11
12
#include <limits>
13
14
namespace
carla
{
15
16
namespace
client
{
17
class
Map
;
18
class
Sensor
;
19
class
Vehicle
;
20
}
// namespace client
21
22
namespace
agents
{
23
namespace
navigation
{
24
25
class
GlobalRoutePlanner
;
26
27
/// C++ port of agents.navigation.constant_velocity_agent.ConstantVelocityAgent.
28
///
29
/// Drives the ego at a fixed velocity, using BasicAgent's planner just to
30
/// keep the wheels rotating. A collision sensor is attached on construction
31
/// and a collision flips the agent into a "stopped" state.
32
class
ConstantVelocityAgent
:
public
BasicAgent
{
33
public
:
34
35
struct
ConstantOptions
:
Options
{
36
bool
use_basic_behavior
=
false
;
37
float
restart_time
= std::numeric_limits<float>::infinity();
38
};
39
40
/// Out-of-line default factory; see LocalPlanner::DefaultOptions().
41
static
ConstantOptions
DefaultConstantOptions
();
42
43
ConstantVelocityAgent
(
SharedPtr<client::Vehicle>
vehicle,
44
float
target_speed_kmh = 20.0f,
45
const
ConstantOptions
&opts =
DefaultConstantOptions
(),
46
SharedPtr<client::Map>
map =
nullptr
,
47
SharedPtr<GlobalRoutePlanner>
grp =
nullptr
);
48
49
~ConstantVelocityAgent
()
override
;
50
51
/// Hides BasicAgent::SetTargetSpeed; converts km/h to m/s for the
52
/// internal `_target_speed_ms` and forwards to the planner.
53
void
SetTargetSpeed
(
float
speed_kmh);
54
55
/// Disables constant velocity mode and stamps the stop time. The agent
56
/// will sit idle until `restart_time` has elapsed (then auto-restart) or
57
/// `RestartConstantVelocity` is called manually.
58
void
StopConstantVelocity
();
59
60
/// Re-enable constant velocity at the current `_target_speed_ms`.
61
void
RestartConstantVelocity
();
62
63
rpc::VehicleControl
RunStep
()
override
;
64
65
/// Tear down the collision sensor (called from the destructor too).
66
void
DestroySensor
();
67
68
private
:
69
70
void
SetCollisionSensor
();
71
void
SetConstantVelocity
(
float
speed_ms);
72
73
bool
_use_basic_behavior
;
74
float
_target_speed_ms
;
// m/s — note BasicAgent's _target_speed is km/h
75
float
_restart_time
;
76
bool
_is_constant_velocity_active
;
77
double
_constant_velocity_stop_time
;
78
bool
_has_stop_timestamp
;
79
80
SharedPtr<client::Sensor>
_collision_sensor
;
81
};
82
83
inline
ConstantVelocityAgent::ConstantOptions
84
ConstantVelocityAgent::DefaultConstantOptions
() {
85
return
ConstantOptions
{};
86
}
87
88
}
// namespace navigation
89
}
// namespace agents
90
}
// namespace carla
BasicAgent.h
VehicleControl.h
Memory.h
carla::agents::navigation::BasicAgent::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
BasicAgent.cpp:63
carla::agents::navigation::ConstantVelocityAgent::SetCollisionSensor
void SetCollisionSensor()
Definition
ConstantVelocityAgent.cpp:138
carla::agents::navigation::ConstantVelocityAgent::_restart_time
float _restart_time
Definition
ConstantVelocityAgent.h:75
carla::agents::navigation::ConstantVelocityAgent::_use_basic_behavior
bool _use_basic_behavior
Definition
ConstantVelocityAgent.h:73
carla::agents::navigation::ConstantVelocityAgent::RestartConstantVelocity
void RestartConstantVelocity()
Re-enable constant velocity at the current _target_speed_ms.
Definition
ConstantVelocityAgent.cpp:66
carla::agents::navigation::ConstantVelocityAgent::StopConstantVelocity
void StopConstantVelocity()
Disables constant velocity mode and stamps the stop time.
Definition
ConstantVelocityAgent.cpp:58
carla::agents::navigation::ConstantVelocityAgent::DefaultConstantOptions
static ConstantOptions DefaultConstantOptions()
Out-of-line default factory; see LocalPlanner::DefaultOptions().
Definition
ConstantVelocityAgent.h:84
carla::agents::navigation::ConstantVelocityAgent::DestroySensor
void DestroySensor()
Tear down the collision sensor (called from the destructor too).
Definition
ConstantVelocityAgent.cpp:159
carla::agents::navigation::ConstantVelocityAgent::SetTargetSpeed
void SetTargetSpeed(float speed_kmh)
Hides BasicAgent::SetTargetSpeed; converts km/h to m/s for the internal _target_speed_ms and forwards...
Definition
ConstantVelocityAgent.cpp:53
carla::agents::navigation::ConstantVelocityAgent::_target_speed_ms
float _target_speed_ms
Definition
ConstantVelocityAgent.h:74
carla::agents::navigation::ConstantVelocityAgent::_is_constant_velocity_active
bool _is_constant_velocity_active
Definition
ConstantVelocityAgent.h:76
carla::agents::navigation::ConstantVelocityAgent::_constant_velocity_stop_time
double _constant_velocity_stop_time
Definition
ConstantVelocityAgent.h:77
carla::agents::navigation::ConstantVelocityAgent::RunStep
rpc::VehicleControl RunStep() override
Definition
ConstantVelocityAgent.cpp:75
carla::agents::navigation::ConstantVelocityAgent::_has_stop_timestamp
bool _has_stop_timestamp
Definition
ConstantVelocityAgent.h:78
carla::agents::navigation::ConstantVelocityAgent::_collision_sensor
SharedPtr< client::Sensor > _collision_sensor
Definition
ConstantVelocityAgent.h:80
carla::agents::navigation::ConstantVelocityAgent::SetConstantVelocity
void SetConstantVelocity(float speed_ms)
Definition
ConstantVelocityAgent.cpp:71
carla::agents::navigation::ConstantVelocityAgent::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)
Definition
ConstantVelocityAgent.cpp:30
carla::agents::navigation::GlobalRoutePlanner
C++ port of agents.navigation.global_route_planner.GlobalRoutePlanner.
Definition
GlobalRoutePlanner.h:36
carla::client::Map
Definition
client/Map.h:32
carla::client::Sensor
Definition
LibCarla/source/carla/client/Sensor.h:17
carla::client::Vehicle
Definition
Vehicle.h:33
carla::rpc::VehicleControl
Definition
LibCarla/source/carla/rpc/VehicleControl.h:20
carla::agents::navigation
Definition
BasicAgent.cpp:40
carla::agents
Definition
BasicAgent.cpp:39
carla::client
Definition
BasicAgent.h:24
carla
This file contains definitions of common data structures used in traffic manager.
Definition
SignComponent.h:21
carla::SharedPtr
std::shared_ptr< T > SharedPtr
Definition
Memory.h:15
carla::agents::navigation::BasicAgent::Options
Tunable knobs.
Definition
BasicAgent.h:49
carla::agents::navigation::ConstantVelocityAgent::ConstantOptions
Definition
ConstantVelocityAgent.h:35
carla::agents::navigation::ConstantVelocityAgent::ConstantOptions::restart_time
float restart_time
Definition
ConstantVelocityAgent.h:37
carla::agents::navigation::ConstantVelocityAgent::ConstantOptions::use_basic_behavior
bool use_basic_behavior
Definition
ConstantVelocityAgent.h:36
Generated by
1.18.0