forked from ros-controls/ros2_controllers
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* introducing handles Signed-off-by: Karsten Knese <Karsten1987@users.noreply.github.com> * component interfaces & tests Signed-off-by: Karsten Knese <Karsten1987@users.noreply.github.com> * linters Signed-off-by: Karsten Knese <Karsten1987@users.noreply.github.com> * import resource manager Signed-off-by: Karsten Knese <Karsten1987@users.noreply.github.com> * correct year Signed-off-by: Karsten Knese <Karsten1987@users.noreply.github.com> * import handles from loaded components Signed-off-by: Karsten Knese <Karsten1987@users.noreply.github.com> * wip / debug Signed-off-by: Karsten Knese <Karsten1987@users.noreply.github.com> * parse components Signed-off-by: Karsten Knese <Karsten1987@users.noreply.github.com> * changes after rebase Signed-off-by: Karsten Knese <Karsten1987@users.noreply.github.com> * component parser as shared library Signed-off-by: Karsten Knese <Karsten1987@users.noreply.github.com> * validate urdf configuratin Signed-off-by: Karsten Knese <Karsten1987@users.noreply.github.com> * documentation Signed-off-by: Karsten Knese <Karsten1987@users.noreply.github.com> * remove default constructor Signed-off-by: Karsten Knese <Karsten1987@users.noreply.github.com> * resource loaning Signed-off-by: Karsten Knese <Karsten1987@users.noreply.github.com> * loan state interface Signed-off-by: Karsten Knese <Karsten1987@users.noreply.github.com> * import externally declared components Signed-off-by: Karsten Knese <Karsten1987@users.noreply.github.com> * move resource manager to hardware interface (ros-controls#226) * move resource manager to hardware interface Signed-off-by: Karsten Knese <Karsten1987@users.noreply.github.com> * include functional for std::function Co-authored-by: Bence Magyar <bence.magyar.robotics@gmail.com> * address review comments Signed-off-by: Karsten Knese <Karsten1987@users.noreply.github.com> Co-authored-by: Bence Magyar <bence.magyar.robotics@gmail.com>
- Loading branch information
1 parent
04e6531
commit 993db54
Showing
14 changed files
with
608 additions
and
186 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 was deleted.
Oops, something went wrong.
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
69 changes: 69 additions & 0 deletions
69
hardware_interface/include/hardware_interface/loaned_command_interface.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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
// Copyright 2020 Open Source Robotics Foundation, Inc. | ||
// | ||
// 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 HARDWARE_INTERFACE__LOANED_COMMAND_INTERFACE_HPP_ | ||
#define HARDWARE_INTERFACE__LOANED_COMMAND_INTERFACE_HPP_ | ||
|
||
#include <functional> | ||
#include <utility> | ||
|
||
#include "hardware_interface/handle.hpp" | ||
|
||
namespace hardware_interface | ||
{ | ||
|
||
class LoanedCommandInterface | ||
{ | ||
public: | ||
using Deleter = std::function<void (void)>; | ||
|
||
explicit LoanedCommandInterface(CommandInterface & command_interface) | ||
: LoanedCommandInterface(command_interface, nullptr) | ||
{} | ||
|
||
LoanedCommandInterface( | ||
CommandInterface & command_interface, | ||
Deleter && deleter) | ||
: command_interface_(command_interface), | ||
deleter_(std::forward<Deleter>(deleter)) | ||
{} | ||
|
||
LoanedCommandInterface(const LoanedCommandInterface & other) = delete; | ||
|
||
LoanedCommandInterface(LoanedCommandInterface && other) = default; | ||
|
||
virtual ~LoanedCommandInterface() | ||
{ | ||
if (deleter_) { | ||
deleter_(); | ||
} | ||
} | ||
|
||
void set_value(double val) | ||
{ | ||
command_interface_.set_value(val); | ||
} | ||
|
||
double get_value() const | ||
{ | ||
return command_interface_.get_value(); | ||
} | ||
|
||
protected: | ||
CommandInterface & command_interface_; | ||
Deleter deleter_; | ||
}; | ||
|
||
} // namespace hardware_interface | ||
#endif // HARDWARE_INTERFACE__LOANED_COMMAND_INTERFACE_HPP_ |
Oops, something went wrong.