Skip to content

Commit 909c6f2

Browse files
[testing sprint] remove dead code not used in 10 years from navfn (#1926)
* remove dead code not used in 10 years from navfn * ping * inverting period to rate * removing debug statement that could never be triggered by a single non-looping action server * type change
1 parent a5402ee commit 909c6f2

File tree

6 files changed

+51
-57
lines changed

6 files changed

+51
-57
lines changed

nav2_navfn_planner/include/nav2_navfn_planner/navfn.hpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -258,13 +258,13 @@ class NavFn
258258

259259
/** display callback */
260260
/**< <n> is the number of cycles between updates */
261-
void display(void fn(NavFn * nav), int n = 100);
262-
int displayInt; /**< save second argument of display() above */
263-
void (* displayFn)(NavFn * nav); /**< display function itself */
261+
// void display(void fn(NavFn * nav), int n = 100);
262+
// int displayInt; /**< save second argument of display() above */
263+
// void (* displayFn)(NavFn * nav); /**< display function itself */
264264

265265
/** save costmap */
266266
/**< write out costmap and start/goal states as fname.pgm and fname.txt */
267-
void savemap(const char * fname);
267+
// void savemap(const char * fname);
268268
};
269269

270270
} // namespace nav2_navfn_planner

nav2_navfn_planner/src/navfn.cpp

Lines changed: 44 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -131,8 +131,8 @@ NavFn::NavFn(int xs, int ys)
131131
start[0] = start[1] = 0;
132132

133133
// display function
134-
displayFn = NULL;
135-
displayInt = 0;
134+
// displayFn = NULL;
135+
// displayInt = 0;
136136

137137
// path buffers
138138
npathbuf = npath = 0;
@@ -607,9 +607,9 @@ NavFn::propNavFnDijkstra(int cycles, bool atStart)
607607
updateCell(*pb++);
608608
}
609609

610-
if (displayInt > 0 && (cycle % displayInt) == 0) {
611-
displayFn(this);
612-
}
610+
// if (displayInt > 0 && (cycle % displayInt) == 0) {
611+
// displayFn(this);
612+
// }
613613

614614
// swap priority blocks curP <=> nextP
615615
curPe = nextPe;
@@ -693,9 +693,9 @@ NavFn::propNavFnAstar(int cycles)
693693
updateCellAstar(*pb++);
694694
}
695695

696-
if (displayInt > 0 && (cycle % displayInt) == 0) {
697-
displayFn(this);
698-
}
696+
// if (displayInt > 0 && (cycle % displayInt) == 0) {
697+
// displayFn(this);
698+
// }
699699

700700
// swap priority blocks curP <=> nextP
701701
curPe = nextPe;
@@ -985,48 +985,48 @@ NavFn::gradCell(int n)
985985
// <n> is the number of cycles to wait before displaying,
986986
// use 0 to turn it off
987987

988-
void
989-
NavFn::display(void fn(NavFn * nav), int n)
990-
{
991-
displayFn = fn;
992-
displayInt = n;
993-
}
988+
// void
989+
// NavFn::display(void fn(NavFn * nav), int n)
990+
// {
991+
// displayFn = fn;
992+
// displayInt = n;
993+
// }
994994

995995

996996
//
997997
// debug writes
998998
// saves costmap and start/goal
999999
//
10001000

