-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
- Loading branch information
1 parent
0ddd055
commit d912da4
Showing
13 changed files
with
91 additions
and
58 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
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
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
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
40 changes: 40 additions & 0 deletions
40
crane_sender/include/crane_sender/parameter_with_event.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,40 @@ | ||
// Copyright (c) 2024 ibis-ssl | ||
// | ||
// Use of this source code is governed by an MIT-style | ||
// license that can be found in the LICENSE file or at | ||
// https://opensource.org/licenses/MIT. | ||
|
||
#ifndef CRANE_SENDER__PARAMETER_WITH_EVENT_HPP_ | ||
#define CRANE_SENDER__PARAMETER_WITH_EVENT_HPP_ | ||
namespace crane | ||
{ | ||
struct ParameterWithEvent | ||
{ | ||
ParameterWithEvent(std::string name, rclcpp::Node & node) : name(name) | ||
{ | ||
parameter_subscriber = std::make_shared<rclcpp::ParameterEventHandler>(&node); | ||
parameter_callback_handle = | ||
parameter_subscriber->add_parameter_callback(name, [&](const rclcpp::Parameter & p) { | ||
if (p.get_type() == rclcpp::ParameterType::PARAMETER_DOUBLE && callback) { | ||
value = p.as_double(); | ||
callback(value); | ||
} else { | ||
std::cout << "debug_id is not integer" << std::endl; | ||
} | ||
}); | ||
} | ||
|
||
std::shared_ptr<rclcpp::ParameterEventHandler> parameter_subscriber; | ||
|
||
std::shared_ptr<rclcpp::ParameterCallbackHandle> parameter_callback_handle; | ||
|
||
std::function<void(double)> callback; | ||
|
||
double getValue() { return value; } | ||
|
||
double value; | ||
|
||
std::string name; | ||
}; | ||
} // namespace crane | ||
#endif // CRANE_SENDER__PARAMETER_WITH_EVENT_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
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