CARLA
Loading...
Searching...
No Matches
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"
11
12#include <limits>
13
14namespace carla {
15
16namespace client {
17 class Map;
18 class Sensor;
19 class Vehicle;
20} // namespace client
21
22namespace agents {
23namespace 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.
33 public:
34
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().
42
44 float target_speed_kmh = 20.0f,
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.
59
60 /// Re-enable constant velocity at the current `_target_speed_ms`.
62
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
74 float _target_speed_ms; // m/s — note BasicAgent's _target_speed is km/h
79
81 };
82
87
88} // namespace navigation
89} // namespace agents
90} // namespace carla
C++ port of agents.navigation.basic_agent.BasicAgent.
Definition BasicAgent.h:44
C++ port of agents.navigation.constant_velocity_agent.ConstantVelocityAgent.
void RestartConstantVelocity()
Re-enable constant velocity at the current _target_speed_ms.
void StopConstantVelocity()
Disables constant velocity mode and stamps the stop time.
static ConstantOptions DefaultConstantOptions()
Out-of-line default factory; see LocalPlanner::DefaultOptions().
void DestroySensor()
Tear down the collision sensor (called from the destructor too).
void SetTargetSpeed(float speed_kmh)
Hides BasicAgent::SetTargetSpeed; converts km/h to m/s for the internal _target_speed_ms and forwards...
This file contains definitions of common data structures used in traffic manager.
std::shared_ptr< T > SharedPtr
Definition Memory.h:15