Skip to main content

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

Once vehicle '1' leaves the simulation by arriving at it's destination, requesting it's position raises an exception. The easiest solution is to catch the exception and do nothing.
You can also prevent vehicle '1' from leaving the simulation by modifying it's route or adding at <stop> on the final edge to keep it in the simulation.

regards,
Jakob

2018-09-10 7:45 GMT+02:00 Muktadir R Chowdhury (mrchwdhr) <mrchwdhr@xxxxxxxxxxx>:

I have the following traci 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 clientId = atoi(argv[1]);


    client.connect("localhost", 47000);


    TraCIAPI::VehicleScope vehicleScope(client);


    while(true ) {

        client.simulationStep();

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

        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 till the simulation ends. 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? Is it because the simulation 


Muktadir



_______________________________________________
sumo-user mailing list
sumo-user@xxxxxxxxxxx
To change your delivery options, retrieve your password, or unsubscribe from this list, visit
https://dev.eclipse.org/mailman/listinfo/sumo-user



Back to the top