Skip to content

Commit

Permalink
created parameter_manager_node
Browse files Browse the repository at this point in the history
  • Loading branch information
LeRatDuFA committed Oct 22, 2023
1 parent 432f7a5 commit ccb8192
Show file tree
Hide file tree
Showing 4 changed files with 66 additions and 0 deletions.
9 changes: 9 additions & 0 deletions asv_setup/config/freya.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
/parameter_manager_node:
ros__parameters:
configuration_matrix: "[[ 0.70711, 0.70711, 0.70711, 0.70711], [ -0.70711, 0.70711, -0.70711, 0.70711], [ 0.27738, 0.27738, -0.27738, -0.27738]]" #NED #Surge #Sway #Yaw
asv_thruster_manager_input: "thrust/desired_forces" # 3DOF thrust vector
asv_thruster_manager_output: "thrust/thruster_forces"
asv_thruster_manager_wrench: "thrust/wrench_input"
joy_node: "joystick/joy"


10 changes: 10 additions & 0 deletions asv_setup/launch/launch_to_erase.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
launch:
- node:
pkg: test_pkg
exec: test_node
name: parameter_manager_node
output: screen
param:
- from: /home/jade/ros2_ws/src/test_pkg/test_pkg/config/params.yaml


47 changes: 47 additions & 0 deletions asv_setup/scripts/parameter_manager_node.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
import rclpy
from rclpy.node import Node
import ast


class ParameterManagerNode(Node):

def __init__(self):
super().__init__('parameter_manager_node')

self.get_logger().info("Parameter manager node is up and running")


#Declaration of parameters
self.declare_parameter('configuration_matrix',"")
self.declare_parameter('asv_thruster_manager_output',"")
self.declare_parameter('asv_thruster_manager_input',"")
self.declare_parameter('asv_thruster_manager_wrench',"")

self.configuration_matrix = self.get_parameter('configuration_matrix').value #Is a string because 2D Array is not supported as a ros2 param
self.asv_thruster_manager_output = self.get_parameter('asv_thruster_manager_output').value
self.asv_thruster_manager_input = self.get_parameter('asv_thruster_manager_input').value
self.asv_thruster_manager_wrench = self.get_parameter('asv_thruster_manager_wrench').value

self.configuration_matrix = StringInto2DArray(self.configuration_matrix)


def StringInto2DArray(input_string):
two_d_array = ast.literal_eval(input_string)
if isinstance(two_d_array, list) and all(isinstance(row, list) for row in two_d_array):
return two_d_array
else:
print("The input string is not a valid 2D array.")


def main():
rclpy.init()
parameter_manager_node = ParameterManagerNode()
test = parameter_manager_node.asv_thruster_manager_output
#rclpy.spin(joystick_interface)
#parameter_manager_node.destroy_node()
rclpy.shutdown()



if __name__ == "__main__":
main()
Empty file added git
Empty file.

0 comments on commit ccb8192

Please sign in to comment.