11#!/usr/bin/env python3
22import numpy as np
33import rclpy
4- from geometry_msgs .msg import (
5- PoseWithCovarianceStamped ,
6- TwistWithCovarianceStamped ,
7- Wrench ,
8- )
4+ from geometry_msgs .msg import (PoseWithCovarianceStamped ,
5+ TwistWithCovarianceStamped , Wrench )
96from rclpy .executors import MultiThreadedExecutor
107from rclpy .lifecycle import LifecycleNode
118from rclpy .lifecycle .node import LifecycleState , TransitionCallbackReturn
129from rclpy .qos import HistoryPolicy , QoSProfile , ReliabilityPolicy
1310from std_msgs .msg import Bool , String
1411from velocity_controller_lqr .velocity_controller_lqr_lib import (
15- GuidanceValues ,
16- LQRController ,
17- LQRParameters ,
18- State ,
19- )
12+ GuidanceValues , LQRController , LQRParameters , State )
2013from vortex_msgs .msg import LOSGuidance
2114
2215
@@ -33,7 +26,7 @@ def __init__(self):
3326 self .reliable_qos = QoSProfile (
3427 reliability = ReliabilityPolicy .RELIABLE ,
3528 history = HistoryPolicy .KEEP_LAST ,
36- depth = 10 ,
29+ depth = 2 ,
3730 )
3831
3932 # ---------------- CALLBACK VARIABLES INITIALIZATION ----------------
@@ -62,6 +55,7 @@ def __init__(self):
6255 self .controller = LQRController (self .lqr_params , self .inertia_matrix )
6356
6457 def on_configure (self , previous_state : LifecycleState ) -> TransitionCallbackReturn :
58+ self .declare_parameters ()
6559 self .get_parameters ()
6660 # -------------------------- GET ALL TOPICS -------------------------
6761 (
@@ -176,8 +170,8 @@ def get_topics(self) -> None:
176170 killswitch_topic ,
177171 )
178172
179- def get_parameters (self ) -> None :
180- """Updates the LQR_params in the LQR_parameters Dataclass ."""
173+ def declare_parameters (self ) -> None :
174+ """Declares parameters that are to be used from the configuration file ."""
181175 self .declare_parameter ("LQR_params.q_surge" )
182176 self .declare_parameter ("LQR_params.q_pitch" )
183177 self .declare_parameter ("LQR_params.q_yaw" )
@@ -194,6 +188,9 @@ def get_parameters(self) -> None:
194188
195189 self .declare_parameter ("LQR_params.dt" )
196190 self .declare_parameter ("max_force" )
191+
192+ def get_parameters (self ) -> None :
193+ """Gets the declared parameters from the configuration file."""
197194
198195 self .lqr_params .q_surge = self .get_parameter ("LQR_params.q_surge" ).value
199196 self .lqr_params .q_pitch = self .get_parameter ("LQR_params.q_pitch" ).value
0 commit comments