Skip to content

Commit

Permalink
Merge branch 'main' into allow_path_end_pose_deviation_revive
Browse files Browse the repository at this point in the history
  • Loading branch information
jwallace42 committed Jan 25, 2024
2 parents 409ead1 + bc76734 commit 9a88fe9
Show file tree
Hide file tree
Showing 63 changed files with 552 additions and 169 deletions.
6 changes: 3 additions & 3 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,12 @@ _commands:
- restore_cache:
name: Restore Cache << parameters.key >>
keys:
- "<< parameters.key >>-v17\
- "<< parameters.key >>-v18\
-{{ arch }}\
-{{ .Branch }}\
-{{ .Environment.CIRCLE_PR_NUMBER }}\
-{{ checksum \"<< parameters.workspace >>/lockfile.txt\" }}"
- "<< parameters.key >>-v17\
- "<< parameters.key >>-v18\
-{{ arch }}\
-main\
-<no value>\
Expand All @@ -58,7 +58,7 @@ _commands:
steps:
- save_cache:
name: Save Cache << parameters.key >>
key: "<< parameters.key >>-v17\
key: "<< parameters.key >>-v18\
-{{ arch }}\
-{{ .Branch }}\
-{{ .Environment.CIRCLE_PR_NUMBER }}\
Expand Down
18 changes: 18 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
Any contribution that you make to this repository will
be under the Apache 2 License, as dictated by that
[license](http://www.apache.org/licenses/LICENSE-2.0.html):

~~~
5. Submission of Contributions. Unless You explicitly state otherwise,
any Contribution intentionally submitted for inclusion in the Work
by You to the Licensor shall be under the terms and conditions of
this License, without any additional terms or conditions.
Notwithstanding the above, nothing herein shall supersede or modify
the terms of any separate license agreement you may have executed
with Licensor regarding such Contributions.
~~~

Contributors must sign-off each commit by adding a `Signed-off-by: ...`
line to commit messages to certify that they have the right to submit
the code they are contributing to the project according to the
[Developer Certificate of Origin (DCO)](https://developercertificate.org/).
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,11 @@ class AssistedTeleopAction : public BtActionNode<nav2_msgs::action::AssistedTele
*/
BT::NodeStatus on_cancelled() override;

/**
* @brief Function to read parameters and initialize class variables
*/
void initialize();

/**
* @brief Creates list of BT ports
* @return BT::PortsList Containing basic ports along with node-specific ports
Expand All @@ -81,6 +86,7 @@ class AssistedTeleopAction : public BtActionNode<nav2_msgs::action::AssistedTele

private:
bool is_recovery_;
bool initialized_;
};

} // namespace nav2_behavior_tree
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,11 @@ class BackUpAction : public BtActionNode<nav2_msgs::action::BackUp>
*/
BT::NodeStatus on_cancelled() override;

/**
* @brief Function to read parameters and initialize class variables
*/
void initialize();

/**
* @brief Creates list of BT ports
* @return BT::PortsList Containing basic ports along with node-specific ports
Expand All @@ -79,6 +84,9 @@ class BackUpAction : public BtActionNode<nav2_msgs::action::BackUp>
"error_code_id", "The back up behavior server error code")
});
}

private:
bool initialized_;
};

} // namespace nav2_behavior_tree
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,11 @@ class DriveOnHeadingAction : public BtActionNode<nav2_msgs::action::DriveOnHeadi
const std::string & action_name,
const BT::NodeConfiguration & conf);

/**
* @brief Function to read parameters and initialize class variables
*/
void initialize();

/**
* @brief Creates list of BT ports
* @return BT::PortsList Containing basic ports along with node-specific ports
Expand All @@ -59,6 +64,11 @@ class DriveOnHeadingAction : public BtActionNode<nav2_msgs::action::DriveOnHeadi
});
}

/**
* @brief Function to perform some user-defined operation on tick
*/
void on_tick() override;

/**
* @brief Function to perform some user-defined operation upon successful completion of the action
*/
Expand All @@ -73,6 +83,9 @@ class DriveOnHeadingAction : public BtActionNode<nav2_msgs::action::DriveOnHeadi
* @brief Function to perform some user-defined operation upon cancellation of the action
*/
BT::NodeStatus on_cancelled() override;

private:
bool initalized_;
};

} // namespace nav2_behavior_tree
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,10 @@ class RemovePassedGoals : public BT::ActionNodeBase
const std::string & xml_tag_name,
const BT::NodeConfiguration & conf);

/**
* @brief Function to read parameters and initialize class variables
*/
void initialize();

static BT::PortsList providedPorts()
{
Expand All @@ -56,6 +60,7 @@ class RemovePassedGoals : public BT::ActionNodeBase
double transform_tolerance_;
std::shared_ptr<tf2_ros::Buffer> tf_;
std::string robot_base_frame_;
bool initialized_;
};

} // namespace nav2_behavior_tree
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,11 @@ class SpinAction : public BtActionNode<nav2_msgs::action::Spin>
*/
void on_tick() override;

