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

fix bug mentioned in #3958 #3972

Merged
merged 67 commits into from
Dec 1, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
67 commits
Select commit Hold shift + click to select a range
898a4b7
bug fixed
Nov 20, 2023
e83da7c
add space
Nov 20, 2023
bd5fbde
Update planner_server.cpp
GoesM Nov 21, 2023
510c70b
add space for code style
GoesM Nov 21, 2023
e90ad88
Merge pull request #1 from GoesM/GoesM-patch-1
GoesM Nov 21, 2023
14325f6
add childLifecycleNode mode to costmap_2d_ros
GoesM Nov 22, 2023
ec8e2d0
add childLifecycleNode mode to costmap_2d_ros
GoesM Nov 22, 2023
c7a86da
add childLifecycleNode mode to costmap_2d_ros
GoesM Nov 22, 2023
4a09cff
add childLifecycleNode mode in costmap_2d_ros
GoesM Nov 22, 2023
2637de1
add childLifecycleNode mode in costmap_2d_ros
GoesM Nov 22, 2023
ff6ee9f
add childLifecycleNode mode in costmap_2d_ros
GoesM Nov 22, 2023
bfb97f9
add ChildLifecycleNode mode in costmap_2d_ros
GoesM Nov 22, 2023
867e079
add childLifecycleNode mode to costmap_2d_ros
GoesM Nov 22, 2023
c4a2ab0
Merge branch 'ros-planning:main' into main
GoesM Nov 23, 2023
9a0e9d0
NodeOption: is_lifecycle_follower_
GoesM Nov 23, 2023
c6946fd
NodeOption: is_lifecycle_follower_
GoesM Nov 23, 2023
db96dde
fit to NodeOption: is_lifecycle_follower_
GoesM Nov 23, 2023
cb8128e
NodeOption: is_lifecycle_follower_
GoesM Nov 23, 2023
fde1155
fit to NodeOption: is_lifecycle_follower
GoesM Nov 23, 2023
852f547
fit to NodeOption: is_lifecycle_follower
GoesM Nov 23, 2023
bafb5ca
set NodeOption: is_lifecycle_follower_
GoesM Nov 23, 2023
6a6715c
fit reorder Werror
GoesM Nov 23, 2023
428b4a7
fit reorder Werror
GoesM Nov 23, 2023
4fda15d
fix wrong use of is_lifecycle_follower
GoesM Nov 23, 2023
0d4e989
remove blank line
GoesM Nov 23, 2023
f81615b
NodeOption: is_lifecycle_follower_
GoesM Nov 24, 2023
897b263
NodeOption: is_lifecycle_follower_
GoesM Nov 24, 2023
0fa7cc0
Add files via upload
GoesM Nov 24, 2023
1007d2b
NodeOption: is_lifecycle_follower_
GoesM Nov 24, 2023
2348f1f
NodeOption:is_lifecycle_follower_
Nov 24, 2023
a2de411
Merge branch 'main' into nav2_patch
GoesM Nov 24, 2023
cce7734
NodeOption: is_lifecycle_follower_
GoesM Nov 24, 2023
0e31e19
NodeOption:is_lifecycle_follower
Nov 24, 2023
add3eca
NodeOption:is_lifecycle_follower
Nov 24, 2023
f91c121
NodeOption:is_lifecycle_follower
Nov 24, 2023
aff34e2
change default
GoesM Nov 24, 2023
2a2a78a
Merge branch 'ros-planning:main' into nav2_patch
GoesM Nov 28, 2023
4c40d1f
add NodeOption for costmap_2d_ros
Nov 28, 2023
70104ce
add node options for costmap2dros as an independent node
Nov 28, 2023
838393f
code style reformat
Nov 28, 2023
3283bd6
Merge branch 'main' into nav2_patch
GoesM Nov 28, 2023
1dd0fc1
add NodeOptions for Costmap2DROS "is_lifecycle_follower_"
GoesM Nov 28, 2023
bb96f12
fit to NodeOption of Costmap2DROS
Nov 28, 2023
6c291ae
fit to NodeOption of Costmap2DROS
Nov 28, 2023
2e49282
fit to NodeOption of Costmap2DROS
Nov 28, 2023
2d24fb5
Merge branch 'nav2_patch' of https://github.com/GoesM/nav2_fork into …
Nov 28, 2023
267f994
fit to NodeOption of Costmap2DROS in lifecycle_test
GoesM Nov 28, 2023
6927761
Update nav2_costmap_2d/include/nav2_costmap_2d/costmap_2d_ros.hpp
GoesM Nov 28, 2023
ad4bcea
Update nav2_costmap_2d/include/nav2_costmap_2d/costmap_2d_ros.hpp
GoesM Nov 28, 2023
1719e56
Update nav2_costmap_2d/include/nav2_costmap_2d/costmap_2d_ros.hpp
GoesM Nov 28, 2023
a52ef13
changes
Nov 28, 2023
05ad59e
NodeOption
GoesM Nov 28, 2023
fe9f0be
comment changes
Nov 28, 2023
a14e345
Merge pull request #9 from GoesM/nav2_patch
GoesM Nov 28, 2023
297c1d6
change get_parameter into =false
Nov 28, 2023
1236fae
change get_parameter into `=false`
GoesM Nov 28, 2023
3f6748a
comment modification
Nov 28, 2023
dcae712
comment modification
GoesM Nov 28, 2023
caf4447
missing line
Nov 28, 2023
7327191
missing line
GoesM Nov 28, 2023
125dd8e
Update nav2_costmap_2d/include/nav2_costmap_2d/costmap_2d_ros.hpp
SteveMacenski Nov 28, 2023
57b2726
Update nav2_costmap_2d/include/nav2_costmap_2d/costmap_2d_ros.hpp
SteveMacenski Nov 28, 2023
08fc25b
delete last line
Nov 29, 2023
9e317fc
delete last line
GoesM Nov 29, 2023
ebed737
Merge pull request #14 from GoesM/main
GoesM Dec 1, 2023
6dde48a
change lifecycle_test fit to NodeOption
Dec 1, 2023
4d312ab
Merge pull request #15 from GoesM/nav2_patch
GoesM Dec 1, 2023
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
14 changes: 4 additions & 10 deletions nav2_controller/src/controller_server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -290,11 +290,7 @@ ControllerServer::on_deactivate(const rclcpp_lifecycle::State & /*state*/)
* unordered_set iteration. Once this issue is resolved, we can maybe make a stronger
* ordering assumption: https://github.com/ros2/rclcpp/issues/2096
*/
if (costmap_ros_->get_current_state().id() ==
lifecycle_msgs::msg::State::PRIMARY_STATE_ACTIVE)
{
costmap_ros_->deactivate();
}
costmap_ros_->deactivate();

