Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[sumo-user] Error while getting information from vehicle

I have the following client code:


#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);


    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;

    }


    client.close();

}




I run sumo like this:             sudo sumo --remote-port 47000 -c map.sumocfg &

Then I run client program:   ./client 1


So the program should continuously print the position of vehicle with id 1. It is printing for some time, and after some time the program exiting by throwing the following error:


terminate called after throwing an instance of 'tcpip::SocketException'

  what():  .. Answered with error to command (164), [description: Vehicle '1' is not known]

Aborted (core dumped)



What might have caused this error?


Muktadir



Back to the top