Skip to content

Commit e6da02f

Browse files
SteveMacenskiARK3rGoesMGoesMbi0ha2ard
authored
Iron sync 5: April 4, 2024 (#4240)
* nav2_controller: add loop rate log (#4171) * update smac_planner README Signed-off-by: ARK3r <[email protected]> * added current controller loop rate logging Signed-off-by: ARK3r <[email protected]> * linting Signed-off-by: ARK3r <[email protected]> * uncrustify lint Signed-off-by: ARK3r <[email protected]> * Update nav2_controller/src/controller_server.cpp Signed-off-by: Steve Macenski <[email protected]> * Update nav2_controller/src/controller_server.cpp Signed-off-by: Steve Macenski <[email protected]> * Update nav2_controller/src/controller_server.cpp Signed-off-by: Steve Macenski <[email protected]> --------- Signed-off-by: ARK3r <[email protected]> Signed-off-by: Steve Macenski <[email protected]> Co-authored-by: Steve Macenski <[email protected]> * completely shutdown inital_pose_sub_ (#4176) Signed-off-by: GoesM <[email protected]> Co-authored-by: GoesM <[email protected]> * chore(nav2_behavior_tree): log actual wait period in bt_action_node (#4178) Signed-off-by: Felix <[email protected]> Co-authored-by: Felix <[email protected]> * replace throw-error with error-log to avoid UAF mentioned in #4175 (#4180) * replace throw-error with error-log to avoid UAF Signed-off-by: GoesM <[email protected]> * fix typo Signed-off-by: GoesM <[email protected]> --------- Signed-off-by: GoesM <[email protected]> Co-authored-by: GoesM <[email protected]> * fix typos in description messages (#4188) Signed-off-by: Antonio Park <[email protected]> * AMCL: Set an initial guess by service call (#4182) * Added initial guess service. Signed-off-by: Alexander Mock Signed-off-by: Alexander Mock <[email protected]> * - Removed added empty line - Renamed initialGuessCallback to initialPoseReceivedSrv - Added new line to SetInitialPose service definition - Removed mutex from initialPoseReceived - Cleanup service server Signed-off-by: Alexander Mock <[email protected]> * added whitespace Signed-off-by: Alexander Mock <[email protected]> * renamed initial pose service in callback bind Signed-off-by: Alexander Mock <[email protected]> --------- Signed-off-by: Alexander Mock <[email protected]> * Move lines for pre-computation to outside a loop (#4191) Signed-off-by: Kyungsik Park <[email protected]> * Fix typo (#4196) * Fix BT.CPP import Signed-off-by: Tony Najjar <[email protected]> * Update README.md --------- Signed-off-by: Tony Najjar <[email protected]> * Update footprint iif changed (#4193) Signed-off-by: Brice <[email protected]> * fix missing param declare (#4203) Signed-off-by: nelson <[email protected]> * Revert "nav2_controller: add loop rate log (#4171)" (#4210) This reverts commit 4737462. * add polygon_subscribe_transient_local parameter in collision monitor (#4207) Signed-off-by: asarazin <[email protected]> Co-authored-by: asarazin <[email protected]> * nav2_controller: add loop rate log (#4228) * added current loop rate printout Signed-off-by: ARK3r <[email protected]> * remove empty line Signed-off-by: ARK3r <[email protected]> --------- Signed-off-by: ARK3r <[email protected]> * bump to 1.2.7 for iron sync * change pointer free order in amcl to avoid use-after-free bug mentioned in #4068 (#4070) Signed-off-by: GoesM <[email protected]> Co-authored-by: GoesM <[email protected]> * Allow path end pose deviation revive (#4065) * Support stitching paths in compute path to poses * Update nav2_planner/src/planner_server.cpp Co-authored-by: Steve Macenski <[email protected]> * Rename parameter to allow_path_through_poses_goal_deviation * Fix description * restore nav2_params * missing whitespace * lint fix * removed parameter Signed-off-by: gg <[email protected]> * Update planner_server.hpp * Update planner_server.cpp --------- Signed-off-by: gg <[email protected]> Co-authored-by: pepisg <[email protected]> Co-authored-by: Pedro Alejandro González <[email protected]> Co-authored-by: Steve Macenski <[email protected]> * Change costmap_queue to shared library (#4072) Signed-off-by: cybaol <[email protected]> * free `map_sub_` before `map_free(map_)` to avoid UAF&&NullPtr bug mentioned in #4078 (#4079) * free `map_sub_` before `map_free(map_)` Signed-off-by: GoesM <[email protected]> * reformat Signed-off-by: GoesM <[email protected]> --------- Signed-off-by: GoesM <[email protected]> Co-authored-by: GoesM <[email protected]> * Fix typo (#4087) Fix AttributeError: 'BasicNavigator' object has no attribute '_BasicNavigator__getPathThroughPosesImpl' Signed-off-by: nfriedrich00 <[email protected]> * Add velocity based polygon (#3708) * add velocity based polygon * fix header, copyright and variable name change * optimise polygon update * optimise duplicated code with setPolygonShape * add warning log for uncovered speed * update feedback * rename polygon velocity to velocity polygon * cleanup * fix typo * add dynamic support for velocity polygon * wrap try catch for getting parameters * update naming and linting * use switch case * Revert "use switch case" This reverts commit 1230ede. * fix proper return for invalid parameters * remove topic parameter for velocity polygon * fix formatting manually * continue if points are not defined * rewrite velocity polygon with polygon base class Signed-off-by: nelson <[email protected]> * update review comments and description Signed-off-by: nelson <[email protected]> * add VelocityPolygon to detector node Signed-off-by: nelson <[email protected]> * review update Signed-off-by: nelson <[email protected]> * fix cpplint Signed-off-by: nelson <[email protected]> * Update nav2_collision_monitor/src/velocity_polygon.cpp Co-authored-by: Steve Macenski <[email protected]> Signed-off-by: nelson <[email protected]> * add velocity polygon tests Signed-off-by: nelson <[email protected]> * fix cpplint Signed-off-by: nelson <[email protected]> * add in-line comment Signed-off-by: nelson <[email protected]> * fix push back Signed-off-by: nelson <[email protected]> * minor change and update README Signed-off-by: nelson <[email protected]> * update README Signed-off-by: nelson <[email protected]> --------- Signed-off-by: nelson <[email protected]> Co-authored-by: Steve Macenski <[email protected]> * avoid implicit type case (#4098) * adding progress checker selector BT node (#4109) * New MPPI Cost Critic (Contrib: Brice Renaudeau) (#4090) * Share code Signed-off-by: Brice <[email protected]> * Update inflation_cost_critic.hpp - copyright - ifndef Signed-off-by: Brice <[email protected]> * fix lint cpp - extra space Signed-off-by: Brice <[email protected]> * Fix Smac Planner confined collision checker (#4055) * Update collision_checker.cpp Signed-off-by: Steve Macenski <[email protected]> * Fix tests Signed-off-by: Steve Macenski <[email protected]> * Update test_a_star.cpp Signed-off-by: Steve Macenski <[email protected]> --------- Signed-off-by: Steve Macenski <[email protected]> Signed-off-by: Brice <[email protected]> * Prevent analytic expansions from shortcutting Smac Planner feasible paths (#3962) * a potential solution to smac shortcutting * costmap reoslution * some fixes * completed prototype * some fixes for collision detection and performance * completing shortcutting fix * updating tests * adding readme --------- Signed-off-by: Steve Macenski <[email protected]> Signed-off-by: Brice <[email protected]> * change pointer free order in amcl to avoid use-after-free bug mentioned in #4068 (#4070) Signed-off-by: GoesM <[email protected]> Co-authored-by: GoesM <[email protected]> Signed-off-by: Brice <[email protected]> * [Smac Planner] Massive Improvement of Behavior for SE2 Footprint Checking (ie non-circular robots) In Confined Settings (#4067) * prototype to test SE2 footprint H improvements * some fixes * fixed * invert logic * Working final prototype to be tested * complete unit test conversions * Update inflation_layer.hpp Signed-off-by: Steve Macenski <[email protected]> --------- Signed-off-by: Steve Macenski <[email protected]> Signed-off-by: Brice <[email protected]> * Adding new Smac paper to readme Signed-off-by: Steve Macenski <[email protected]> Signed-off-by: Brice <[email protected]> * Update README.md Signed-off-by: Steve Macenski <[email protected]> Signed-off-by: Brice <[email protected]> * [behavior_tree] don't repeat yourself in "blackboard->set" (#4074) * don't repeat yourself: templates in tests Signed-off-by: Davide Faconti <[email protected]> * misse change Signed-off-by: Davide Faconti <[email protected]> --------- Signed-off-by: Davide Faconti <[email protected]> Signed-off-by: Brice <[email protected]> * Allow path end pose deviation revive (#4065) * Support stitching paths in compute path to poses * Update nav2_planner/src/planner_server.cpp Co-authored-by: Steve Macenski <[email protected]> * Rename parameter to allow_path_through_poses_goal_deviation * Fix description * restore nav2_params * missing whitespace * lint fix * removed parameter Signed-off-by: gg <[email protected]> * Update planner_server.hpp * Update planner_server.cpp --------- Signed-off-by: gg <[email protected]> Co-authored-by: pepisg <[email protected]> Co-authored-by: Pedro Alejandro González <[email protected]> Co-authored-by: Steve Macenski <[email protected]> Signed-off-by: Brice <[email protected]> * Updated code to use getInflationLayer() method (#4076) * updated code to use getInflationLayer method Signed-off-by: Jose Faria <[email protected]> * Fix linting Signed-off-by: Jose Faria <[email protected]> --------- Signed-off-by: Jose Faria <[email protected]> Signed-off-by: Brice <[email protected]> * 1594 twist stamped publisher (#4077) * Add TwistStamped to controller_server via TwistPublisher util * Add a new util class for publishing either Twist or TwistStamped * Add a new parameter for selecting to stamp the twist data * Consume TwistPublisher in nav2_controller Signed-off-by: Ryan Friedman <[email protected]> * Fix small issues * Unused variable * Incorrect doxygen Signed-off-by: Ryan Friedman <[email protected]> * Remove stored node and assert Signed-off-by: Ryan Friedman <[email protected]> * Add tests for node * Facing timeout even though it does the same thing as velocity smoother test Signed-off-by: Ryan Friedman <[email protected]> * Add missing spin call to solve timeout Signed-off-by: Ryan Friedman <[email protected]> * Fix copyright (me instead of intel) Signed-off-by: Ryan Friedman <[email protected]> * Add full test coverage with subscriber Signed-off-by: Ryan Friedman <[email protected]> * Remove unused rclcpp fixture * Can't use it due to needing to join the pub thread after rclcpp shuts down Signed-off-by: Ryan Friedman <[email protected]> * Use TwistStamped in nav2_behaviors Signed-off-by: Ryan Friedman <[email protected]> * Use TwistStamped in collision monitor node Signed-off-by: Ryan Friedman <[email protected]> * Add TwistStamped readme updates to velocity smoother Signed-off-by: Ryan Friedman <[email protected]> * Add TwistSubscriber implementation Signed-off-by: Ryan Friedman <[email protected]> * Fix syntax errors Signed-off-by: Ryan Friedman <[email protected]> * Use TwistSubscriber in test_velocity_smoother Signed-off-by: Ryan Friedman <[email protected]> * Use TwistSubscriber in assisted_teleop Signed-off-by: Ryan Friedman <[email protected]> * Use TwistSubscriber in collision monitor node Signed-off-by: Ryan Friedman <[email protected]> * Use TwistSubscriber in velocity smoother Signed-off-by: Ryan Friedman <[email protected]> * Remove unused code Signed-off-by: Ryan Friedman <[email protected]> * add timestamp and frame_id to TwistStamped message * Add missing utility include Signed-off-by: Ryan Friedman <[email protected]> * Document TwistPublisher and TwistSubscriber usage Signed-off-by: Ryan Friedman <[email protected]> * Use pass-by-reference * Instead of std::move(std::unique_ptr<TwistStamped>) Signed-off-by: Ryan Friedman <[email protected]> * Finish twist subscriber tests Signed-off-by: Ryan Friedman <[email protected]> * Add other constructor and docs Signed-off-by: Ryan Friedman <[email protected]> * Fix linter issues Signed-off-by: Ryan Friedman <[email protected]> * Manually fix paren alignment Signed-off-by: Ryan Friedman <[email protected]> * Remove GSoC reference Signed-off-by: Ryan Friedman <[email protected]> * Document twist bool param in README Signed-off-by: Ryan Friedman <[email protected]> * Handle twistPublisher in collision monitor * Implement behavior in the stamped callback * Unstamped callback calls the stamped callback * Switch to unique pointer for publisher Signed-off-by: Ryan Friedman <[email protected]> * Convert to using TwistStamped interally * Use incoming twistStamped timestamp if available * Convert all internal representations to use TwistStamped Signed-off-by: Ryan Friedman <[email protected]> * Remove nav2_util usage instructions Signed-off-by: Ryan Friedman <[email protected]> * Remove unused Twist only subscriber Signed-off-by: Ryan Friedman <[email protected]> * More linter fixes Signed-off-by: Ryan Friedman <[email protected]> * Prefer working with unique_ptr for cmd_vel * This makes it easier to switch to std::move instead of dereference on publish Signed-off-by: Ryan Friedman <[email protected]> * Completing twist stamped migration * shared to unique ptr Signed-off-by: Steve Macenski <[email protected]> * twist add stamps and properly propogated * nav2_util: fix for compiling with clang - Resolve error: moving a temporary object prevents copy elision [-Werror,-Wpessimizing-move] Signed-off-by: Rhys Mainwaring <[email protected]> --------- Signed-off-by: Ryan Friedman <[email protected]> Signed-off-by: Steve Macenski <[email protected]> Signed-off-by: Rhys Mainwaring <[email protected]> Co-authored-by: pedro-fuoco <[email protected]> Co-authored-by: Steve Macenski <[email protected]> Co-authored-by: Rhys Mainwaring <[email protected]> Signed-off-by: Brice <[email protected]> * Change costmap_queue to shared library (#4072) Signed-off-by: cybaol <[email protected]> Signed-off-by: Brice <[email protected]> * fix include of hpp Signed-off-by: Brice Renaudeau <[email protected]> * inflation cost optmiizations and cleanu * rename, add defaults, and docs * smoke test addition * lintg * normalize weight * update readme * increment cache * Update cost_critic.hpp Signed-off-by: Steve Macenski <[email protected]> * Update cost_critic.cpp Signed-off-by: Steve Macenski <[email protected]> --------- Signed-off-by: Brice <[email protected]> Signed-off-by: Steve Macenski <[email protected]> Signed-off-by: GoesM <[email protected]> Signed-off-by: Davide Faconti <[email protected]> Signed-off-by: gg <[email protected]> Signed-off-by: Jose Faria <[email protected]> Signed-off-by: Ryan Friedman <[email protected]> Signed-off-by: Rhys Mainwaring <[email protected]> Signed-off-by: cybaol <[email protected]> Signed-off-by: Brice Renaudeau <[email protected]> Co-authored-by: BriceRenaudeau <[email protected]> Co-authored-by: GoesM <[email protected]> Co-authored-by: GoesM <[email protected]> Co-authored-by: Davide Faconti <[email protected]> Co-authored-by: Joshua Wallace <[email protected]> Co-authored-by: pepisg <[email protected]> Co-authored-by: Pedro Alejandro González <[email protected]> Co-authored-by: jncfa <[email protected]> Co-authored-by: Ryan <[email protected]> Co-authored-by: pedro-fuoco <[email protected]> Co-authored-by: Rhys Mainwaring <[email protected]> Co-authored-by: Kino <[email protected]> * Use ament_export_targets for all targets (#4112) * Matches new internal ALIAS targets * Use ALIAS targets for all internal linkage * Remove unnecessary calls to ament_target_dependencies in test code * Export includes in proper folders for overlays in colcon Signed-off-by: Ryan Friedman <[email protected]> * Update default recommendation from Obstacles to Cost critic in MPPI (#4170) Signed-off-by: Steve Macenski <[email protected]> * fix merge conflict * Revert "Add velocity based polygon (#3708)" This reverts commit a3ed745. * custom backported version of cost critic inscribed cost --------- Signed-off-by: ARK3r <[email protected]> Signed-off-by: Steve Macenski <[email protected]> Signed-off-by: GoesM <[email protected]> Signed-off-by: Felix <[email protected]> Signed-off-by: Antonio Park <[email protected]> Signed-off-by: Alexander Mock <[email protected]> Signed-off-by: Kyungsik Park <[email protected]> Signed-off-by: Tony Najjar <[email protected]> Signed-off-by: Brice <[email protected]> Signed-off-by: nelson <[email protected]> Signed-off-by: asarazin <[email protected]> Signed-off-by: gg <[email protected]> Signed-off-by: cybaol <[email protected]> Signed-off-by: nfriedrich00 <[email protected]> Signed-off-by: Davide Faconti <[email protected]> Signed-off-by: Jose Faria <[email protected]> Signed-off-by: Ryan Friedman <[email protected]> Signed-off-by: Rhys Mainwaring <[email protected]> Signed-off-by: Brice Renaudeau <[email protected]> Co-authored-by: Reza Kermani <[email protected]> Co-authored-by: GoesM <[email protected]> Co-authored-by: GoesM <[email protected]> Co-authored-by: bi0ha2ard <[email protected]> Co-authored-by: Felix <[email protected]> Co-authored-by: Antonio Park <[email protected]> Co-authored-by: Alexander Mock <[email protected]> Co-authored-by: Tony Najjar <[email protected]> Co-authored-by: BriceRenaudeau <[email protected]> Co-authored-by: nelson <[email protected]> Co-authored-by: anaelle-sw <[email protected]> Co-authored-by: asarazin <[email protected]> Co-authored-by: Joshua Wallace <[email protected]> Co-authored-by: pepisg <[email protected]> Co-authored-by: Pedro Alejandro González <[email protected]> Co-authored-by: Kino <[email protected]> Co-authored-by: nfriedrich00 <[email protected]> Co-authored-by: Davide Faconti <[email protected]> Co-authored-by: jncfa <[email protected]> Co-authored-by: Ryan <[email protected]> Co-authored-by: pedro-fuoco <[email protected]> Co-authored-by: Rhys Mainwaring <[email protected]>
1 parent 3e6c016 commit e6da02f

File tree

75 files changed

+916
-151
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

75 files changed

+916
-151
lines changed

nav2_amcl/include/nav2_amcl/amcl_node.hpp

+11
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
#include "nav2_amcl/sensors/laser/laser.hpp"
3636
#include "nav2_msgs/msg/particle.hpp"
3737
#include "nav2_msgs/msg/particle_cloud.hpp"
38+
#include "nav2_msgs/srv/set_initial_pose.hpp"
3839
#include "nav_msgs/srv/set_map.hpp"
3940
#include "sensor_msgs/msg/laser_scan.hpp"
4041
#include "std_srvs/srv/empty.hpp"
@@ -210,6 +211,16 @@ class AmclNode : public nav2_util::LifecycleNode
210211
const std::shared_ptr<std_srvs::srv::Empty::Request> request,
211212
std::shared_ptr<std_srvs::srv::Empty::Response> response);
212213

214+
// service server for providing an initial pose guess
215+
rclcpp::Service<nav2_msgs::srv::SetInitialPose>::SharedPtr initial_guess_srv_;
216+
/*
217+
* @brief Service callback for an initial pose guess request
218+
*/
219+
void initialPoseReceivedSrv(
220+
const std::shared_ptr<rmw_request_id_t> request_header,
221+
const std::shared_ptr<nav2_msgs::srv::SetInitialPose::Request> request,
222+
std::shared_ptr<nav2_msgs::srv::SetInitialPose::Response> response);
223+
213224
// Let amcl update samples without requiring motion
214225
rclcpp::Service<std_srvs::srv::Empty>::SharedPtr nomotion_update_srv_;
215226
/*

nav2_amcl/package.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<?xml-model href="http://download.ros.org/schema/package_format3.xsd" schematypens="http://www.w3.org/2001/XMLSchema"?>
33
<package format="3">
44
<name>nav2_amcl</name>
5-
<version>1.2.6</version>
5+
<version>1.2.7</version>
66
<description>
77
<p>
88
amcl is a probabilistic localization system for a robot moving in

nav2_amcl/src/amcl_node.cpp

+21-5
Original file line numberDiff line numberDiff line change
@@ -325,13 +325,17 @@ AmclNode::on_cleanup(const rclcpp_lifecycle::State & /*state*/)
325325
// Get rid of the inputs first (services and message filter input), so we
326326
// don't continue to process incoming messages
327327
global_loc_srv_.reset();
328+
initial_guess_srv_.reset();
328329
nomotion_update_srv_.reset();
330+
executor_thread_.reset(); // to make sure initial_pose_sub_ completely exit
329331
initial_pose_sub_.reset();
330332
laser_scan_connection_.disconnect();
333+
tf_listener_.reset(); // listener may access lase_scan_filter_, so it should be reset earlier
331334
laser_scan_filter_.reset();
332335
laser_scan_sub_.reset();
333336

