Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
d68327c
Working replanning if path is vaild, however there is a bug with new …
jwallace42 Oct 6, 2021
9c1b724
Completed tested of path replanning
jwallace42 Oct 9, 2021
ab0bd04
Delete uncrustify.cfg
jwallace42 Oct 9, 2021
82ba36e
Clean up for code review
jwallace42 Oct 10, 2021
c6cf5e7
Merge branch 'replanning' of https://github.com/jwallace42/navigation…
jwallace42 Oct 10, 2021
1db1637
steady
jwallace42 Oct 10, 2021
a45acd4
Merge branch 'main' into replanning
jwallace42 Oct 19, 2021
d9e7e3e
small code review changes
jwallace42 Oct 19, 2021
0246e99
listen to server_timeout in input port
jwallace42 Oct 19, 2021
b295ba4
Lint issues
jwallace42 Oct 19, 2021
b6fb154
reverted file for navigate to pose
jwallace42 Oct 20, 2021
e105ed7
lint fixes
jwallace42 Oct 20, 2021
9a3515c
added global update condition
jwallace42 Dec 7, 2021
9eb57d2
headless
jwallace42 Dec 16, 2021
e9f6242
revert default bt
jwallace42 Dec 16, 2021
4093b9e
Merge branch 'main' of https://github.com/ros-planning/navigation2 in…
jwallace42 Dec 17, 2021
dc90458
Add image of new bt tree
jwallace42 Dec 17, 2021
617f42d
circle ci and comments
jwallace42 Dec 17, 2021
2dcbf3e
add test for globally updated goal condition
jwallace42 Dec 18, 2021
eacd1f9
added plath replanning only if path is invalid to navigate to pose
jwallace42 Dec 18, 2021
779e3b6
Added nodes to nav2_tree_nodes
jwallace42 Jan 7, 2022
6893e29
Merge branch 'main' of github.com:ros-planning/navigation2 into repla…
jwallace42 Jan 16, 2022
18fbb98
cleanup BT tree for invalid path
jwallace42 Jan 16, 2022
3f389ae
code fixeds
jwallace42 Jan 19, 2022
2638090
lint fixes
jwallace42 Jan 19, 2022
dce9cd2
added default timeout
jwallace42 Jan 19, 2022
e0c18ff
lint fix
jwallace42 Jan 25, 2022
f1e6a71
server timeout fix
jwallace42 Jan 26, 2022
bc01fa6
removed images of new BTs
jwallace42 Jan 26, 2022
6aa2e9f
added rate controller
jwallace42 Jan 26, 2022
f3caddc
lint fix
jwallace42 Jan 26, 2022
24b748b
Moved server timeout to constructor
jwallace42 Jan 29, 2022
405178b
fixed xml lint error
jwallace42 Jan 29, 2022
e85a582
fixed test for is path valid
jwallace42 Jan 29, 2022
b774eb1
new bt image for reference
jwallace42 Jan 29, 2022
1945361
remove reference
jwallace42 Jan 29, 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
6 changes: 6 additions & 0 deletions nav2_behavior_tree/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -84,9 +84,15 @@ list(APPEND plugin_libs nav2_transform_available_condition_bt_node)
add_library(nav2_goal_reached_condition_bt_node SHARED plugins/condition/goal_reached_condition.cpp)
list(APPEND plugin_libs nav2_goal_reached_condition_bt_node)

add_library(nav2_globally_updated_goal_condition_bt_node SHARED plugins/condition/globally_updated_goal_condition.cpp)
list(APPEND plugin_libs nav2_globally_updated_goal_condition_bt_node)

add_library(nav2_goal_updated_condition_bt_node SHARED plugins/condition/goal_updated_condition.cpp)
list(APPEND plugin_libs nav2_goal_updated_condition_bt_node)

add_library(nav2_is_path_valid_condition_bt_node SHARED plugins/condition/is_path_valid_condition.cpp)
list(APPEND plugin_libs nav2_is_path_valid_condition_bt_node)

add_library(nav2_time_expired_condition_bt_node SHARED plugins/condition/time_expired_condition.cpp)
list(APPEND plugin_libs nav2_time_expired_condition_bt_node)

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
// Copyright (c) 2021 Joshua Wallace
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

#ifndef NAV2_BEHAVIOR_TREE__PLUGINS__CONDITION__GLOBALLY_UPDATED_GOAL_CONDITION_HPP_
#define NAV2_BEHAVIOR_TREE__PLUGINS__CONDITION__GLOBALLY_UPDATED_GOAL_CONDITION_HPP_

#include <string>
#include <vector>

#include "rclcpp/rclcpp.hpp"

#include "behaviortree_cpp_v3/condition_node.h"
#include "geometry_msgs/msg/pose_stamped.hpp"


