|
11 | 11 |
|
12 | 12 | #include "rclcpp/rclcpp.hpp" |
13 | 13 |
|
14 | | -#include "tf2_ros/transform_broadcaster.h" |
15 | | -#include "tf2/transform_datatypes.h" |
| 14 | +#include "tf2_ros/transform_broadcaster.hpp" |
| 15 | +#include "tf2/transform_datatypes.hpp" |
16 | 16 |
|
17 | 17 | #include "test_costmap_2d_ros.hpp" |
18 | 18 |
|
@@ -63,22 +63,22 @@ ROSCostmapServer::ROSCostmapServer( |
63 | 63 | : tfBuffer_(node_->get_clock()), |
64 | 64 | tfListener_(tfBuffer_) |
65 | 65 | { |
66 | | - // lots of parameters here affect the construction ( e.g. rolling window) |
67 | | - // if you don't have any parameters set, then this |
68 | | - // - alot of defaults which get dumped on the ros param server |
69 | | - // - fires up an obstacle layer and an inflation layer |
70 | | - // - creates a publisher for an occupancy grid |
71 | | - |
72 | | - costmap_ = std::make_shared<ROSCostmap>(name); |
73 | | - costmap_->set_parameter(rclcpp::Parameter{"plugins", std::vector<std::string>()}); |
74 | | - costmap_->set_parameter(rclcpp::Parameter{"robot_base_frame", baseLinkTransformName}); |
75 | | - costmap_->set_parameter(rclcpp::Parameter{"origin_x", origin.x()}); |
76 | | - costmap_->set_parameter(rclcpp::Parameter{"origin_y", origin.y()}); |
77 | | - costmap_->set_parameter(rclcpp::Parameter{"width", width}); |
78 | | - costmap_->set_parameter(rclcpp::Parameter{"height", height}); |
79 | | - costmap_->set_parameter(rclcpp::Parameter{"resolution", 0.5}); |
80 | | - // clears 1 cell if inside, up to 4 cells on a vertex |
81 | | - costmap_->set_parameter(rclcpp::Parameter{"robot_radius", 0.03}); |
| 66 | + // Costmap2DROS declares most parameters in on_configure(), so set them as overrides. |
| 67 | + // Only the NodeOptions constructor keeps the overrides. |
| 68 | + rclcpp::NodeOptions options; |
| 69 | + options.arguments({"--ros-args", "-r", "__node:=" + name, "-r", "__ns:=/" + name}); |
| 70 | + options.parameter_overrides({ |
| 71 | + {"plugins", std::vector<std::string>()}, |
| 72 | + {"robot_base_frame", baseLinkTransformName}, |
| 73 | + {"origin_x", origin.x()}, |
| 74 | + {"origin_y", origin.y()}, |
| 75 | + {"width", width}, |
| 76 | + {"height", height}, |
| 77 | + {"resolution", 0.5}, |
| 78 | + // clears 1 cell if inside, up to 4 cells on a vertex |
| 79 | + {"robot_radius", 0.03}, |
| 80 | + }); |
| 81 | + costmap_ = std::make_shared<ROSCostmap>(options); |
82 | 82 |
|
83 | 83 | costmap_->configure(); |
84 | 84 | costmap_->activate(); |
|
0 commit comments