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

Add velocity based polygon #3708

Merged
merged 36 commits into from
Feb 5, 2024
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
a2622f7
add velocity based polygon
kaichie Jul 23, 2023
ac4045f
fix header, copyright and variable name change
kaichie Jul 24, 2023
763b432
optimise polygon update
kaichie Jul 24, 2023
489392a
optimise duplicated code with setPolygonShape
kaichie Jul 24, 2023
727060c
add warning log for uncovered speed
kaichie Jul 24, 2023
3d9e979
Merge remote-tracking branch 'upstream/main' into add_polygon_velocity
kaichie Sep 2, 2023
50fd22c
update feedback
kaichie Sep 3, 2023
b6a05e2
rename polygon velocity to velocity polygon
kaichie Sep 3, 2023
b0a1093
cleanup
kaichie Sep 3, 2023
f1de5f9
fix typo
kaichie Sep 3, 2023
43c28d0
add dynamic support for velocity polygon
kaichie Sep 24, 2023
c2098b6
Merge remote-tracking branch 'upstream/main' into add_polygon_velocity
kaichie Sep 24, 2023
f6b2b19
wrap try catch for getting parameters
kaichie Sep 24, 2023
7f9f55a
update naming and linting
kaichie Sep 24, 2023
1230ede
use switch case
kaichie Sep 25, 2023
cd1af8a
Revert "use switch case"
kaichie Sep 26, 2023
2c4181e
fix proper return for invalid parameters
kaichie Sep 26, 2023
400d45e
remove topic parameter for velocity polygon
kaichie Sep 26, 2023
b97cbb7
fix formatting manually
kaichie Sep 26, 2023
5dc403b
continue if points are not defined
kaichie Sep 26, 2023
3db0146
Merge branch 'main' into add_polygon_velocity
kaichie Nov 16, 2023
8491ed4
Merge branch 'main' into add_polygon_velocity
kaichie Dec 5, 2023
a5c48a7
Merge branch 'main' into add_polygon_velocity
kaichie Jan 2, 2024
abab066
rewrite velocity polygon with polygon base class
kaichie Jan 7, 2024
620c7c2
update review comments and description
kaichie Jan 7, 2024
898d8c0
add VelocityPolygon to detector node
kaichie Jan 7, 2024
940225c
review update
kaichie Jan 16, 2024
0a7fe8c
fix cpplint
kaichie Jan 16, 2024
680f7ca
Merge remote-tracking branch 'upstream/main' into add_polygon_velocity
kaichie Jan 16, 2024
5c5d184
Update nav2_collision_monitor/src/velocity_polygon.cpp
kaichie Jan 17, 2024
49d7b71
add velocity polygon tests
kaichie Jan 17, 2024
ee69105
fix cpplint
kaichie Jan 17, 2024
10d59e1
add in-line comment
kaichie Jan 17, 2024
bbcb930
fix push back
kaichie Jan 17, 2024
df2cb95
minor change and update README
kaichie Jan 20, 2024
e150e85
update README
kaichie Jan 27, 2024
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 @@ -15,6 +15,7 @@
#ifndef NAV2_COLLISION_MONITOR__VELOCITY_POLYGON_HPP_
#define NAV2_COLLISION_MONITOR__VELOCITY_POLYGON_HPP_

#include <memory>
#include <string>
#include <vector>

Expand Down Expand Up @@ -99,6 +100,9 @@ class VelocityPolygon : public Polygon
*/
bool isInRange(const Velocity & cmd_vel_in, const SubPolygonParameter & sub_polygon_param);

// Clock
rclcpp::Clock::SharedPtr clock_;