namespace nav2_behavior_tree
{
/**
* @brief A BT::ConditionNode that returns SUCCESS when goal is
* updated on the blackboard and FAILURE otherwise
*/
class GloballyUpdatedGoalCondition : public BT::ConditionNode
{
public:
/**
* @brief A constructor for nav2_behavior_tree::GloballyUpdatedGoalCondition
* @param condition_name Name for the XML tag for this node
* @param conf BT node configuration
*/
GloballyUpdatedGoalCondition(
const std::string & condition_name,
const BT::NodeConfiguration & conf);

GloballyUpdatedGoalCondition() = delete;

/**
* @brief The main override required by a BT action
* @return BT::NodeStatus Status of tick execution
*/
BT::NodeStatus tick() override;


/**
* @brief Creates list of BT ports
* @return BT::PortsList Containing node-specific ports
*/
static BT::PortsList providedPorts()
{
return {};
}

private:
bool first_time;
rclcpp::Node::SharedPtr node_;
geometry_msgs::msg::PoseStamped goal_;
std::vector<geometry_msgs::msg::PoseStamped> goals_;
};

} // namespace nav2_behavior_tree


#endif // NAV2_BEHAVIOR_TREE__PLUGINS__CONDITION__GLOBALLY_UPDATED_GOAL_CONDITION_HPP_
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
// Copyright (c) 2021 Joshua Wallace
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

#ifndef NAV2_BEHAVIOR_TREE__PLUGINS__CONDITION__IS_PATH_VALID_CONDITION_HPP_
#define NAV2_BEHAVIOR_TREE__PLUGINS__CONDITION__IS_PATH_VALID_CONDITION_HPP_

#include <string>
#include <memory>

#include "rclcpp/rclcpp.hpp"
#include "behaviortree_cpp_v3/condition_node.h"
#include "geometry_msgs/msg/pose_stamped.hpp"
#include "nav2_msgs/srv/is_path_valid.hpp"

namespace nav2_behavior_tree
{

/**
* @brief A BT::ConditionNode that returns SUCCESS when the IsPathValid
* service returns true and FAILURE otherwise
*/
class IsPathValidCondition : public BT::ConditionNode
{
public:
/**
* @brief A constructor for nav2_behavior_tree::IsPathValidCondition
* @param condition_name Name for the XML tag for this node
* @param conf BT node configuration
*/
IsPathValidCondition(
const std::string & condition_name,
const BT::NodeConfiguration & conf);

IsPathValidCondition() = delete;

/**
* @brief The main override required by a BT action
* @return BT::NodeStatus Status of tick execution
*/
BT::NodeStatus tick() override;

/**
* @brief Creates list of BT ports
* @return BT::PortsList Containing node-specific ports
*/
static BT::PortsList providedPorts()
{
return {
BT::InputPort<nav_msgs::msg::Path>("path", "Path to Check"),
BT::InputPort<std::chrono::milliseconds>("server_timeout")
Comment thread
SteveMacenski marked this conversation as resolved.
};
}

private:
rclcpp::Node::SharedPtr node_;
rclcpp::Client<nav2_msgs::srv::IsPathValid>::SharedPtr client_;
// The timeout value while waiting for a responce from the
// is path valid service
std::chrono::milliseconds server_timeout_;
};

} // namespace nav2_behavior_tree

#endif // NAV2_BEHAVIOR_TREE__PLUGINS__CONDITION__IS_PATH_VALID_CONDITION_HPP_
8 changes: 8 additions & 0 deletions nav2_behavior_tree/nav2_tree_nodes.xml
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,8 @@

<Condition ID="GoalUpdated"/>

<Condition ID="GloballyUpdatedGoalCondition"/>

<Condition ID="IsBatteryLow">
<input_port name="min_battery">Min battery % or voltage before triggering</input_port>
<input_port name="battery_topic">Topic for battery info</input_port>
Expand All @@ -129,6 +131,12 @@

<Condition ID="InitialPoseReceived">
</Condition>

<Condition ID="IsPathValidCondition">
<input_port name="path"> Path to validate </input_port>
<input_port name="server_timeout"> Server timeout </input_port>
</Condition>

<!-- ############################### CONTROL NODES ################################ -->
<Control ID="PipelineSequence"/>

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
// Copyright (c) 2021 Joshua Wallace
Comment thread
SteveMacenski marked this conversation as resolved.
Comment thread
SteveMacenski marked this conversation as resolved.
//
Comment thread
SteveMacenski marked this conversation as resolved.
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

#include <vector>
#include <string>

#include "nav2_behavior_tree/plugins/condition/globally_updated_goal_condition.hpp"

