Eclipse SUMO - Simulation of Urban MObility
Loading...
Searching...
No Matches
testlibtraci_main.cpp
Go to the documentation of this file.
1/****************************************************************************/
2// Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.dev/sumo
3// Copyright (C) 2001-2024 German Aerospace Center (DLR) and others.
4// This program and the accompanying materials are made available under the
5// terms of the Eclipse Public License 2.0 which is available at
6// https://www.eclipse.org/legal/epl-2.0/
7// This Source Code may also be made available under the following Secondary
8// Licenses when the conditions for such availability set forth in the Eclipse
9// Public License 2.0 are satisfied: GNU General Public License, version 2
10// or later which is available at
11// https://www.gnu.org/licenses/old-licenses/gpl-2.0-standalone.html
12// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-or-later
13/****************************************************************************/
18// Testing libtraci for C++
19/****************************************************************************/
20#ifdef _MSC_VER
21// Avoid some noisy warnings with Visual Studio
22#pragma warning(disable:4820 4514 5045 4668 4710)
23#endif
24
25#include <iostream>
26#include <libsumo/libtraci.h>
27
28
29// ===========================================================================
30// main function
31// ===========================================================================
32int
33main(int argc, char** argv) {
34 std::vector<std::string> options;
35 for (int i = 1; i < argc; i++) {
36 options.push_back(argv[i]);
37 }
38 try {
39 libtraci::Simulation::start(options);
40 // libtraci::Simulation::start(options, -1, libsumo::DEFAULT_NUM_RETRIES, "default", true);
41 std::cout << "Simulation started\n";
42 for (int i = 0; i < 50; i++) {
43 libtraci::Simulation::step();
44 }
45 libtraci::Simulation::close();
46 } catch (const std::runtime_error& e) {
47 std::cerr << "Could not start simulation: " << e.what() << "\n";
48 }
49 /*
50 std::vector<libsumo::TraCIStage> result = libsumo::Simulation::findIntermodalRoute("64455492", "-22913705", "public", 21600, 3, -1, -1, 0, 0,0,"ped");
51 double cost = 0;
52 double time = 0;
53 for (const auto& stage : result)
54 {
55 std::cout << " type=" << stage.type << " line=" << stage.line << " travelTime=" << stage.travelTime << " cost=" << stage.cost << " destination: "<< stage.destStop<<"\n";
56 std::cout << "Descr:\n" << stage.description<< std::endl<<std::endl;
57 cost += stage.cost;
58 time += stage.travelTime;
59 }
60 std::cout<<"end cost: "<<cost<<std::endl;
61 std::cout<<"end time: "<<time<<std::endl;
62 */
63}
64
65
66/****************************************************************************/
int main(int argc, char **argv)