/**
* @brief Function to read parameters and initialize class variables
*/
void initialize();

/**
* @brief Creates list of BT ports
* @return BT::PortsList Containing basic ports along with node-specific ports
Expand Down Expand Up @@ -81,6 +86,7 @@ class SpinAction : public BtActionNode<nav2_msgs::action::Spin>

private:
bool is_recovery_;
bool initialized_;
};

} // namespace nav2_behavior_tree
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,11 @@ class WaitAction : public BtActionNode<nav2_msgs::action::Wait>
*/
void on_tick() override;

/**
* @brief Function to read parameters and initialize class variables
*/
void initialize();

/**
* @brief Creates list of BT ports
* @return BT::PortsList Containing basic ports along with node-specific ports
Expand All @@ -56,6 +61,9 @@ class WaitAction : public BtActionNode<nav2_msgs::action::Wait>
BT::InputPort<double>("wait_duration", 1.0, "Wait time")
});
}

private:
bool initialized_;
};

} // namespace nav2_behavior_tree
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,11 @@ class DistanceTraveledCondition : public BT::ConditionNode
*/
BT::NodeStatus tick() override;

/**
* @brief Function to read parameters and initialize class variables
*/
void initialize();

/**
* @brief Creates list of BT ports
* @return BT::PortsList Containing node-specific ports
Expand All @@ -74,6 +79,7 @@ class DistanceTraveledCondition : public BT::ConditionNode
double distance_;
double transform_tolerance_;
std::string global_frame_, robot_base_frame_;
bool initialized_;
};

} // namespace nav2_behavior_tree
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,11 @@ class IsBatteryLowCondition : public BT::ConditionNode
*/
BT::NodeStatus tick() override;

/**
* @brief Function to read parameters and initialize class variables
*/
void initialize();

/**
* @brief Creates list of BT ports
* @return BT::PortsList Containing node-specific ports
Expand Down Expand Up @@ -81,6 +86,7 @@ class IsBatteryLowCondition : public BT::ConditionNode
double min_battery_;
bool is_voltage_;
bool is_battery_low_;
bool initialized_;
};

} // namespace nav2_behavior_tree
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,11 @@ class IsPathValidCondition : public BT::ConditionNode
*/
BT::NodeStatus tick() override;

/**
* @brief Function to read parameters and initialize class variables
*/
void initialize();

/**
* @brief Creates list of BT ports
* @return BT::PortsList Containing node-specific ports
Expand All @@ -68,6 +73,7 @@ class IsPathValidCondition : public BT::ConditionNode
// The timeout value while waiting for a responce from the
// is path valid service
std::chrono::milliseconds server_timeout_;
bool initialized_;
};

} // namespace nav2_behavior_tree
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,11 @@ class TimeExpiredCondition : public BT::ConditionNode
*/
BT::NodeStatus tick() override;

/**
* @brief Function to read parameters and initialize class variables
*/
void initialize();