publishZeroVelocity();
vel_publisher_->on_deactivate();
Expand All @@ -320,11 +316,9 @@ ControllerServer::on_cleanup(const rclcpp_lifecycle::State & /*state*/)

goal_checkers_.clear();
progress_checkers_.clear();
if (costmap_ros_->get_current_state().id() ==
lifecycle_msgs::msg::State::PRIMARY_STATE_INACTIVE)
{
costmap_ros_->cleanup();
}

costmap_ros_->cleanup();


// Release any allocated resources
action_server_.reset();
Expand Down
27 changes: 26 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 @@ -75,8 +75,9 @@ class Costmap2DROS : public nav2_util::LifecycleNode
public:
/**
* @brief Constructor for the wrapper
* @param options Additional options to control creation of the node.
*/
Costmap2DROS();
Costmap2DROS(const rclcpp::NodeOptions & options = rclcpp::NodeOptions());

/**
* @brief Constructor for the wrapper, the node will
Expand Down Expand Up @@ -134,6 +135,28 @@ class Costmap2DROS : public nav2_util::LifecycleNode
*/
nav2_util::CallbackReturn on_shutdown(const rclcpp_lifecycle::State & state) override;

/**
* @brief as a child-LifecycleNode :
* Costmap2DROS may be launched by another Lifecycle Node as a composed module
* If composed, its parents will handle the shutdown, which includes this module
*/
void on_rcl_preshutdown() override
SteveMacenski marked this conversation as resolved.
Show resolved Hide resolved
{
if (is_lifecycle_follower_) {
// Transitioning handled by parent node
return;
}

// Else, if this is an independent node, this node needs to handle itself.
RCLCPP_INFO(
get_logger(), "Running Nav2 LifecycleNode rcl preshutdown (%s)",
this->get_name());

runCleanups();

destroyBond();
}

