Last active
May 3, 2023 08:23
-
-
Save agrueneberg/d76fff493753fa531f1b5d33be0f07ed to your computer and use it in GitHub Desktop.
Complex ROS2 parameters via undeclared, namespaced parameters
This file contains hidden or 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
import rclpy | |
import rclpy.node | |
def main(): | |
rclpy.init() | |
node = rclpy.node.Node('mappings', allow_undeclared_parameters=True) | |
def mappings(): | |
mappingsParam = node.get_parameters_by_prefix('mappings') | |
mappings = {} | |
for key, value in mappingsParam.items(): | |
namespace, name = key.split('.', maxsplit=1) | |
if namespace not in mappings: | |
mappings[namespace] = {} | |
mappings[namespace][name] = value.get_parameter_value().string_value | |
node.get_logger().info(f'mappings: {str(mappings)}') | |
node.create_timer(1, mappings) | |
rclpy.spin(node) | |
if __name__ == '__main__': | |
main() |
This file contains hidden or 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
/mappings: | |
ros__parameters: | |
mappings: | |
m1: | |
from: "t1" | |
to: "t1" | |
m2: | |
from: "t2" | |
to: "t2" | |
use_sim_time: false |
This file contains hidden or 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
ros2 param load /mappings mappings2.yaml |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment