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

Staticial replanning #3100

Draft
wants to merge 132 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 8 commits
Commits
Show all changes
132 commits
Select commit Hold shift + click to select a range
8cfe20f
statistical prototype
SteveMacenski Jun 15, 2022
beeb427
fixed two sample z-test
jwallace42 Jul 25, 2022
f697654
fixed 2 sample z test
jwallace42 Jul 25, 2022
7a14c46
rolling issue
jwallace42 Jul 25, 2022
10445f1
navfn produces costs
jwallace42 Jul 25, 2022
146ca55
complete updates
jwallace42 Aug 3, 2022
c1a499f
Revert "rolling issue"
jwallace42 Aug 5, 2022
5108c97
Revert "navfn produces costs"
jwallace42 Aug 5, 2022
827a0ba
adding plugin type for static in local + removing unused print (#3021)
SteveMacenski Jun 16, 2022
8ba8848
removed extra includes (#3026)
jwallace42 Jun 19, 2022
b7a13d3
remove extra sub (#3025)
jwallace42 Jun 19, 2022
ef0102b
Fix missing dependency on nav2_velocity_smoother (#3031)
hodnajit Jun 21, 2022
21d36bf
adding timeout for action client initialization (#3029)
vinnnyr Jun 22, 2022
2672bd1
- Modified findVelocitySignChange method to transform cusp into robot…
stevenbrills Jun 23, 2022
9e6be2e
cleanup warnings (#3028)
jwallace42 Jun 23, 2022
5f2eede
Update mergify.yml
SteveMacenski Jun 24, 2022
9c08a05
Draft: Added GoalUpdatedController BT plugin node (#3044)
relffok Jun 28, 2022
6a5165b
installing plugins folder of nav2_behaviors package (#3051)
SrijaneeBiswas Jun 28, 2022
e63eae1
Completed PR 2929 (#3038)
SteveMacenski Jun 30, 2022
02a8dab
zero z values in rpp transformed plan (#3066)
Aposhian Jul 8, 2022
84cd1d8
forward porting #3053 (#3064)
SteveMacenski Jul 11, 2022
1dd5d27
removing get node options default for nav2 utils (#3073)
SteveMacenski Jul 12, 2022
d40dcd6
adding looping timeout for lifecycle service clients + adding string …
SteveMacenski Jul 12, 2022
b15367f
Smac Planner 2D changes (#3083)
SteveMacenski Jul 20, 2022
35df8e6
Collision monitor (#2982)
AlexeyMerzlyakov Jul 20, 2022
252d844
removing the extra argument in class dec (#3084)
padhupradheep Jul 21, 2022
e8047ce
Fix for #3078, fix image path in YAML (#3082)
nakai-omer Jul 21, 2022
ffa0061
do not depend on velocity for approach scaling (#3047)
Aposhian Jul 21, 2022
ee06ded
Use correct timeout when checking future (#3087)
samiamlabs Jul 22, 2022
5cba027
Adds missing commas so default plugin names are not stuck together (#…
aaronchongth Aug 17, 2022
232d665
Fix Costmap Filters system tests (#3120)
SteveMacenski Aug 18, 2022
289a686
Finding distance H if obstacle H is <= 0 (#3122)
SteveMacenski Aug 18, 2022
e1830c9
Removed additional sign multiplication (#3088)
automech-rb Aug 19, 2022
aab082e
adding checks on goal IDs in results for waypoint follower (#3130)
SteveMacenski Aug 19, 2022
c9bab4d
Update nav2_multirobot_params_1.yaml
SteveMacenski Aug 22, 2022
72b5348
Update nav2_multirobot_params_2.yaml
SteveMacenski Aug 22, 2022
42b5bc8
ComputePathToPose Sets empty path on blackboard if action is aborted …
jwallace42 Aug 22, 2022
ca48a4d
Ignore feedback from old goals in waypoint follower (#3139)
pepisg Aug 22, 2022
6fdcfc1
apply joinchar in pathify (#3141)
ladianchad Aug 23, 2022
d4886a7
Log level (#3110)
jwallace42 Aug 23, 2022
676fe71
linting and uncrusitfy fixes for CI (#3144)
jwallace42 Aug 23, 2022
34524ed
start is now added to the path (#3140)
jwallace42 Aug 23, 2022
11285ea
Update README.md (#3147)
austin-InDro Aug 24, 2022
074e3e1
fixing linting problem
SteveMacenski Aug 24, 2022
7a6b11d
Setting map map's yaml path to empty string, since overridden in laun…
SteveMacenski Aug 24, 2022
344ac1c
use_sim_time refactoring (#3131)
Aug 25, 2022
2b34405
standalone assisted teleop (#2904)
jwallace42 Aug 25, 2022
1022f02
Add the support of range sensors to Collision Monitor (#3099)
AlexeyMerzlyakov Aug 26, 2022
7a18064
Fix #3152: Costmap extend did not include Y component (#3153)
SteveMacenski Aug 26, 2022
3360f18
missing nodes added to nav2_tree_nodes.xml (#3155)
enesbedir1 Aug 27, 2022
12b45f5
Change deprecated ceres function (#3158)
Tobias-Fischer Aug 30, 2022
79c73f6
remove camera_rgb_joint since child frame does not exist (#3162)
ipa-kut Aug 31, 2022
c5e4d1b
bugfix (#3109) deadlock when costmap receives new map (#3145)
daisukes Aug 31, 2022
78ed712
simple command costmap api - first few functions (#3159)
stevedanomodolor Aug 31, 2022
908a765
Fix missing dependency on nav2_collision_monitor (#3175)
fantalukas Sep 6, 2022
f424310
fixed start (#3168)
jwallace42 Sep 6, 2022
8ce0ead
Fix velocities comparison for rotation at place case (#3177)
AlexeyMerzlyakov Sep 9, 2022
72da017
set a empty path on halt (#3178)
jwallace42 Sep 9, 2022
7eeb91e
simple command costmap api - update few functions (#3169)
JacksonK9 Sep 12, 2022
9cbaf1a
clear names for bt nodes (#3183)
jwallace42 Sep 12, 2022
48ca6e1
[Smac] check if a node exists before creating (#3195)
SteveMacenski Sep 16, 2022
278f896
fixing benchmarkign for planners (#3202)
SteveMacenski Sep 19, 2022
5ae4b73
[Smac] Robin hood data structure improves performance by 10-15%! (#3201)
SteveMacenski Sep 20, 2022
f896415
[RPP] Add parameter to enable/disable collision detection (#3204)
fantalukas Sep 21, 2022
e853746
Update waffle.model
SteveMacenski Sep 21, 2022
c6bd5c5
Add a min_obstacle_height param to the nav2_costmap_2d's ObstacleLaye…
milidam Sep 22, 2022
f2713f7
add benchmark launch file + instructions (#3218)
SteveMacenski Sep 22, 2022
b45381d
removing hypotf from smac planner heuristic computation (#3217)
SteveMacenski Sep 22, 2022
1b24e28
complete smac planner tolerances (#3219)
SteveMacenski Sep 23, 2022
810f076
Disable Output Buffering (#3220)
ruffsl Sep 23, 2022
83f8b4f
fix majority of python linting errors introduced in python costmap AP…
SteveMacenski Sep 23, 2022
c1f837d
Add new constructor to cosmtap2DROS (#3222)
Sep 26, 2022
8df3c5d
Assisted teleop simple commander (#3198)
jwallace42 Sep 26, 2022
92dd352
added result codes for global planner (#3146)
jwallace42 Sep 28, 2022
53a6af5
Fix RMW deprecation warnings (#3226)
AndyZe Sep 30, 2022
3727175
Costmap Filter enabling service (#3229)
AlexeyMerzlyakov Oct 5, 2022
bd715a5
Fixing Ogre deprecation build warning
SteveMacenski Oct 5, 2022
185b7af
Add binary flip costmap filter (#3228)
AlexeyMerzlyakov Oct 10, 2022
81811e2
Update waffle.model
SteveMacenski Oct 11, 2022
b908b53
Revert "added result codes for global planner (#3146)" (#3237)
SteveMacenski Oct 11, 2022
b1922b6
Update waffle.model
SteveMacenski Oct 11, 2022
a96301c
Update test_actions.cpp
SteveMacenski Oct 11, 2022
5fe3345
odom alpha restriction to avoid overflow caused by user-misconfigurat…
Cryst4L9527 Oct 11, 2022
95fbd23
Expections (#3244)
jwallace42 Oct 12, 2022
4b54dfd
Update controller server goal checker (#3240)
NicolasRochaPacheco Oct 12, 2022
5d85e3f
map-size restriction to avoid overflow and nullptr caused by user-mis…
Cryst4L9527 Oct 14, 2022
aeec74a
Add Path Smoothers Benchmarking suite (#3236)
AlexeyMerzlyakov Oct 14, 2022
e7d4d98
Controller exceptions (#3227)
jwallace42 Oct 14, 2022
9b74dd0
CostmapLayer::matchSize may be executed concurrently (#3250)
Cryst4L9527 Oct 24, 2022
338e93e
Fix typo (#3262)
woawo1213 Nov 1, 2022
a94fdc4
Adding new Nav2 Smoother: Savitzky-Golay Smoother (#3264)
SteveMacenski Nov 3, 2022
c8053e3
refactoring RPP a bit for cleanliness on way to ROSCon (#3265)
SteveMacenski Nov 3, 2022
5161f7d
exceptions for compute path through poses (#3248)
jwallace42 Nov 3, 2022
80bd879
Reclaim Our CI Coverage from the Lords of Painful Subtle Regressions …
SteveMacenski Nov 3, 2022
607019c
Added Line Iterator (#3197)
afifswaidan Nov 7, 2022
d81cc62
Use SetParameter Launch API to set the yaml filename for map_server (…
stevedanomodolor Nov 7, 2022
ad5aa20
adding reconfigure test to thetastar (#3275)
padhupradheep Nov 9, 2022
ae268d8
Check for range_max of laserscan in updateFilter to avoid a implicit …
Cryst4L9527 Nov 10, 2022
61a967c
BT Service Node to throw if service was not available in time (#3256)
guilyx Nov 11, 2022
6d325e3
remove exec_depend on behaviortree_cpp_v3 (#3279)
Aposhian Nov 11, 2022
9b4bdde
add parameterized refinement recursion numbers in Smac Planner Smooth…
SteveMacenski Nov 15, 2022
a13d642
Add allow_unknown parameter to theta star planner (#3286)
pepisg Nov 16, 2022
95c951d
Include test cases waypoint follwer (#3288)
stevedanomodolor Nov 16, 2022
ab5dcd9
Dynamically changing polygons support (#3245)
AlexeyMerzlyakov Nov 17, 2022
1f74b4d
adding getCostScalingFactor (#3290)
SteveMacenski Nov 17, 2022
94fde9e
Implemented smoother selector bt node (#3283)
owen7900 Nov 18, 2022
cb391ed
Pipe error codes (#3251)
jwallace42 Nov 18, 2022
1a5313a
Solve bug when CostmapInfoServer is reactivated (#3292)
MartiBolet Nov 20, 2022
c415c76
Smoothness metrics update (#3294)
AlexeyMerzlyakov Nov 20, 2022
806bc68
preempt/cancel test for time behavior, spin pluguin (#3301)
stevedanomodolor Nov 29, 2022
6202f57
Migrate to createTreeFromFile for loading BTs (#3306)
SteveMacenski Dec 1, 2022
5c27a3e
update comment (#3309)
jwallace42 Dec 5, 2022
7c88750
Added a flag to not send goal in BtActionNode (#3293)
owen7900 Dec 5, 2022
6143295
Ensure that plugin initialization to be called before updating routin…
AlexeyMerzlyakov Dec 6, 2022
c119017
Make mapUpdateLoop() indicator variables to be thread-safe (#3308)
AlexeyMerzlyakov Dec 6, 2022
fe776fb
Fix Wrong Map Pointer (#3311) (#3315)
borongyuan Dec 6, 2022
bd3afbc
Add ability to publish layers of the costmap (#3254)
jwallace42 Dec 8, 2022
03876ea
Revert "Add ability to publish layers of the costmap (#3254)" (#3319)
SteveMacenski Dec 8, 2022
5e16d10
Publish layers (#3320)
jwallace42 Dec 9, 2022
fe9519d
Smoother error codes (#3296)
jwallace42 Dec 9, 2022
7f41234
fix (#3321)
jwallace42 Dec 10, 2022
6b02da4
rebase
Dec 14, 2022
e32431c
Revert "rolling issue"
jwallace42 Aug 5, 2022
d50a2d1
added Path with cost message
Dec 14, 2022
6664b93
switch to PathWithCost
Dec 14, 2022
dad593f
Merge branch 'main' into staticial_replanning
Dec 14, 2022
444b506
fix
Dec 14, 2022
5f08d1f
able to open in rviz
Dec 15, 2022
f3b3dc6
path with cost display working with new message type
Dec 16, 2022
0903d22
updates
Dec 19, 2022
acb0458
code review
Dec 20, 2022
27adc55
initial tests for path validator
Dec 21, 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
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,8 @@ class IsPathValidCondition : public BT::ConditionNode
{
return {
BT::InputPort<nav_msgs::msg::Path>("path", "Path to Check"),
BT::InputPort<std::chrono::milliseconds>("server_timeout")
BT::InputPort<std::chrono::milliseconds>("server_timeout"),
BT::InputPort<bool>("consider_cost_change", true, "Consider cost changes")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add to groot XML for people using it to build trees to have the option exposed

};
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,13 @@ BT::NodeStatus IsPathValidCondition::tick()
{
nav_msgs::msg::Path path;
getInput("path", path);
bool consider_cost_change;
getInput("consider_cost_change", consider_cost_change);

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

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

if (rclcpp::spin_until_future_complete(node_, result, server_timeout_) ==
Expand Down
1 change: 1 addition & 0 deletions nav2_bringup/params/nav2_params.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -275,6 +275,7 @@ planner_server:
tolerance: 0.5
use_astar: false
allow_unknown: true
z_score: 2.55

smoother_server:
ros__parameters:
Expand Down
1 change: 1 addition & 0 deletions nav2_msgs/srv/IsPathValid.srv
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#Determine if the current path is still valid

nav_msgs/Path path
bool consider_cost_change
---
bool is_valid
int32[] invalid_pose_indices
1 change: 1 addition & 0 deletions nav2_planner/include/nav2_planner/planner_server.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,7 @@ class PlannerServer : public nav2_util::LifecycleNode
std::vector<std::string> planner_ids_;
std::vector<std::string> planner_types_;
double max_planner_duration_;
double z_score_;
std::string planner_ids_concat_;

// Clock
Expand Down
87 changes: 69 additions & 18 deletions nav2_planner/src/planner_server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
#include <string>
#include <vector>
#include <utility>
#include <numeric>

#include "builtin_interfaces/msg/duration.hpp"
#include "nav2_util/costmap.hpp"
Expand Down Expand Up @@ -52,6 +53,12 @@ PlannerServer::PlannerServer(const rclcpp::NodeOptions & options)
declare_parameter("planner_plugins", default_ids_);
declare_parameter("expected_planner_frequency", 1.0);

nav2_util::declare_parameter_if_not_declared(
this, "z_score", rclcpp::ParameterValue(2.55));


get_parameter("z_score", z_score_);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the parameter / variable name, it would be nice to have some more context to what this is used for. While it is a Z-score, that's not really telling a user why its there / where its used. cost_change_z_score or path_difference_z_score or something would help give some context where/how its used.

Considering the use of consider_cost_change in the action field, I think cost_change_z_score or path_cost_change_score or something would make sense

Copy link
Member

@SteveMacenski SteveMacenski Aug 25, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also parameter guide stuff :-)

Though, I think this should be broken out into another object. It doesn't seem very natural to have this implementation in the planner_server itself - maybe a pluginable interface at some point in the future? But at least for now, needs to be in a statistical_replanning file utility or object.


get_parameter("planner_plugins", planner_ids_);
if (planner_ids_ == default_ids_) {
for (size_t i = 0; i < default_ids_.size(); ++i) {
Expand Down Expand Up @@ -541,13 +548,15 @@ void PlannerServer::isPathValid(
return;
}

// Find the closest point to the robot to evaluate from
// TODO add orientation element like `truncate_path_local_action` BT node for looping paths
geometry_msgs::msg::PoseStamped current_pose;
unsigned int closest_point_index = 0;
if (costmap_ros_->getRobotPose(current_pose)) {
float current_distance = std::numeric_limits<float>::max();
float closest_distance = current_distance;
geometry_msgs::msg::Point current_point = current_pose.pose.position;
for (unsigned int i = 0; i < request->path.poses.size(); ++i) {
for (unsigned int i = 0; i != request->path.poses.size(); ++i) {
geometry_msgs::msg::Point path_point = request->path.poses[i].pose.position;

current_distance = nav2_util::geometry_utils::euclidean_distance(
Expand All @@ -559,26 +568,68 @@ void PlannerServer::isPathValid(
closest_distance = current_distance;
}
}
}

/**
* The lethal check starts at the closest point to avoid points that have already been passed
* and may have become occupied
*/
unsigned int mx = 0;
unsigned int my = 0;
for (unsigned int i = closest_point_index; i < request->path.poses.size(); ++i) {
costmap_->worldToMap(
request->path.poses[i].pose.position.x,
request->path.poses[i].pose.position.y, mx, my);
unsigned int cost = costmap_->getCost(mx, my);

if (cost == nav2_costmap_2d::LETHAL_OBSTACLE ||
cost == nav2_costmap_2d::INSCRIBED_INFLATED_OBSTACLE)
{
response->is_valid = false;
}
// Checking path for collisions starting at the closest point to avoid those already passed
std::vector<unsigned int> current_costs;
current_costs.reserve(request->path.costs.size() - closest_point_index - 1);

unsigned int mx = 0;
unsigned int my = 0;
for (unsigned int i = closest_point_index; i != request->path.poses.size(); ++i) {
costmap_->worldToMap(
request->path.poses[i].pose.position.x,
request->path.poses[i].pose.position.y, mx, my);
unsigned int cost = costmap_->getCost(mx, my);
current_costs.push_back(cost);

if (cost == nav2_costmap_2d::LETHAL_OBSTACLE ||
cost == nav2_costmap_2d::INSCRIBED_INFLATED_OBSTACLE)
{
response->is_valid = false;
return;
}
}

// Check using a statistical test if the cost changes are 'significant' enough
// to warrant replanning, due to changes in cost within the environment,
// when larger than the minimum sample size for the test
if (!request->consider_cost_change || request->path.costs.size() < 30) {
return;
}

std::vector<unsigned int> original_costs(
request->path.costs.begin() + closest_point_index, request->path.costs.end());

float mean_orginal = 0;
float mean_current = 0;
for (unsigned int i = 0; i != original_costs.size(); ++i) {
mean_orginal += static_cast<float>(original_costs[i]);
mean_current += static_cast<float>(current_costs[i]);
}
mean_orginal /= static_cast<float>(original_costs.size());
mean_current /= static_cast<float>(current_costs.size());

float var_orginal = 0;
float var_current = 0;
for (unsigned int i = 0; i != original_costs.size(); ++i) {
var_orginal += std::pow(static_cast<float>(original_costs[i]) - static_cast<float>(mean_orginal), 2);
var_current += std::pow(static_cast<float>(current_costs[i]) - static_cast<float>(mean_current), 2);
}
var_orginal /= static_cast<float>(original_costs.size() - 1);
var_current /= static_cast<float>(current_costs.size() - 1);

// Conduct a two sample Z-test, with the null hypothesis is that both path cost samples
// come from the same distribution (e.g. there is not a statistically significant change)
// Thus, the difference in population mean is 0 and the sample sizes are the same
float z = (mean_current - mean_orginal) / std::sqrt((var_current + var_orginal) / current_costs.size());

// TODO try single tail or tune strictness? Parameterize?
// 1.65 95% single tail; 2.55 for 99% dual, 2.33 99% single; 90% 1.65 dual, 90% 1.2 single.
if (z > z_score_) { // critical z score for 95% level
RCLCPP_DEBUG_STREAM(get_logger(), "Z-test triggered new global plan. The z score was: " << z << "and the threshold was" << z_score_);
response->is_valid = false;
}
}

rcl_interfaces::msg::SetParametersResult
Expand Down