forked from ros-navigation/navigation2
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
4d80d5d
commit e17b29e
Showing
5 changed files
with
119 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
// Copyright (c) 2019 Samsung Research America | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
#include <cmath> | ||
#include <chrono> | ||
#include <memory> | ||
|
||
#include "wait.hpp" | ||
|
||
namespace nav2_recoveries | ||
{ | ||
|
||
Wait::Wait() | ||
: Recovery<WaitAction>() | ||
{ | ||
duration_ = 0.0; | ||
} | ||
|
||
Wait::~Wait() | ||
{ | ||
} | ||
|
||
Status Wait::onRun(const std::shared_ptr<const WaitAction::Goal> command) | ||
{ | ||
duration_ = command->time; | ||
return Status::SUCCEEDED; | ||
} | ||
|
||
Status Wait::onCycleUpdate() | ||
{ | ||
RCLCPP_INFO(node_->get_logger(), "Waiting %i seconds.", duration_); | ||
auto sleep_dur = std::chrono::seconds(duration_); | ||
rclcpp::sleep_for(sleep_dur); | ||
return Status::SUCCEEDED; | ||
} | ||
|
||
} // namespace nav2_recoveries | ||
|
||
#include "pluginlib/class_list_macros.hpp" | ||
PLUGINLIB_EXPORT_CLASS(nav2_recoveries::Wait, nav2_core::Recovery) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
// Copyright (c) 2019 Samsung Research America | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
#ifndef NAV2_RECOVERIES__PLUGINS__WAIT_HPP_ | ||
#define NAV2_RECOVERIES__PLUGINS__WAIT_HPP_ | ||
|
||
#include <chrono> | ||
#include <string> | ||
#include <memory> | ||
|
||
#include "nav2_recoveries/recovery.hpp" | ||
#include "nav2_msgs/action/wait.hpp" | ||
|
||
namespace nav2_recoveries | ||
{ | ||
using WaitAction = nav2_msgs::action::Wait; | ||
|
||
class Wait : public Recovery<WaitAction> | ||
{ | ||
public: | ||
Wait(); | ||
~Wait(); | ||
|
||
Status onRun(const std::shared_ptr<const WaitAction::Goal> command) override; | ||
|
||
Status onCycleUpdate() override; | ||
|
||
protected: | ||
int duration_; | ||
}; | ||
|
||
} // namespace nav2_recoveries | ||
|
||
#endif // NAV2_RECOVERIES__PLUGINS__WAIT_HPP_ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters