Expand description
§traci-rs
A pure-Rust client library for the SUMO TraCI (Traffic Control Interface) protocol.
§Quick start
use traci_rs::TraciClient;
fn main() -> Result<(), traci_rs::TraciError> {
let mut client = TraciClient::connect("127.0.0.1", 8813)?;
client.set_order(1)?;
// Advance the simulation one step
client.simulation_step(0.0)?;
// Query all vehicles
let ids = client.vehicle.get_id_list(&mut client)?;
for id in &ids {
let pos = client.vehicle.get_position(&mut client, id)?;
println!("{}: ({}, {})", id, pos.x, pos.y);
}
client.close()?;
Ok(())
}Re-exports§
pub use client::TraciClient;pub use error::TraciError;pub use types::SubscribedKinematics;pub use types::*;
Modules§
- client
- Core
TraciClient— connection, lifecycle, protocol helpers, and scope access. - constants
- TraCI protocol constants — direct translation of
libsumo/TraCIConstants.h. - error
- Error types for the
sumo-tracicrate. - socket
- TCP socket layer — equivalent to
tcpip::Socketin the C++ library. - storage
- Binary serialisation buffer — equivalent to
tcpip::Storagein the C++ library. - types
- Data structures and the
TraciValueenum — translation oflibsumo/TraCIDefs.h.
Macros§
- impl_
scope_ accessors - Generate the common subscription-result accessors for a scope struct.
- scope_
get_ color - scope_
get_ double - Generate the
get_id_listandget_id_countmethods for a scope, plus the generic parameter API, and subscription helpers. - scope_
get_ double_ list - scope_
get_ int - scope_
get_ polygon - scope_
get_ pos - scope_
get_ pos3d - scope_
get_ string - scope_
get_ string_ list - scope_
set_ double - scope_
set_ int - scope_
set_ string - scope_
set_ string_ list
Structs§
- Edge
Scope - Scope for interacting with SUMO edge objects.
- Junction
Scope - Scope for interacting with SUMO junction objects.
- Lane
Scope - Scope for interacting with SUMO lane objects.
- Person
Scope - Scope for interacting with SUMO person objects.
- Route
Scope - Scope for interacting with SUMO route objects.
- Simulation
Scope - Scope for querying and controlling the SUMO simulation.
- Traffic
Light Scope - Scope for interacting with SUMO traffic light objects.
- Vehicle
Scope - Scope for interacting with SUMO vehicle objects.
- Vehicle
Type Scope - Scope for interacting with SUMO vehicle type objects.