sudo sumo --remote-port 47000 -c map.sumocfg &

#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 is my client code.


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 is 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


________________________________
From: sumo-user-boun...@eclipse.org <sumo-user-boun...@eclipse.org> on behalf 
of Mirko Barthauer <m.bartha...@t-online.de>
Sent: Saturday, September 8, 2018 11:40:12 PM
To: sumo-user@eclipse.org
Subject: Re: [sumo-user] Getting information from simulated vehicle


You have full control over the simulation duration. As long as the while loop 
is executed, your simulation continues. Jakob just wrote it as some sample code 
to adapt to your purpose. Could be something like:

runSim = True

steps = 0


while runSim:

    traci.simulationStep()

    steps += 1


    # stop criterion - can be any other condition


    runSim = steps < 3600


Regards
Mirko

Am 08.09.2018 um 17:56 schrieb Muktadir R Chowdhury (mrchwdhr):

Will the following loop continue to run till the simulation finishes?

while True:
  traci.simulationStep()


Muktadir

________________________________
From: sumo-user-boun...@eclipse.org<mailto:sumo-user-boun...@eclipse.org> 
<sumo-user-boun...@eclipse.org><mailto:sumo-user-boun...@eclipse.org> on behalf 
of Jakob Erdmann <namdre.s...@gmail.com><mailto:namdre.s...@gmail.com>
Sent: Friday, September 7, 2018 6:47:54 PM
To: Sumo project User discussions
Subject: Re: [sumo-user] Getting information from simulated vehicle

Yes.

2018-09-07 14:35 GMT+02:00 Muktadir R Chowdhury (mrchwdhr) 
<mrchw...@memphis.edu<mailto:mrchw...@memphis.edu>>:


Regarding client ordering: the process that spawns the clients just needs to 
assign an arbitrary running number and this number is given after connecting 
with the setOrder command.

Does it mean setting up the order in which the clients will be served by Traci 
server?


Muktadir

________________________________
From: sumo-user-boun...@eclipse.org<mailto:sumo-user-boun...@eclipse.org> 
<sumo-user-boun...@eclipse.org<mailto:sumo-user-boun...@eclipse.org>> on behalf 
of Jakob Erdmann <namdre.s...@gmail.com<mailto:namdre.s...@gmail.com>>
Sent: Friday, September 7, 2018 6:09:03 PM

To: Sumo project User discussions
Subject: Re: [sumo-user] Getting information from simulated vehicle

The web service technology employed by TraaS can be used in a local network 
without involving the world wide web.
Regarding client ordering: the process that spawns the clients just needs to 
assign an arbitrary running number and this number is given after connecting 
with the setOrder command.

2018-09-07 13:56 GMT+02:00 Muktadir R Chowdhury (mrchwdhr) 
<mrchw...@memphis.edu<mailto:mrchw...@memphis.edu>>:

My client program can not be web-based. So I am left with the first option and 
I am using C++ Traci API.


When using TraCI in multi-client mode, all clients have to connect at the 
beginning and all of them have to run at least a loop similar to

while True:
  traci.simulationStep()


According to document: "Please note that in multi client scenarios you must 
explicity specify the execution order of the clients using the 
SetOrder-command<http://sumo.dlr.de/wiki/TraCI/Control-related_commands#Command_0x03:_SetOrder>."

Do I also have to do it here? If so how can I do it?

I don't need my client to interfere with the simulation. I just want the 
simulation to run and the clients will get info as needed.

Muktadir
________________________________
From: sumo-user-boun...@eclipse.org<mailto:sumo-user-boun...@eclipse.org> 
<sumo-user-boun...@eclipse.org<mailto:sumo-user-boun...@eclipse.org>> on behalf 
of Jakob Erdmann <namdre.s...@gmail.com<mailto:namdre.s...@gmail.com>>
Sent: Friday, September 7, 2018 5:19:58 PM

To: Sumo project User discussions
Subject: Re: [sumo-user] Getting information from simulated vehicle

When using TraCI in multi-client mode, all clients have to connect at the 
beginning and all of them have to run at least a loop similar to

while True:
  traci.simulationStep()

Alternatively, you can use TraaS (TraCI as a Service) which acts as a single 
client and collects commands from an arbitrary number of web service clients 
and forwards them to sumo. (http://traas.sourceforge.net/cms/)
TraaS is already part of sumo and can be found in  sumo/bin.

regards,
Jakob

2018-09-07 13:12 GMT+02:00 Muktadir R Chowdhury (mrchwdhr) 
<mrchw...@memphis.edu<mailto:mrchw...@memphis.edu>>:
Thanks for your reply. Ok I will upgrade my SUMO.

According to this http://sumo.dlr.de/wiki/TraCI#V2X_simulation , "When started 
with the --remote-port 
<INT><http://sumo.dlr.de/wiki/Basics/Notation#Referenced_Data_Types> option, 
SUMO<http://sumo.dlr.de/wiki/SUMO> only prepares the simulation and waits for 
all external applications to connect and take over the control. ".

That means client connected to SUMO is responsible for running the simulation. 
But, what I want to do is SUMO will run as soon as I issue the command "sumo 
--remote-port <INT> --num-clients <INT>". Then each client (correspond to a 
vehicle) will connect to SUMO and request some vehicle specific information 
(like current position etc.).

Can you please give me a pointer on how can I do this?

Muktadir
________________________________
From: sumo-user-boun...@eclipse.org<mailto:sumo-user-boun...@eclipse.org> 
<sumo-user-boun...@eclipse.org<mailto:sumo-user-boun...@eclipse.org>> on behalf 
of Jakob Erdmann <namdre.s...@gmail.com<mailto:namdre.s...@gmail.com>>
Sent: Friday, September 7, 2018 4:58:36 PM

To: Sumo project User discussions
Subject: Re: [sumo-user] Getting information from simulated vehicle

Multi-client support is only available since version 0.31.0. I recommend 
upgrading to version 1.0.0, though.
regards,
Jakob

2018-09-07 12:56 GMT+02:00 Muktadir R Chowdhury (mrchwdhr) 
<mrchw...@memphis.edu<mailto:mrchw...@memphis.edu>>:

How can I specify the number of clients when starting SUMO, I am using SUMO 
version 0.25 and it is saying "no option with the name 'num-clients' exists."


Muktadir


________________________________
From: sumo-user-boun...@eclipse.org<mailto:sumo-user-boun...@eclipse.org> 
<sumo-user-boun...@eclipse.org<mailto:sumo-user-boun...@eclipse.org>> on behalf 
of Jakob Erdmann <namdre.s...@gmail.com<mailto:namdre.s...@gmail.com>>
Sent: Friday, September 7, 2018 4:19:59 PM
To: Sumo project User discussions
Subject: Re: [sumo-user] Getting information from simulated vehicle

Yes, as long as you know the number of clients in advance.

2018-09-07 12:05 GMT+02:00 Muktadir R Chowdhury (mrchwdhr) 
<mrchw...@memphis.edu<mailto:mrchw...@memphis.edu>>:
I want to achieve the following in SUMO:

(1) SUMO will run in a specified port. Let's say there are "n" vehicles in the 
simulation.
(2) SUMO will keep running while "n" client will connect to SUMO, and each 
client will print location information of each of the vehicles in regular 
interval.

Is it possible to do?

Muktadir Chowdhury



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



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



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



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



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





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


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

Reply via email to