Skip to content

Commit

Permalink
Patch for PhotoAtWaypoint plugin (ros-navigation#2067)
Browse files Browse the repository at this point in the history
* nav2_way_point_follower; introduce photo at waypoint arrivals plugin

Signed-off-by: jediofgever <fetulahatas1@gmail.com>

* resolve cmake lint errors

Signed-off-by: jediofgever <fetulahatas1@gmail.com>

* resolve requested chages of first review

Signed-off-by: jediofgever <fetulahatas1@gmail.com>

* minor corrections on photo_at_waypoint header

* resolve requested changes of second review

Signed-off-by: jediofgever <fetulahatas1@gmail.com>

* update default save_dir

Signed-off-by: jediofgever <fetulahatas1@gmail.com>

* move directory checking code to initialize()

* add try catch block to catch possible execeptions while creating a directory for photo at waypoint plugin

Signed-off-by: jediofgever <fetulahatas1@gmail.com>

* adding logging and disabling

* Update nav2_waypoint_follower/plugins/photo_at_waypoint.cpp

Co-authored-by: Fetullah Atas  <fetulahatas1@gmail.com>

* Update photo_at_waypoint.cpp

Co-authored-by: jediofgever <fetulahatas1@gmail.com>
  • Loading branch information
2 people authored and vinnnyr committed Nov 9, 2020
1 parent f5ea383 commit 18d6137
Showing 1 changed file with 19 additions and 12 deletions.
31 changes: 19 additions & 12 deletions nav2_waypoint_follower/plugins/photo_at_waypoint.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,22 +54,29 @@ void PhotoAtWaypoint::initialize(

// get inputted save directory and make sure it exists, if not log and create it
save_dir_ = save_dir_as_string;
if (!std::experimental::filesystem::exists(save_dir_)) {
RCLCPP_WARN(
logger_,
"Provided save directory for photo at waypoint plugin does not exist,"
"provided directory is: %s, the directory will be created automatically.",
save_dir_.c_str()
);
if (!std::experimental::filesystem::create_directory(save_dir_)) {
RCLCPP_ERROR(
try {
if (!std::experimental::filesystem::exists(save_dir_)) {
RCLCPP_WARN(
logger_,
"Failed to create directory!: %s required by photo at waypoint plugin, "
"exiting the plugin with failure!",
"Provided save directory for photo at waypoint plugin does not exist,"
"provided directory is: %s, the directory will be created automatically.",
save_dir_.c_str()
);
is_enabled_ = false;
if (!std::experimental::filesystem::create_directory(save_dir_)) {
RCLCPP_ERROR(
logger_,
"Failed to create directory!: %s required by photo at waypoint plugin, "
"exiting the plugin with failure!",
save_dir_.c_str()
);
is_enabled_ = false;
}
}
} catch (const std::exception & e) {
RCLCPP_ERROR(
logger_, "Exception (%s) thrown while attempting to create image capture directory."
" This task executor is being disabled as it cannot save images.", e.what());
is_enabled_ = false;
}

if (!is_enabled_) {
Expand Down

0 comments on commit 18d6137

Please sign in to comment.