1001-
void
1002-
NavFn::savemap(const char * fname)
1003-
{
1004-
char fn[4096];
1005-
1006-
RCLCPP_DEBUG(rclcpp::get_logger("rclcpp"), "[NavFn] Saving costmap and start/goal points");
1007-
// write start and goal points
1008-
snprintf(fn, sizeof(fn), "%s.txt", fname);
1009-
FILE * fp = fopen(fn, "w");
1010-
if (!fp) {
1011-
RCLCPP_WARN(rclcpp::get_logger("rclcpp"), "Can't open file %s", fn);
1012-
return;
1013-
}
1014-
fprintf(fp, "Goal: %d %d\nStart: %d %d\n", goal[0], goal[1], start[0], start[1]);
1015-
fclose(fp);
1016-
1017-
// write cost array
1018-
if (!costarr) {
1019-
return;
1020-
}
1021-
snprintf(fn, sizeof(fn), "%s.pgm", fname);
1022-
fp = fopen(fn, "wb");
1023-
if (!fp) {
1024-
RCLCPP_WARN(rclcpp::get_logger("rclcpp"), "Can't open file %s", fn);
1025-
return;
1026-
}
1027-
fprintf(fp, "P5\n%d\n%d\n%d\n", nx, ny, 0xff);
1028-
fwrite(costarr, 1, nx * ny, fp);
1029-
fclose(fp);
1030-
}
1001+
// void
1002+
// NavFn::savemap(const char * fname)
1003+
// {
1004+
// char fn[4096];
1005+
1006+
// RCLCPP_DEBUG(rclcpp::get_logger("rclcpp"), "[NavFn] Saving costmap and start/goal points");
1007+
// // write start and goal points
1008+
// snprintf(fn, sizeof(fn), "%s.txt", fname);
1009+
// FILE * fp = fopen(fn, "w");
1010+
// if (!fp) {
1011+
// RCLCPP_WARN(rclcpp::get_logger("rclcpp"), "Can't open file %s", fn);
1012+
// return;
1013+
// }
1014+
// fprintf(fp, "Goal: %d %d\nStart: %d %d\n", goal[0], goal[1], start[0], start[1]);
1015+
// fclose(fp);
1016+
1017+
// // write cost array
1018+
// if (!costarr) {
1019+
// return;
1020+
// }
1021+
// snprintf(fn, sizeof(fn), "%s.pgm", fname);
1022+
// fp = fopen(fn, "wb");
1023+
// if (!fp) {
1024+
// RCLCPP_WARN(rclcpp::get_logger("rclcpp"), "Can't open file %s", fn);
1025+
// return;
1026+
// }
1027+
// fprintf(fp, "P5\n%d\n%d\n%d\n", nx, ny, 0xff);
1028+
// fwrite(costarr, 1, nx * ny, fp);
1029+
// fclose(fp);
1030+
// }
10311031

10321032
} // namespace nav2_navfn_planner

nav2_navfn_planner/src/navfn_planner.cpp

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -319,11 +319,11 @@ NavfnPlanner::getPlanFromPotential(
319319

320320
int path_len = planner_->calcPath(costmap_->getSizeInCellsX() * 4);
321321
if (path_len == 0) {
322-
RCLCPP_DEBUG(node_->get_logger(), "No path found\n");
323322
return false;
324323
}
325324

326-
RCLCPP_DEBUG(node_->get_logger(), "Path found, %d steps\n", path_len);
325+
auto cost = planner_->getLastPathCost();
326+
RCLCPP_DEBUG(node_->get_logger(), "Path found, %d steps, %f cost\n", path_len, cost);
327327

328328
// extract the plan
329329
float * x = planner_->getPathX();
@@ -402,10 +402,6 @@ bool
402402
NavfnPlanner::worldToMap(double wx, double wy, unsigned int & mx, unsigned int & my)
403403
{
404404
if (wx < costmap_->getOriginX() || wy < costmap_->getOriginY()) {
405-
RCLCPP_ERROR(
406-
node_->get_logger(), "worldToMap failed: wx,wy: %f,%f, "
407-
"size_x,size_y: %d,%d", wx, wy,
408-
costmap_->getSizeInCellsX(), costmap_->getSizeInCellsY());
409405
return false;
410406
}
411407

nav2_planner/src/planner_server.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,6 @@ PlannerServer::computePlan()
233233
}
234234

235235
if (action_server_->is_preempt_requested()) {
236-
RCLCPP_INFO(get_logger(), "Preempting the goal pose.");
237236
goal = action_server_->accept_pending_goal();
238237
}
239238

nav2_system_tests/src/planning/CMakeLists.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,6 @@ ament_add_gtest(test_planner_plugin_failures
5151
)
5252

5353
ament_target_dependencies(test_planner_plugin_failures rclcpp geometry_msgs nav2_msgs ${dependencies})
54-
5554
target_link_libraries(test_planner_plugin_failures
5655
stdc++fs
5756
)

nav2_system_tests/src/planning/test_planner_plugins.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ TEST(testPluginMap, Failures)
3737
{
3838
auto obj = std::make_shared<nav2_system_tests::NavFnPlannerTester>();
3939
rclcpp_lifecycle::State state;
40-
obj->set_parameter(rclcpp::Parameter("expected_planner_frequency", 0.0001));
40+
obj->set_parameter(rclcpp::Parameter("expected_planner_frequency", 100000.0));
4141
obj->onConfigure(state);
4242
obj->create_subscription<nav_msgs::msg::Path>(
4343
"plan", rclcpp::SystemDefaultsQoS(), callback);

0 commit comments

Comments
 (0)