25 #define _CRT_SECURE_NO_WARNINGS
26 #pragma warning(disable:4820 4514 5045 4668 4710)
45 s.copy(buf, 1 + s.length());
52 std::vector<std::string> options;
53 std::stringstream ss(callOptions);
55 while (std::getline(ss, temp_str,
DELIMITER)) {
56 options.push_back(temp_str);
60 libsumo::Simulation::load(options);
62 std::cerr <<
"libsumo::Simulation::load() failed - reason: " << e.what() << std::endl;
69 libsumo::Simulation::close();
74 libsumo::Simulation::step(time);
79 return libsumo::Vehicle::getIDCount();
85 std::vector<std::string> params;
86 std::stringstream ss(paramString);
88 while (std::getline(ss, temp_str,
DELIMITER)) {
89 params.push_back(temp_str);
92 const std::string vehID = params[0];
93 const std::string edgeID = params[1];
94 int laneIndex = strtol(params[2].c_str(), &pEnd, 10);
95 double x = strtod(params[3].c_str(), &pEnd);
96 double y = strtod(params[4].c_str(), &pEnd);
98 int keepRoute = params.size() >= 7 ? strtol(params[6].c_str(), &pEnd, 10) : 1;
99 double matchThreshold = params.size() >= 8 ? strtod(params[7].c_str(), &pEnd) : 100;
100 libsumo::Vehicle::moveToXY(vehID, edgeID, laneIndex, x, y, angle, keepRoute, matchThreshold);
101 }
catch (
const std::runtime_error& e) {
102 std::cerr <<
"libsumo::Vehicle::moveToXY() failed - reason: " << e.what() << std::endl;
110 std::vector<std::string> params;
112 std::string temp_str;
113 while (std::getline(ss, temp_str,
DELIMITER)) {
114 params.push_back(temp_str);
117 const std::string vehID = params[0];
118 const std::string key = params[1];
119 std::pair<std::string, std::string> p = libsumo::Vehicle::getParameterWithKey(vehID, key);
120 const std::string resultString = p.first +
DELIMITER + p.second;
122 }
catch (
const std::runtime_error& e) {
123 std::cerr <<
"libsumo::Vehicle::getParameterWithKey() failed - reason: " << e.what() << std::endl;
131 std::vector<std::string> params;
133 std::string temp_str;
134 while (std::getline(ss, temp_str,
DELIMITER)) {
135 params.push_back(temp_str);
138 const std::string vehID = params[0];
140 }
catch (
const std::runtime_error& e) {
141 std::cerr <<
"libsumo::Vehicle::getLaneID() failed - reason: " << e.what() << std::endl;
149 std::vector<std::string> params;
151 std::string temp_str;
152 while (std::getline(ss, temp_str,
DELIMITER)) {
153 params.push_back(temp_str);
156 const std::string vehID = params[0];
158 std::ostringstream os;
161 }
catch (
const std::runtime_error& e) {
162 std::cerr <<
"libsumo::Vehicle::getPosition() failed - reason: " << e.what() << std::endl;
An error which allows to continue.
void libsumo_vehicle_moveToXY(const char *paramString)
void libsumo_load(char *callOptions)
void libsumo_vehicle_getLaneID(ModelInstance *comp, const char **result)
void libsumo_vehicle_getPosition(ModelInstance *comp, const char **result)
void libsumo_vehicle_getParameterWithKey(ModelInstance *comp, const char **result)
char * allocateAndCopyString(ModelInstance *comp, const std::string &s)
void libsumo_step(double time)
int libsumo_vehicle_getIDCount(void)
TRACI_CONST double INVALID_DOUBLE_VALUE
char * getterParameters
Parameters stored for the next (libsumo) getter call. Workaround for FMIv2 not allowing input values ...
allocateMemoryType allocateMemory
A 2D or 3D-position, for 2D positions z == INVALID_DOUBLE_VALUE.