Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [sumo-user] I can’t set libsumo library

Hi Milad,

The vector strings are directly command line arguments passed to 'sumo.exe' or 'sumo-gui.exe'. See https://sumo.dlr.de/docs/Basics/Using_the_Command_Line_Applications.html#setting_options_on_the_command_line
So you need a file called 'net.net.xml' in your current directory. Or if you have another file like 'myname.net.xml', just replace 'net.net.xml' with that filename.

In your MyPedestrian.cpp, sumo is now being called like on a command prompt with: "sumo-gui.exe -c main.sumocfg". You can actually try that command in a command prompt window in the directory where 'main.sumocfg' is located. There is not more magic than that.
Creating a .sumocfg is explained on the SUMO website. It just describes a collection of files and properties to load to make up a SUMO project. E.g.

<configuration>
  <input>
    <net-file value="myfile.net.xml"/>
    <route-files value="myfile.rou.xml"/>
  </input>
  <time>
    <begin value="0"/>
    <end value="-1"/>
    <step-length value="0.1"/>
  </time>
</configuration>

It would be good to read a bit more on SUMO on the website; they will give some insight on how it all works.

Cheers,
Ruud




On Thu, Feb 29, 2024 at 2:54 AM Milad Sasha <milad.sasha70@xxxxxxxxx> wrote:
Dear Ruud,

I just wanted to say thanks for your help and time—it's been a huge help. This is my first time diving into libsumo and C++ libraries in general, and I've been trying to set up a basic simulation from scratch in Visual Studio. I've got the headers included and the .lib files linked from the bin directory, but I'm stuck on this line from your example code:

Simulation::start({"sumo","-n", "net.net.xml"});

I'm not sure what to replace "sumo", "-n", and "net.net.xml" with for my own network. Could you give me a simple example or some guidance on what these arguments should be?
I also tried running your code, but I'm still having trouble getting the simulation to run from Visual Studio. I've attached screenshots of my .h and .cpp files, as well as how I've included libsumo in the Visual Studio linker. I'm hoping this helps you see what might be going wrong.
Thanks again for your help!

Best,
Milad


On Wed, Feb 28, 2024 at 9:56 AM Ruud van Gaal <r.vangaal@xxxxxxxxxx> wrote:
Here is something that was still in my code:

  auto r = Simulation::start({"sumo", "-c", "main.sumocfg"}, -1, 60, "default", true);

So you'll need the 'main.sumocfg' file in your current directory.
The code I actually use (the above does compile but I haven't test it) is something like this:

  int prefSumoPort=8813;
  bool prefSumoVerbose=true;
  int num_retries=60;
  bool prefSumoGui=true;
  std::string cfg_name="main.sumocfg";
  std::vector<std::string> cmd;
  // Standard installation location
  if (prefSumoGui)
    cmd.push_back("sumo-gui");
  else
    cmd.push_back("sumo");

  // Configuration to load
  cmd.push_back("-c");
  cmd.push_back(cfg_name);
  auto r = Simulation::start(cmd, prefSumoPort, num_retries, "default", prefSumoVerbose);

Hope that helps,
Ruud


On Wed, Feb 28, 2024 at 2:40 PM Milad Sasha <milad.sasha70@xxxxxxxxx> wrote:
Thank you very much for your answer. I think I am wrong with Fstring.please forget about it.

Instead, Could please kindly fill the red arguments with an imaginary example:
Simulation::start({"sumo","-n", "net.net.xml"});

I have become puzzled with the arguments and what to put instead of “sumo” and “net.net.xml” .




On Wed, Feb 28, 2024 at 4:08 AM Ruud van Gaal <r.vangaal@xxxxxxxxxx> wrote:
Hi Milad,

FString may not be compatible. Look at this piece of code on how to make a std::string out of it:

FString test = "MyTest";
std::string test2 = std::string(TCHAR_TO_UTF8(*test));

Cheers,
Ruud


On Wed, Feb 28, 2024 at 8:29 AM Mirko Barthauer via sumo-user <sumo-user@xxxxxxxxxxx> wrote:

Dear Milad,

 

what exactly does not work or what is the error message when you try to run the code? Btw libsumo works with normal std::string values, not sure what happens if you use Unreal FString.

 

Best regards

Mirko

 

 

 

-----Original-Nachricht-----

Betreff: I can’t set libsumo library

Datum: 2024-02-28T01:44:19+0100

Von: "Milad Sasha" <milad.sasha70@xxxxxxxxx>

An: "Mirko Barthauer" <m.barthauer@xxxxxxxxxxx>, "sumo-user@xxxxxxxxxxx" <sumo-user@xxxxxxxxxxx>

 

 

 

Good morning dear Mirko Barthauer,

 

I hope you are well. I tried to include libsumo header in .h and .cpp of my visual studio project.

there is an error in this line of the example code:

Simulation::start({"sumo","-n", "net.net.xml"});

 

Do I need to give the path for sumogui.exe and the path to my network.xml like this:

FString SumoExecutablePath = "C:\\path\\to\\sumo.exe"; FString NetworkFilePath = "C:\\path\\to\\your\\network.net.xml";

Simulation::start({SumoExecutablePath, "-n", NetworkFilePath});

 

Actually, I cannot start the simulation since I cannot run the mentioned line of code. Could you please help me with this?

If there is no need to address "sumogui.exe" file and my network please let me know. Thank you so much in advance.

 

Best Regards,

Milad


_______________________________________________
sumo-user mailing list
sumo-user@xxxxxxxxxxx
To unsubscribe from this list, visit https://www.eclipse.org/mailman/listinfo/sumo-user

Back to the top