334337
// Map
338+
map_sub_.reset(); // map_sub_ may access map_, so it should be reset earlier
335339
if (map_ != NULL) {
336340
map_free(map_);
337341
map_ = nullptr;
@@ -341,7 +345,6 @@ AmclNode::on_cleanup(const rclcpp_lifecycle::State & /*state*/)
341345

342346
// Transforms
343347
tf_broadcaster_.reset();
344-
tf_listener_.reset();
345348
tf_buffer_.reset();
346349

347350
// PubSub
@@ -493,6 +496,15 @@ AmclNode::globalLocalizationCallback(
493496
pf_init_ = false;
494497
}
495498

499+
void
500+
AmclNode::initialPoseReceivedSrv(
501+
const std::shared_ptr<rmw_request_id_t>/*request_header*/,
502+
const std::shared_ptr<nav2_msgs::srv::SetInitialPose::Request> req,
503+
std::shared_ptr<nav2_msgs::srv::SetInitialPose::Response>/*res*/)
504+
{
505+
initialPoseReceived(std::make_shared<geometry_msgs::msg::PoseWithCovarianceStamped>(req->pose));
506+
}
507+
496508
// force nomotion updates (amcl updating without requiring motion)
497509
void
498510
AmclNode::nomotionUpdateCallback(
@@ -1102,20 +1114,20 @@ AmclNode::initParameters()
11021114
// Semantic checks
11031115
if (laser_likelihood_max_dist_ < 0) {
11041116
RCLCPP_WARN(
1105-
get_logger(), "You've set laser_likelihood_max_dist to be negtive,"
1117+
get_logger(), "You've set laser_likelihood_max_dist to be negative,"
11061118
" this isn't allowed so it will be set to default value 2.0.");
11071119
laser_likelihood_max_dist_ = 2.0;
11081120
}
11091121
if (max_particles_ < 0) {
11101122
RCLCPP_WARN(
1111-
get_logger(), "You've set max_particles to be negtive,"
1123+
get_logger(), "You've set max_particles to be negative,"
11121124
" this isn't allowed so it will be set to default value 2000.");
11131125
max_particles_ = 2000;
11141126
}
11151127

11161128
if (min_particles_ < 0) {
11171129
RCLCPP_WARN(
1118-
get_logger(), "You've set min_particles to be negtive,"
1130+
get_logger(), "You've set min_particles to be negative,"
11191131
" this isn't allowed so it will be set to default value 500.");
11201132
min_particles_ = 500;
11211133
}
@@ -1129,7 +1141,7 @@ AmclNode::initParameters()
11291141

11301142
if (resample_interval_ <= 0) {
11311143
RCLCPP_WARN(
1132-
get_logger(), "You've set resample_interval to be zero or negtive,"
1144+
get_logger(), "You've set resample_interval to be zero or negative,"
11331145
" this isn't allowed so it will be set to default value to 1.");
11341146
resample_interval_ = 1;
11351147
}
@@ -1542,6 +1554,10 @@ AmclNode::initServices()
15421554
"reinitialize_global_localization",
15431555
std::bind(&AmclNode::globalLocalizationCallback, this, _1, _2, _3));
15441556

1557+
initial_guess_srv_ = create_service<nav2_msgs::srv::SetInitialPose>(
1558+
"set_initial_pose",
1559+
std::bind(&AmclNode::initialPoseReceivedSrv, this, _1, _2, _3));
1560+
15451561
nomotion_update_srv_ = create_service<std_srvs::srv::Empty>(
15461562
"request_nomotion_update",
15471563
std::bind(&AmclNode::nomotionUpdateCallback, this, _1, _2, _3));

nav2_amcl/src/sensors/laser/likelihood_field_model.cpp

+11-11
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,17 @@ LikelihoodFieldModel::sensorFunction(LaserData * data, pf_sample_set_t * set)
5353

5454
self = reinterpret_cast<LikelihoodFieldModel *>(data->laser);
5555

56+
// Pre-compute a couple of things
57+
double z_hit_denom = 2 * self->sigma_hit_ * self->sigma_hit_;
58+
double z_rand_mult = 1.0 / data->range_max;
59+
60+
step = (data->range_count - 1) / (self->max_beams_ - 1);
61+
62+
// Step size must be at least 1
63+
if (step < 1) {
64+
step = 1;
65+
}
66+
5667
total_weight = 0.0;
5768

5869
// Compute the sample weights
@@ -65,17 +76,6 @@ LikelihoodFieldModel::sensorFunction(LaserData * data, pf_sample_set_t * set)
6576

6677
p = 1.0;
6778

68-
// Pre-compute a couple of things
69-
double z_hit_denom = 2 * self->sigma_hit_ * self->sigma_hit_;
70-
double z_rand_mult = 1.0 / data->range_max;
71-
72-
step = (data->range_count - 1) / (self->max_beams_ - 1);
73-
74-
// Step size must be at least 1
75-
if (step < 1) {
76-
step = 1;
77-
}
78-
7979
for (i = 0; i < data->range_count; i += step) {
8080
obs_range = data->ranges[i][0];
8181
obs_bearing = data->ranges[i][1];

nav2_behavior_tree/CMakeLists.txt

+3
Original file line numberDiff line numberDiff line change
@@ -204,6 +204,9 @@ list(APPEND plugin_libs nav2_smoother_selector_bt_node)
204204
add_library(nav2_goal_checker_selector_bt_node SHARED plugins/action/goal_checker_selector_node.cpp)
205205
list(APPEND plugin_libs nav2_goal_checker_selector_bt_node)
206206

207+
add_library(nav2_progress_checker_selector_bt_node SHARED plugins/action/progress_checker_selector_node.cpp)
208+
list(APPEND plugin_libs nav2_progress_checker_selector_bt_node)
209+
207210
add_library(nav2_goal_updated_controller_bt_node SHARED plugins/decorator/goal_updated_controller.cpp)
208211
list(APPEND plugin_libs nav2_goal_updated_controller_bt_node)
209212

nav2_behavior_tree/include/nav2_behavior_tree/bt_action_node.hpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ class BtActionNode : public BT::ActionNodeBase
9595
RCLCPP_DEBUG(node_->get_logger(), "Waiting for \"%s\" action server", action_name.c_str());
9696
if (!action_client_->wait_for_action_server(1s)) {
9797
RCLCPP_ERROR(
98-
node_->get_logger(), "\"%s\" action server not available after waiting for 1 s",
98+
node_->get_logger(), "\"%s\" action server not available after waiting for 1s",
9999
action_name.c_str());
100100
throw std::runtime_error(
101101
std::string("Action server ") + action_name +

nav2_behavior_tree/include/nav2_behavior_tree/bt_action_server_impl.hpp

+3
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,9 @@ BtActionServer<ActionT>::BtActionServer(
6464
if (!node->has_parameter("action_server_result_timeout")) {
6565
node->declare_parameter("action_server_result_timeout", 900.0);
6666
}
67+
if (!node->has_parameter("wait_for_service_timeout")) {
68+
node->declare_parameter("wait_for_service_timeout", 1000);
69+
}
6770

6871
std::vector<std::string> error_code_names = {
6972
"follow_path_error_code",
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
// Copyright (c) 2024 Open Navigation LLC
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
15+
#ifndef NAV2_BEHAVIOR_TREE__PLUGINS__ACTION__PROGRESS_CHECKER_SELECTOR_NODE_HPP_
16+
#define NAV2_BEHAVIOR_TREE__PLUGINS__ACTION__PROGRESS_CHECKER_SELECTOR_NODE_HPP_
17+
18+
#include <memory>
19+
#include <string>
20+
21+
#include "std_msgs/msg/string.hpp"
22+
23+
#include "behaviortree_cpp_v3/action_node.h"
24+
25+
#include "rclcpp/rclcpp.hpp"
26+
27+
namespace nav2_behavior_tree
28+
{
29+
30+
/**
31+
* @brief The ProgressCheckerSelector behavior is used to switch the progress checker
32+
* of the controller server. It subscribes to a topic "progress_checker_selector"
33+
* to get the decision about what progress_checker must be used. It is usually used before of
34+
* the FollowPath. The selected_progress_checker output port is passed to progress_checker_id
35+
* input port of the FollowPath
36+
*/
37+
class ProgressCheckerSelector : public BT::SyncActionNode
38+
{
39+
public:
40+
/**
41+
* @brief A constructor for nav2_behavior_tree::ProgressCheckerSelector
42+
*
43+
* @param xml_tag_name Name for the XML tag for this node
44+
* @param conf BT node configuration
45+
*/
46+
ProgressCheckerSelector(
47+
const std::string & xml_tag_name,
48+
const BT::NodeConfiguration & conf);
49+
50+
/**
51+
* @brief Creates list of BT ports
52+
* @return BT::PortsList Containing basic ports along with node-specific ports
53+
*/
54+
static BT::PortsList providedPorts()
55+
{
56+
return {
57+
BT::InputPort<std::string>(
58+
"default_progress_checker",
59+
"the default progress_checker to use if there is not any external topic message received."),
60+
61+
BT::InputPort<std::string>(
62+
"topic_name",
63+
"progress_checker_selector",
64+
"the input topic name to select the progress_checker"),
65+
66+
BT::OutputPort<std::string>(
67+
"selected_progress_checker",
68+
"Selected progress_checker by subscription")
69+
};
70+
}
71+
72+
private:
73+
/**
74+
* @brief Function to perform some user-defined operation on tick
75+
*/
76+
BT::NodeStatus tick() override;
77+
78+
/**
79+
* @brief callback function for the progress_checker_selector topic
80+
*
81+
* @param msg the message with the id of the progress_checker_selector
82+
*/
83+
void callbackProgressCheckerSelect(const std_msgs::msg::String::SharedPtr msg);
84+
85+
rclcpp::Subscription<std_msgs::msg::String>::SharedPtr progress_checker_selector_sub_;
86+
87+
std::string last_selected_progress_checker_;
88+
89+
rclcpp::Node::SharedPtr node_;
90+
91+
std::string topic_name_;
92+
};
93+
94+
} // namespace nav2_behavior_tree
95+
96+
#endif // NAV2_BEHAVIOR_TREE__PLUGINS__ACTION__PROGRESS_CHECKER_SELECTOR_NODE_HPP_

nav2_behavior_tree/nav2_tree_nodes.xml

+6
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,12 @@
182182
<output_port name="selected_goal_checker">Name of the selected goal checker received from the topic subcription</output_port>
183183
</Action>
184184

185+
<Action ID="ProgressCheckerSelector">
186+
<input_port name="topic_name">Name of the topic to receive progress checker selection commands</input_port>
187+
<input_port name="default_progress_checker">Default progress checker of the controller selector</input_port>
188+
<output_port name="selected_progress_checker">Name of the selected progress checker received from the topic subcription</output_port>
189+
</Action>
190+
185191
<Action ID="Spin">
186192
<input_port name="spin_dist">Spin distance</input_port>
187193
<input_port name="time_allowance">Allowed time for spinning</input_port>

nav2_behavior_tree/package.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<?xml-model href="http://download.ros.org/schema/package_format3.xsd" schematypens="http://www.w3.org/2001/XMLSchema"?>
33
<package format="3">
44
<name>nav2_behavior_tree</name>
5-
<version>1.2.6</version>
5+
<version>1.2.7</version>
66
<description>TODO</description>
77
<maintainer email="[email protected]">Michael Jeronimo</maintainer>
88
<maintainer email="[email protected]">Carlos Orduno</maintainer>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
// Copyright (c) 2024 Open Navigation LLC
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
15+
#include <string>
16+
#include <memory>
17+
18+
#include "std_msgs/msg/string.hpp"
19+
20+
#include "nav2_behavior_tree/plugins/action/progress_checker_selector_node.hpp"
21+
22+
#include "rclcpp/rclcpp.hpp"
23+
24+
namespace nav2_behavior_tree
25+
{
26+
27+
using std::placeholders::_1;
28+
29+
ProgressCheckerSelector::ProgressCheckerSelector(
30+
const std::string & name,
31+
const BT::NodeConfiguration & conf)
32+
: BT::SyncActionNode(name, conf)
33+
{
34+
node_ = config().blackboard->get<rclcpp::Node::SharedPtr>("node");
35+
36+
getInput("topic_name", topic_name_);
37+
38+
rclcpp::QoS qos(rclcpp::KeepLast(1));
39+
qos.transient_local().reliable();
40+
41+
progress_checker_selector_sub_ = node_->create_subscription<std_msgs::msg::String>(
42+
topic_name_, qos, std::bind(&ProgressCheckerSelector::callbackProgressCheckerSelect, this, _1));
43+
}
44+
45+
BT::NodeStatus ProgressCheckerSelector::tick()
46+
{
47+
rclcpp::spin_some(node_);
48+
49+
// This behavior always use the last selected progress checker received from the topic input.
50+
// When no input is specified it uses the default goaprogressl checker.
51+
// If the default progress checker is not specified then we work in
52+
// "required progress checker mode": In this mode, the behavior returns failure if the progress
53+
// checker selection is not received from the topic input.
54+
if (last_selected_progress_checker_.empty()) {
55+
std::string default_progress_checker;
56+
getInput("default_progress_checker", default_progress_checker);
57+
if (default_progress_checker.empty()) {
58+
return BT::NodeStatus::FAILURE;
59+
} else {
60+
last_selected_progress_checker_ = default_progress_checker;
61+
}
62+
}
63+
64+
setOutput("selected_progress_checker", last_selected_progress_checker_);
65+
66+
return BT::NodeStatus::SUCCESS;
67+
}
68+
69+
void
70+
ProgressCheckerSelector::callbackProgressCheckerSelect(const std_msgs::msg::String::SharedPtr msg)
71+
{
72+
last_selected_progress_checker_ = msg->data;
73+
}
74+
75+
} // namespace nav2_behavior_tree
76+
77+
#include "behaviortree_cpp_v3/bt_factory.h"
78+
BT_REGISTER_NODES(factory)
79+
{
80+
factory.registerNodeType<nav2_behavior_tree::ProgressCheckerSelector>("ProgressCheckerSelector");
81+
}

nav2_behavior_tree/test/plugins/action/CMakeLists.txt

+4
Original file line numberDiff line numberDiff line change
@@ -107,3 +107,7 @@ ament_target_dependencies(test_smoother_selector_node ${dependencies})
107107
ament_add_gtest(test_goal_checker_selector_node test_goal_checker_selector_node.cpp)
108108
target_link_libraries(test_goal_checker_selector_node nav2_goal_checker_selector_bt_node)
109109
ament_target_dependencies(test_goal_checker_selector_node ${dependencies})
110+
111+
ament_add_gtest(test_progress_checker_selector_node test_progress_checker_selector_node.cpp)
112+
target_link_libraries(test_progress_checker_selector_node nav2_progress_checker_selector_bt_node)
113+
ament_target_dependencies(test_progress_checker_selector_node ${dependencies})

0 commit comments

Comments
 (0)