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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
//! This is a simple traffic simulation module with a focus on performance and realism.
//!
//! This is a personal project, with currently poor documentation and is not quite feature complete.
//!
//! ## Goals
//!
//! The goal of this package is to be capable of simulating any road network in a realistic manner,
//! with reasonable performance. This includes simulating things such as:
//!
//! * Car following
//! * Lane-changing decisions and dynamics
//! * Yielding at give way/stop signs
//! * Merging and diverging
//! * Simple path finding
//!
//! The primary gap right now is the lack of a lane-changing.
//! There are pieces in place, but it is in general a very hard problem to solve.
//!
//! # Hello world
//! This sample code demonstrates how to simulate a single vehicle on a straight, single-lane road.
//!
//! ```
//! use traffic_sim::{Simulation, LinkAttributes, VehicleAttributes};
//! use traffic_sim::math::{LineSegment2d, Point2d};
//!
//! // Create a simulation
//! let mut simulation = Simulation::new();
//!
//! // Add a link, which is a single lane of traffic
//! // This one is a straight line 100m long
//! let link_id = simulation.add_link(&LinkAttributes {
//! curve: &LineSegment2d::from_ends(Point2d::new(0.0, 0.0), Point2d::new(100.0, 0.0)),
//! speed_limit: 16.6667, // m/s (60km/h)
//! });
//!
//! // Add a vehicle to the start of the link we just created
//! let veh_id = simulation.add_vehicle(&VehicleAttributes {
//! width: 2.0, // m
//! length: 5.0, // m
//! wheel_base: 1.5, // m
//! max_acc: 2.0, // m
//! comf_dec: 2.0, // m
//! }, link_id);
//!
//! // Simulate 10 frames, each advancing time by 0.1s.
//! // Each frame, print out the coordinates of our single vehicle
//! for _ in 0..10 {
//! simulation.step(0.1);
//! println!("Vehicle is at {:?}", simulation.get_vehicle(veh_id).position());
//! }
//! ```
pub use cgmath;
pub use LinkGroup;
pub use TrafficLight;
pub use ;
pub use Simulation;
use ;
pub use ;
pub use Interval;
pub use ;
new_key_type!
type LinkSet = ;
type VehicleSet = ;