/**
* @brief Creates list of BT ports
* @return BT::PortsList Containing node-specific ports
Expand All @@ -63,6 +68,7 @@ class TimeExpiredCondition : public BT::ConditionNode
rclcpp::Node::SharedPtr node_;
rclcpp::Time start_;
double period_;
bool initialized_;
};

} // namespace nav2_behavior_tree
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,11 @@ class TransformAvailableCondition : public BT::ConditionNode
*/
BT::NodeStatus tick() override;

/**
* @brief Function to read parameters and initialize class variables
*/
void initialize();

/**
* @brief Creates list of BT ports
* @return BT::PortsList Containing node-specific ports
Expand All @@ -75,6 +80,7 @@ class TransformAvailableCondition : public BT::ConditionNode

std::string child_frame_;
std::string parent_frame_;
bool initialized_;
};

} // namespace nav2_behavior_tree
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
#include <string>

#include "nav2_msgs/action/compute_path_to_pose.hpp"
#include "nav2_msgs/action/compute_path_through_poses.hpp"
#include "nav2_behavior_tree/plugins/condition/are_error_codes_present_condition.hpp"

namespace nav2_behavior_tree
Expand All @@ -27,6 +28,8 @@ class WouldAPlannerRecoveryHelp : public AreErrorCodesPresent
{
using Action = nav2_msgs::action::ComputePathToPose;
using ActionResult = Action::Result;
using ThroughAction = nav2_msgs::action::ComputePathThroughPoses;
using ThroughActionResult = Action::Result;

public:
WouldAPlannerRecoveryHelp(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,11 @@ class RateController : public BT::DecoratorNode
const std::string & name,
const BT::NodeConfiguration & conf);

/**
* @brief Function to read parameters and initialize class variables
*/
void initialize();

/**
* @brief Creates list of BT ports
* @return BT::PortsList Containing node-specific ports
Expand All @@ -59,6 +64,7 @@ class RateController : public BT::DecoratorNode
std::chrono::time_point<std::chrono::high_resolution_clock> start_;
double period_;
bool first_time_;
bool initialized_;
};

} // namespace nav2_behavior_tree
Expand Down
11 changes: 10 additions & 1 deletion nav2_behavior_tree/plugins/action/assisted_teleop_action.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,18 +24,27 @@ AssistedTeleopAction::AssistedTeleopAction(
const std::string & xml_tag_name,
const std::string & action_name,
const BT::NodeConfiguration & conf)
: BtActionNode<nav2_msgs::action::AssistedTeleop>(xml_tag_name, action_name, conf)
: BtActionNode<nav2_msgs::action::AssistedTeleop>(xml_tag_name, action_name, conf),
initialized_(false)
{}

void AssistedTeleopAction::initialize()
{
double time_allowance;
getInput("time_allowance", time_allowance);
getInput("is_recovery", is_recovery_);

// Populate the input message
goal_.time_allowance = rclcpp::Duration::from_seconds(time_allowance);
initialized_ = true;
}

void AssistedTeleopAction::on_tick()
{
if (!initialized_) {
initialize();
}

if (is_recovery_) {
increment_recovery_count();
}
Expand Down
12 changes: 11 additions & 1 deletion nav2_behavior_tree/plugins/action/back_up_action.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,12 @@ BackUpAction::BackUpAction(
const std::string & xml_tag_name,
const std::string & action_name,
const BT::NodeConfiguration & conf)
: BtActionNode<nav2_msgs::action::BackUp>(xml_tag_name, action_name, conf)
: BtActionNode<nav2_msgs::action::BackUp>(xml_tag_name, action_name, conf),
initialized_(false)
{
}

void nav2_behavior_tree::BackUpAction::initialize()
{
double dist;
getInput("backup_dist", dist);
Expand All @@ -39,10 +44,15 @@ BackUpAction::BackUpAction(
goal_.target.z = 0.0;
goal_.speed = speed;
goal_.time_allowance = rclcpp::Duration::from_seconds(time_allowance);
initialized_ = true;
}

void BackUpAction::on_tick()
{
if (!initialized_) {
initialize();
}

increment_recovery_count();
}

Expand Down
Loading

0 comments on commit 9a88fe9

Please sign in to comment.