// Variables
/// @brief Flag to indicate if the robot is holonomic
bool holonomic_;
Expand Down
14 changes: 7 additions & 7 deletions nav2_collision_monitor/params/collision_monitor_params.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ collision_monitor:
stop_pub_timeout: 2.0
# Polygons represent zone around the robot for "stop", "slowdown" and "limit" action types,
# and robot footprint for "approach" action type.
# Footprint could be "polygon" type with dynamically set footprint from footprint_topic
# or "circle" type with static footprint set by radius. "footprint_topic" parameter
# (1) Footprint could be "polygon" type with dynamically set footprint from footprint_topic
# (2) "circle" type with static footprint set by radius. "footprint_topic" parameter
# to be ignored in circular case.
# or "velocity_polygon" type with dynamically set polygon from velocity_polygons
# (3) "velocity_polygon" type with dynamically set polygon from velocity_polygons
polygons: ["PolygonStop"]
PolygonStop:
type: "polygon"
Expand Down Expand Up @@ -52,16 +52,16 @@ collision_monitor:
min_points: 6
visualize: False
enabled: True
VelocityPolygonApproach:
VelocityPolygonStop:
type: "velocity_polygon"
action_type: "approach"
action_type: "stop"
time_before_collision: 2.0
simulation_time_step: 0.1
min_points: 6
visualize: True
enabled: True
polygon_pub_topic: "polygon_approach"
velocity_polygons: ["rotation", "translation_forward", "translation_backward", "stop"]
velocity_polygons: ["rotation", "translation_forward", "translation_backward", "stopped"]
holonomic: false
rotation:
points: "[[0.3, 0.3], [0.3, -0.3], [-0.3, -0.3], [-0.3, 0.3]]"
Expand All @@ -81,7 +81,7 @@ collision_monitor:
linear_max: 0.0
theta_min: -1.0
theta_max: 1.0
stop:
stopped:
points: "[[0.25, 0.25], [0.25, -0.25], [-0.25, -0.25], [-0.25, 0.25]]"
linear_min: -1.0
SteveMacenski marked this conversation as resolved.
Show resolved Hide resolved
linear_max: 1.0
Expand Down
22 changes: 9 additions & 13 deletions nav2_collision_monitor/src/velocity_polygon.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ bool VelocityPolygon::getParameters(
if (!node) {
throw std::runtime_error{"Failed to lock node"};
}
clock_ = node->get_clock();

if (!getCommonParameters(polygon_pub_topic)) {
return false;
Expand Down Expand Up @@ -74,31 +75,31 @@ bool VelocityPolygon::getParameters(
double linear_min;
SteveMacenski marked this conversation as resolved.
Show resolved Hide resolved
nav2_util::declare_parameter_if_not_declared(
node, polygon_name_ + "." + velocity_polygon_name + ".linear_min",
rclcpp::ParameterValue(0.0));
rclcpp::PARAMETER_DOUBLE);
linear_min = node->get_parameter(polygon_name_ + "." + velocity_polygon_name + ".linear_min")
.as_double();

// linear_max param
double linear_max;
nav2_util::declare_parameter_if_not_declared(
node, polygon_name_ + "." + velocity_polygon_name + ".linear_max",
rclcpp::ParameterValue(0.0));
rclcpp::PARAMETER_DOUBLE);
linear_max = node->get_parameter(polygon_name_ + "." + velocity_polygon_name + ".linear_max")
.as_double();

// theta_min param
double theta_min;
nav2_util::declare_parameter_if_not_declared(
node, polygon_name_ + "." + velocity_polygon_name + ".theta_min",
rclcpp::ParameterValue(0.0));
rclcpp::PARAMETER_DOUBLE);
theta_min =
node->get_parameter(polygon_name_ + "." + velocity_polygon_name + ".theta_min").as_double();

// theta_max param
double theta_max;
nav2_util::declare_parameter_if_not_declared(
node, polygon_name_ + "." + velocity_polygon_name + ".theta_max",
rclcpp::ParameterValue(0.0));
rclcpp::PARAMETER_DOUBLE);
theta_max =
node->get_parameter(polygon_name_ + "." + velocity_polygon_name + ".theta_max").as_double();

Expand All @@ -122,10 +123,9 @@ bool VelocityPolygon::getParameters(
.as_double();
}

SubPolygonParameter sub_polygon = {
poly, velocity_polygon_name, linear_min, linear_max, theta_min,
theta_max, direction_end_angle, direction_start_angle};
sub_polygons_.emplace_back(sub_polygon);
sub_polygons_.emplace_back(
SubPolygonParameter{poly, velocity_polygon_name, linear_min, linear_max, theta_min,
theta_max, direction_end_angle, direction_start_angle});
}
} catch (const std::exception & ex) {
RCLCPP_ERROR(
Expand Down Expand Up @@ -157,12 +157,8 @@ void VelocityPolygon::updatePolygon(const Velocity & cmd_vel_in)
}

// Log for uncovered velocity
auto node = node_.lock();
if (!node) {
throw std::runtime_error{"Failed to lock node"};
}
RCLCPP_WARN_THROTTLE(
logger_, *node->get_clock(), 2.0,
logger_, *(clock_), 2.0,
kaichie marked this conversation as resolved.
Show resolved Hide resolved
"Velocity is not covered by any of the velocity polygons. x: %.3f y: %.3f tw: %.3f ",
cmd_vel_in.x, cmd_vel_in.y, cmd_vel_in.tw);
return;
Expand Down
Loading