@@ -288,3 +288,70 @@ TEST(NodeLatticeTest, test_get_neighbors)
288288
289289 delete costmapA;
290290}
291+
292+ TEST (NodeLatticeTest, test_node_lattice_custom_footprint)
293+ {
294+ std::string pkg_share_dir = ament_index_cpp::get_package_share_directory (" nav2_smac_planner" );
295+ std::string filePath =
296+ pkg_share_dir +
297+ " /sample_primitives/5cm_resolution/0.5m_turning_radius/ackermann" +
298+ " /output.json" ;
299+
300+ nav2_smac_planner::SearchInfo info;
301+ info.minimum_turning_radius = 0.5 ;
302+ info.non_straight_penalty = 1 ;
303+ info.change_penalty = 1 ;
304+ info.reverse_penalty = 1 ;
305+ info.cost_penalty = 1 ;
306+ info.retrospective_penalty = 0.1 ;
307+ info.analytic_expansion_ratio = 1 ;
308+ info.lattice_filepath = filePath;
309+ info.cache_obstacle_heuristic = true ;
310+ info.allow_reverse_expansion = true ;
311+
312+ unsigned int x = 100 ;
313+ unsigned int y = 100 ;
314+ unsigned int angle_quantization = 16 ;
315+
316+ nav2_smac_planner::NodeLattice::initMotionModel (
317+ nav2_smac_planner::MotionModel::STATE_LATTICE, x, y, angle_quantization, info);
318+
319+ nav2_smac_planner::NodeLattice node (49 );
320+
321+ nav2_costmap_2d::Costmap2D * costmap = new nav2_costmap_2d::Costmap2D (
322+ 40 , 40 , 0.05 , 0.0 , 0.0 , 0 );
323+ std::unique_ptr<nav2_smac_planner::GridCollisionChecker> checker =
324+ std::make_unique<nav2_smac_planner::GridCollisionChecker>(costmap, 72 );
325+
326+ // Make some custom asymmetrical footprint
327+ nav2_costmap_2d::Footprint footprint;
328+ geometry_msgs::msg::Point p;
329+ p.x = -0.1 ;
330+ p.y = -0.15 ;
331+ footprint.push_back (p);
332+ p.x = 0.35 ;
333+ p.y = -0.15 ;
334+ footprint.push_back (p);
335+ p.x = 0.35 ;
336+ p.y = 0.22 ;
337+ footprint.push_back (p);
338+ p.x = -0.1 ;
339+ p.y = 0.22 ;
340+ footprint.push_back (p);
341+ checker->setFootprint (footprint, false , 0.0 );
342+
343+ // Test that the node is valid though all motion primitives poses for custom footprint
344+ // Setting initial robot pose to (1.0, 1.0, 0.0)
345+ node.pose .x = 20 ;
346+ node.pose .y = 20 ;
347+ node.pose .theta = 0 ;
348+ nav2_smac_planner::MotionPrimitivePtrs motion_primitives =
349+ nav2_smac_planner::NodeLattice::motion_table.getMotionPrimitives (&node);
350+ EXPECT_GT (motion_primitives.size (), 0 );
351+ for (unsigned int i = 0 ; i < motion_primitives.size (); i++) {
352+ EXPECT_EQ (node.isNodeValid (true , checker.get (), motion_primitives[i], false ), true );
353+ EXPECT_EQ (node.isNodeValid (true , checker.get (), motion_primitives[i], true ), true );
354+ }
355+
356+ delete costmap;
357+ }
0 commit comments