namespace nav2_behavior_tree
{

GloballyUpdatedGoalCondition::GloballyUpdatedGoalCondition(
const std::string & condition_name,
const BT::NodeConfiguration & conf)
: BT::ConditionNode(condition_name, conf),
first_time(true)
{
node_ = config().blackboard->get<rclcpp::Node::SharedPtr>("node");
}

BT::NodeStatus GloballyUpdatedGoalCondition::tick()
{
if (first_time) {
first_time = false;
config().blackboard->get<std::vector<geometry_msgs::msg::PoseStamped>>("goals", goals_);
config().blackboard->get<geometry_msgs::msg::PoseStamped>("goal", goal_);
return BT::NodeStatus::FAILURE;
}

std::vector<geometry_msgs::msg::PoseStamped> current_goals;
config().blackboard->get<std::vector<geometry_msgs::msg::PoseStamped>>("goals", current_goals);
geometry_msgs::msg::PoseStamped current_goal;
config().blackboard->get<geometry_msgs::msg::PoseStamped>("goal", current_goal);

if (goal_ != current_goal || goals_ != current_goals) {
goal_ = current_goal;
goals_ = current_goals;
return BT::NodeStatus::SUCCESS;
}

return BT::NodeStatus::FAILURE;
}

} // namespace nav2_behavior_tree

#include "behaviortree_cpp_v3/bt_factory.h"
BT_REGISTER_NODES(factory)
{
factory.registerNodeType<nav2_behavior_tree::GloballyUpdatedGoalCondition>("GlobalUpdatedGoal");
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,7 @@ GoalUpdatedCondition::GoalUpdatedCondition(
const std::string & condition_name,
const BT::NodeConfiguration & conf)
: BT::ConditionNode(condition_name, conf)
{
}
{}

BT::NodeStatus GoalUpdatedCondition::tick()
{
Expand Down
61 changes: 61 additions & 0 deletions nav2_behavior_tree/plugins/condition/is_path_valid_condition.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
// Copyright (c) 2021 Joshua Wallace
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

#include "nav2_behavior_tree/plugins/condition/is_path_valid_condition.hpp"
#include <chrono>
#include <memory>
#include <string>

namespace nav2_behavior_tree
{

IsPathValidCondition::IsPathValidCondition(
const std::string & condition_name,
const BT::NodeConfiguration & conf)
: BT::ConditionNode(condition_name, conf)
{
node_ = config().blackboard->get<rclcpp::Node::SharedPtr>("node");
client_ = node_->create_client<nav2_msgs::srv::IsPathValid>("is_path_valid");

server_timeout_ = config().blackboard->template get<std::chrono::milliseconds>("server_timeout");
getInput<std::chrono::milliseconds>("server_timeout", server_timeout_);
}

BT::NodeStatus IsPathValidCondition::tick()
{
nav_msgs::msg::Path path;
getInput("path", path);

auto request = std::make_shared<nav2_msgs::srv::IsPathValid::Request>();

request->path = path;
auto result = client_->async_send_request(request);

if (rclcpp::spin_until_future_complete(node_, result, server_timeout_) ==
rclcpp::FutureReturnCode::SUCCESS)
{
if (result.get()->is_valid) {
return BT::NodeStatus::SUCCESS;
}
}
return BT::NodeStatus::FAILURE;
}

} // namespace nav2_behavior_tree

#include "behaviortree_cpp_v3/bt_factory.h"
BT_REGISTER_NODES(factory)
{
factory.registerNodeType<nav2_behavior_tree::IsPathValidCondition>("IsPathValid");
}
8 changes: 8 additions & 0 deletions nav2_behavior_tree/test/plugins/condition/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ ament_add_gtest(test_condition_goal_updated test_goal_updated.cpp)
target_link_libraries(test_condition_goal_updated nav2_goal_updated_condition_bt_node)
ament_target_dependencies(test_condition_goal_updated ${dependencies})

ament_add_gtest(test_condition_globally_updated_goal test_globally_updated_goal.cpp)
target_link_libraries(test_condition_globally_updated_goal nav2_globally_updated_goal_condition_bt_node)
ament_target_dependencies(test_condition_globally_updated_goal ${dependencies})

ament_add_gtest(test_condition_initial_pose_received test_initial_pose_received.cpp)
target_link_libraries(test_condition_initial_pose_received nav2_initial_pose_received_condition_bt_node)
ament_target_dependencies(test_condition_initial_pose_received ${dependencies})
Expand All @@ -29,3 +33,7 @@ ament_target_dependencies(test_condition_is_stuck ${dependencies})
ament_add_gtest(test_condition_is_battery_low test_is_battery_low.cpp)
target_link_libraries(test_condition_is_battery_low nav2_is_battery_low_condition_bt_node)
ament_target_dependencies(test_condition_is_battery_low ${dependencies})

ament_add_gtest(test_condition_is_path_valid test_is_path_valid.cpp)
target_link_libraries(test_condition_is_path_valid nav2_is_path_valid_condition_bt_node)
ament_target_dependencies(test_condition_is_path_valid ${dependencies})
Loading