1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
//! CARLA navigation agents system for autonomous vehicle control.
//!
//! This module provides autonomous vehicle control through a layered architecture,
//! corresponding to the Python API's
//! [agents](https://carla.readthedocs.io/en/0.9.16/adv_agents/)
//! package.
//!
//! # Key Components
//!
//! - **Navigation**: High-level route planning and trajectory following
//! - **Tools**: Utility functions for agent operations
//!
//! ## Component Hierarchy
//!
//! ```text
//! GlobalRoutePlanner (high-level path planning)
//! ↓
//! LocalPlanner (trajectory following + PID control)
//! ↓
//! VehiclePIDController (low-level vehicle control)
//! ├─ PIDLongitudinalController (throttle/brake)
//! └─ PIDLateralController (steering)
//! ```
//!
//! # Python API Reference
//!
//! See the [CARLA Agents](https://carla.readthedocs.io/en/0.9.16/adv_agents/)
//! documentation for the Python equivalent.
//!
//! ## Usage Example
//!
//! ```no_run
//! use carla::client::Client;
//! use carla::agents::navigation::BasicAgent;
//!
//! # fn main() -> eyre::Result<()> {
//! let client = Client::new("localhost:2000", 10)?;
//! let mut world = client.world();
//!
//! // Spawn vehicle
//! let vehicle = /* spawn vehicle */;
//!
//! // Create agent
//! let mut agent = BasicAgent::new(&vehicle, 30.0)?;
//! agent.follow_speed_limits(true);
//!
//! // Set destination
//! let destination = /* some location */;
//! agent.set_destination(destination)?;
//!
//! // Control loop
//! while !agent.done() {
//! world.tick()?;
//! let control = agent.run_step()?;
//! vehicle.apply_control(&control)?;
//! }
//! # Ok(())
//! # }
//! ```