-
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.
ros2/ros2cli#960 Signed-off-by: Tomoya Fujita <[email protected]>
- Loading branch information
1 parent
3fd8495
commit b1ab77c
Showing
2 changed files
with
32 additions
and
0 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,31 @@ | ||
import rclpy | ||
from rclpy.node import Node | ||
from rclpy.parameter import Parameter | ||
from rcl_interfaces.msg import SetParametersResult | ||
|
||
|
||
class MinimalParameterNode(Node): | ||
def __init__(self): | ||
super().__init__('minimal_param_node') | ||
self.log = self.get_logger() | ||
self.declare_parameter('my_parameter', Parameter.Type.STRING) | ||
self.declare_parameter('foobar.my_parameter', Parameter.Type.STRING) | ||
|
||
self.add_on_set_parameters_callback(self.callback) | ||
|
||
def callback(self, parameters): | ||
for p in parameters: | ||
if p.name == 'my_parameter': | ||
self.log.info(f"Got my_parameter: {p.value}") | ||
if p.name == 'foobar.my_parameter': | ||
self.log.info(f"Got foobar.my_parameter: {p.value}") | ||
return SetParametersResult(successful=True) | ||
|
||
|
||
def main(): | ||
rclpy.init() | ||
node = MinimalParameterNode() | ||
rclpy.spin(node) | ||
|
||
if __name__ == '__main__': | ||
main() |