Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add ability to publish layers of the costmap #3254

Merged
merged 45 commits into from
Dec 8, 2022
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
Show all changes
45 commits
Select commit Hold shift + click to select a range
7a5b546
publish layers of costmap
Oct 24, 2022
0f2e97b
lint fix
Oct 24, 2022
7d950eb
lint round 2 :)
Oct 24, 2022
82481ab
code review
Oct 26, 2022
447f80f
remove isPublishable
Nov 2, 2022
11459a1
lint
Nov 4, 2022
4a222d6
test running
Nov 7, 2022
0285d20
rough structure complete
Nov 7, 2022
c52243e
completed test
Nov 15, 2022
f184acf
lint
Nov 15, 2022
b09ce66
code review
Nov 15, 2022
a663d58
CI
Nov 16, 2022
ce48a59
CI
Nov 16, 2022
b0dab49
linting
Nov 21, 2022
f3ab862
completed pub test
Nov 30, 2022
c2f9f0b
CostmapLayer::matchSize may be executed concurrently (#3250)
Cryst4L9527 Oct 24, 2022
7340017
Fix typo (#3262)
woawo1213 Nov 1, 2022
15f5800
Adding new Nav2 Smoother: Savitzky-Golay Smoother (#3264)
SteveMacenski Nov 3, 2022
be85e52
refactoring RPP a bit for cleanliness on way to ROSCon (#3265)
SteveMacenski Nov 3, 2022
c3b5cce
exceptions for compute path through poses (#3248)
jwallace42 Nov 3, 2022
d042786
Reclaim Our CI Coverage from the Lords of Painful Subtle Regressions …
SteveMacenski Nov 3, 2022
6d66c9d
Added Line Iterator (#3197)
afifswaidan Nov 7, 2022
ee7e505
Use SetParameter Launch API to set the yaml filename for map_server (…
stevedanomodolor Nov 7, 2022
52a31c6
adding reconfigure test to thetastar (#3275)
padhupradheep Nov 9, 2022
e528ccc
Check for range_max of laserscan in updateFilter to avoid a implicit …
Cryst4L9527 Nov 10, 2022
3f8011f
BT Service Node to throw if service was not available in time (#3256)
guilyx Nov 11, 2022
ead132a
remove exec_depend on behaviortree_cpp_v3 (#3279)
Aposhian Nov 11, 2022
7335d6b
add parameterized refinement recursion numbers in Smac Planner Smooth…
SteveMacenski Nov 15, 2022
65a9e4f
Add allow_unknown parameter to theta star planner (#3286)
pepisg Nov 16, 2022
eb2c779
Include test cases waypoint follwer (#3288)
stevedanomodolor Nov 16, 2022
06cac21
Dynamically changing polygons support (#3245)
AlexeyMerzlyakov Nov 17, 2022
bc95038
adding getCostScalingFactor (#3290)
SteveMacenski Nov 17, 2022
6b221b7
Implemented smoother selector bt node (#3283)
owen7900 Nov 18, 2022
ebf079e
Pipe error codes (#3251)
jwallace42 Nov 18, 2022
ba3d647
Solve bug when CostmapInfoServer is reactivated (#3292)
MartiBolet Nov 20, 2022
76314ac
Smoothness metrics update (#3294)
AlexeyMerzlyakov Nov 20, 2022
a7a77fc
preempt/cancel test for time behavior, spin pluguin (#3301)
stevedanomodolor Nov 29, 2022
3152214
lint fix
Oct 24, 2022
6f13a90
Merge branch 'main' into publish_layers
Nov 30, 2022
83376aa
clean up test
Dec 2, 2022
cdaa851
lint
Dec 2, 2022
0cad731
cleaned up test
Dec 7, 2022
e552f3e
Merge branch 'main' into publish_layers
Dec 7, 2022
539db41
update
Dec 7, 2022
1a05397
revert Cmake
Dec 8, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion nav2_costmap_2d/include/nav2_costmap_2d/costmap_2d_ros.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -319,7 +319,9 @@ class Costmap2DROS : public nav2_util::LifecycleNode
// Publishers and subscribers
rclcpp_lifecycle::LifecyclePublisher<geometry_msgs::msg::PolygonStamped>::SharedPtr
footprint_pub_;
std::unique_ptr<Costmap2DPublisher> costmap_publisher_{nullptr};
std::unique_ptr<Costmap2DPublisher> costmap_publisher_;

std::vector<std::unique_ptr<Costmap2DPublisher>> layer_publishers_;

rclcpp::Subscription<geometry_msgs::msg::Polygon>::SharedPtr footprint_sub_;
rclcpp::Subscription<rcl_interfaces::msg::ParameterEvent>::SharedPtr parameter_sub_;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@

#include <string>
#include <mutex>
#include <memory>

#include "geometry_msgs/msg/pose2_d.hpp"
#include "std_srvs/srv/set_bool.hpp"
Expand Down
39 changes: 37 additions & 2 deletions nav2_costmap_2d/src/costmap_2d_ros.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,19 @@ Costmap2DROS::on_configure(const rclcpp_lifecycle::State & /*state*/)
layered_costmap_->getCostmap(), global_frame_,
"costmap", always_send_full_costmap_);

auto layers = layered_costmap_->getPlugins();
AlexeyMerzlyakov marked this conversation as resolved.
Show resolved Hide resolved

for (auto & layer : *layers) {
auto costmap_layer = std::dynamic_pointer_cast<CostmapLayer>(layer);
if (costmap_layer != nullptr) {
layer_publishers_.emplace_back(
std::make_unique<Costmap2DPublisher>(
shared_from_this(),
costmap_layer.get(), global_frame_,
layer->getName(), always_send_full_costmap_));
SteveMacenski marked this conversation as resolved.
Show resolved Hide resolved
}
}

// Set the footprint
if (use_radius_) {
setRobotFootprint(makeFootprintFromRadius(robot_radius_));
Expand All @@ -233,8 +246,12 @@ Costmap2DROS::on_activate(const rclcpp_lifecycle::State & /*state*/)
{
RCLCPP_INFO(get_logger(), "Activating");

costmap_publisher_->on_activate();
footprint_pub_->on_activate();
costmap_publisher_->on_activate();

for (auto & layer_pub : layer_publishers_) {
layer_pub->on_activate();
}

// First, make sure that the transform between the robot base frame
// and the global frame is available
Expand Down Expand Up @@ -280,8 +297,13 @@ Costmap2DROS::on_deactivate(const rclcpp_lifecycle::State & /*state*/)
RCLCPP_INFO(get_logger(), "Deactivating");

dyn_params_handler.reset();
costmap_publisher_->on_deactivate();

footprint_pub_->on_deactivate();
costmap_publisher_->on_deactivate();

for (auto & layer_pub : layer_publishers_) {
layer_pub->on_deactivate();
}

stop();

Expand All @@ -308,6 +330,10 @@ Costmap2DROS::on_cleanup(const rclcpp_lifecycle::State & /*state*/)
costmap_publisher_.reset();
clear_costmap_service_.reset();

for (auto & layer_pub : layer_publishers_) {
layer_pub.reset();
SteveMacenski marked this conversation as resolved.
Show resolved Hide resolved
}

executor_thread_.reset();
return nav2_util::CallbackReturn::SUCCESS;
}
Expand Down Expand Up @@ -446,12 +472,21 @@ Costmap2DROS::mapUpdateLoop(double frequency)
layered_costmap_->getBounds(&x0, &xn, &y0, &yn);
costmap_publisher_->updateBounds(x0, xn, y0, yn);

for (auto & layer_pub : layer_publishers_) {
layer_pub->updateBounds(x0, xn, y0, yn);
}

auto current_time = now();
if ((last_publish_ + publish_cycle_ < current_time) || // publish_cycle_ is due
(current_time < last_publish_)) // time has moved backwards, probably due to a switch to sim_time // NOLINT
{
RCLCPP_DEBUG(get_logger(), "Publish costmap at %s", name_.c_str());
costmap_publisher_->publishCostmap();

for (auto & layer_pub : layer_publishers_) {
layer_pub->publishCostmap();
}

last_publish_ = current_time;
}
}
Expand Down