Eclipse SUMO - Simulation of Urban MObility
testlibtraci_main.cpp
Go to the documentation of this file.
1
/****************************************************************************/
2
// Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.org/sumo
3
// Copyright (C) 2001-2022 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 libsumo for C++
19
/****************************************************************************/
20
#include <iostream>
21
#include <
libsumo/libtraci.h
>
22
23
24
// ===========================================================================
25
// main function
26
// ===========================================================================
27
int
28
main
(
int
argc,
char
** argv) {
29
std::vector<std::string> options;
30
for
(
int
i = 1; i < argc; i++) {
31
options.push_back(argv[i]);
32
}
33
try
{
34
libtraci::Simulation::start(options);
35
// libtraci::Simulation::start(options, -1, libsumo::DEFAULT_NUM_RETRIES, "default", true);
36
std::cout <<
"Simulation started\n"
;
37
for
(
int
i = 0; i < 50; i++) {
38
libtraci::Simulation::step();
39
}
40
libtraci::Simulation::close();
41
}
catch
(
const
std::runtime_error& e) {
42
std::cerr <<
"Could not start simulation: "
<< e.what() <<
"\n"
;
43
}
44
/*
45
std::vector<libsumo::TraCIStage> result = libsumo::Simulation::findIntermodalRoute("64455492", "-22913705", "public", 21600, 3, -1, -1, 0, 0,0,"ped");
46
double cost = 0;
47
double time = 0;
48
for (const auto& stage : result)
49
{
50
std::cout << " type=" << stage.type << " line=" << stage.line << " travelTime=" << stage.travelTime << " cost=" << stage.cost << " destination: "<< stage.destStop<<"\n";
51
std::cout << "Descr:\n" << stage.description<< std::endl<<std::endl;
52
cost += stage.cost;
53
time += stage.travelTime;
54
}
55
std::cout<<"end cost: "<<cost<<std::endl;
56
std::cout<<"end time: "<<time<<std::endl;
57
*/
58
}
59
60
61
/****************************************************************************/
libtraci.h
main
int main(int argc, char **argv)
Definition:
testlibtraci_main.cpp:28
src
traci_testclient
testlibtraci_main.cpp
Generated on Fri Feb 11 2022 22:11:11 for Eclipse SUMO - Simulation of Urban MObility by
1.9.1