/**
* @brief Subscribes to sensor topics if necessary and starts costmap
* updates, can be called to restart the costmap after calls to either
Expand Down Expand Up @@ -381,6 +404,8 @@ class Costmap2DROS : public nav2_util::LifecycleNode
double transform_tolerance_{0}; ///< The timeout before transform errors
double initial_transform_timeout_{0}; ///< The timeout before activation of the node errors

bool is_lifecycle_follower_{true}; ///< whether is a child-LifecycleNode or an independent node

// Derived parameters
bool use_radius_{false};
std::vector<geometry_msgs::msg::Point> unpadded_footprint_;
Expand Down
5 changes: 3 additions & 2 deletions nav2_costmap_2d/src/costmap_2d_ros.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,8 @@ namespace nav2_costmap_2d
Costmap2DROS::Costmap2DROS(const std::string & name, const bool & use_sim_time)
: Costmap2DROS(name, "/", name, use_sim_time) {}

Costmap2DROS::Costmap2DROS()
: nav2_util::LifecycleNode("costmap", ""),
Costmap2DROS::Costmap2DROS(const rclcpp::NodeOptions & options)
: nav2_util::LifecycleNode("costmap", "", options),
name_("costmap"),
default_plugins_{"static_layer", "obstacle_layer", "inflation_layer"},
default_types_{
Expand All @@ -71,6 +71,7 @@ Costmap2DROS::Costmap2DROS()
"nav2_costmap_2d::InflationLayer"}
{
declare_parameter("map_topic", rclcpp::ParameterValue(std::string("map")));
is_lifecycle_follower_ = false;
init();
}

Expand Down
2 changes: 1 addition & 1 deletion nav2_costmap_2d/test/unit/lifecycle_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
TEST(LifecylceTest, CheckInitialTfTimeout) {
rclcpp::init(0, nullptr);

auto costmap = std::make_shared<nav2_costmap_2d::Costmap2DROS>("test_costmap");
auto costmap = std::make_shared<nav2_costmap_2d::Costmap2DROS>(rclcpp::NodeOptions());
costmap->set_parameter({"initial_transform_timeout", 0.0});

std::thread spin_thread{[costmap]() {rclcpp::spin(costmap->get_node_base_interface());}};
Expand Down
16 changes: 2 additions & 14 deletions nav2_planner/src/planner_server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -218,11 +218,7 @@ PlannerServer::on_deactivate(const rclcpp_lifecycle::State & /*state*/)
* unordered_set iteration. Once this issue is resolved, we can maybe make a stronger
* ordering assumption: https://github.com/ros2/rclcpp/issues/2096
*/
if (costmap_ros_->get_current_state().id() ==
lifecycle_msgs::msg::State::PRIMARY_STATE_ACTIVE)
{
costmap_ros_->deactivate();
}
costmap_ros_->deactivate();

PlannerMap::iterator it;
for (it = planners_.begin(); it != planners_.end(); ++it) {
Expand All @@ -247,15 +243,7 @@ PlannerServer::on_cleanup(const rclcpp_lifecycle::State & /*state*/)
plan_publisher_.reset();
tf_.reset();

/*
* Double check whether something else transitioned it to INACTIVE
* already, e.g. the rcl preshutdown callback.
*/
if (costmap_ros_->get_current_state().id() ==
lifecycle_msgs::msg::State::PRIMARY_STATE_INACTIVE)
{
costmap_ros_->cleanup();
}
costmap_ros_->cleanup();

PlannerMap::iterator it;
for (it = planners_.begin(); it != planners_.end(); ++it) {
Expand Down