Skip to main content

Crate traci_rs

Crate traci_rs 

Source
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-traci crate.
socket
TCP socket layer — equivalent to tcpip::Socket in the C++ library.
storage
Binary serialisation buffer — equivalent to tcpip::Storage in the C++ library.
types
Data structures and the TraciValue enum — translation of libsumo/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_list and get_id_count methods 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§

EdgeScope
Scope for interacting with SUMO edge objects.
JunctionScope
Scope for interacting with SUMO junction objects.
LaneScope
Scope for interacting with SUMO lane objects.
PersonScope
Scope for interacting with SUMO person objects.
RouteScope
Scope for interacting with SUMO route objects.
SimulationScope
Scope for querying and controlling the SUMO simulation.
TrafficLightScope
Scope for interacting with SUMO traffic light objects.
VehicleScope
Scope for interacting with SUMO vehicle objects.
VehicleTypeScope
Scope for interacting with SUMO vehicle type objects.