MCPcopy Create free account
hub / github.com/ZJU-FAST-Lab/Implicit-SVSDF-Planner / LoadStartEnd

Method LoadStartEnd

src/plan_manager/src/plan_manager.cpp:359–422  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

357}
358
359void PlannerManager::LoadStartEnd()
360{
361 std::string fullPath = config.inputdata;
362 std::string prefix = "shapes/";
363 size_t startPos = fullPath.find(prefix);
364 std::string shapeString;
365 if (startPos != std::string::npos)
366 {
367 startPos += prefix.length();
368 size_t endPos = fullPath.find(".obj", startPos);
369
370 if (endPos != std::string::npos)
371 {
372 shapeString = fullPath.substr(startPos, endPos - startPos);
373 std::cout << "ShapeString : " << shapeString << std::endl;
374 }
375 else
376 {
377 std::cout << "The string does not contain '.obj' after 'shapes/'" << std::endl;
378 }
379 }
380 else
381 {
382 std::cout << "The string does not contain 'shapes/'" << std::endl;
383 }
384
385 cout << "\033[32m========load traj start and end points=======\033[0m" << endl;
386 std::string filename = ros::package::getPath(string("plan_manager")) + "/pcds/trajectory_" + shapeString + ".txt";
387 std::ifstream file(filename);
388 std::string line;
389
390 if (!file.is_open())
391 {
392 std::cerr << "无法打开文件 " << filename << std::endl;
393 }
394 std::string labelstart{"Start: "};
395
396 while (std::getline(file, line))
397 {
398 if (line.find(labelstart) != std::string::npos)
399 {
400 std::istringstream iss(line.substr(labelstart.length()));
401 iss >> Start_record.x() >> Start_record.y() >> Start_record.z();
402 std::cout << std::setprecision(std::numeric_limits<double>::max_digits10);
403 std::cout << "\033[32m Load start pose: " << Start_record.x() << ", " << Start_record.y() << ", " << Start_record.z() << "\033[0m" << std::endl;
404 std::cout << std::setprecision(std::numeric_limits<double>::digits10);
405 break;
406 }
407 }
408 std::string labelend("End: ");
409 while (std::getline(file, line))
410 {
411 if (line.find(labelend) != std::string::npos)
412 {
413 std::istringstream iss(line.substr(labelend.length()));
414 iss >> End_record.x() >> End_record.y() >> End_record.z();
415 std::cout << std::setprecision(std::numeric_limits<double>::max_digits10);
416 std::cout << "\033[32m Load End pose: " << End_record.x() << ", " << End_record.y() << ", " << End_record.z() << "\033[0m" << std::endl;

Callers

nothing calls this directly

Calls 2

lengthMethod · 0.80
findMethod · 0.45

Tested by

no test coverage detected