Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[sumo-user] Running simulation and getting vehicle information independently

I have the following Traci Client program.


#include <iostream>

#include <stdlib.h>

#include <string>

#include "TraCIAPI.h"


class Client : public TraCIAPI {

public:

    Client() {};

    ~Client() {};

};


int main(int argc, char* argv[]) {

    Client client;

    int order = atoi(argv[1]);


    client.connect("localhost", 47000);


    std::cout << "run 5 steps ...\n";


    TraCIAPI::VehicleScope vehicleScope(client);


    while(true ) {

        client.simulationStep();

        libsumo::TraCIPosition pos = vehicleScope.getPosition(std::to_string(order));

        std::cout << pos.x << ", " << pos.y  << std::endl;

    }


    std::cout << "time in ms: " << client.simulation.getCurrentTime() << "\n";

    client.close();

}


Here in the while() loop I am advancing the simulation and getting vehicle information. My question is, is it possible to advance the simulation in one place (like in another thread) and get vehicle position in another place ?


-Muktadir


Back to the top