Skip to content

Commit

Permalink
Made LQR and PID ready for testing
Browse files Browse the repository at this point in the history
  • Loading branch information
Andeshog committed Apr 29, 2024
1 parent cff5d3c commit 4a1110f
Show file tree
Hide file tree
Showing 7 changed files with 13 additions and 13 deletions.
10 changes: 5 additions & 5 deletions guidance/dp_guidance/dp_guidance/dp_guidance_node.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
from nav_msgs.msg import Odometry
from transforms3d.euler import quat2euler

from dp_guidance.conversions import odometrymsg_to_state, state_to_odometrymsg
from dp_guidance.reference_filter import ReferenceFilter
from conversions import odometrymsg_to_state, state_to_odometrymsg
from reference_filter import ReferenceFilter

class Guidance(Node):
def __init__(self):
Expand Down Expand Up @@ -64,9 +64,9 @@ def guidance_callback(self):
self.eta_ref = np.array([last_waypoint.x, last_waypoint.y, 0])
x_next = self.reference_filter.step(self.eta_ref, self.xd)
self.xd = x_next
self.get_logger().info(f'x_next[0]: {x_next[0]}')
self.get_logger().info(f'x_next[0]: {x_next[1]}')
self.get_logger().info(f'x_next[0]: {x_next[2]}')
# self.get_logger().info(f'x_next[0]: {x_next[0]}')
# self.get_logger().info(f'x_next[0]: {x_next[1]}')
# self.get_logger().info(f'x_next[0]: {x_next[2]}')

odom_msg = Odometry()
odom_msg = state_to_odometrymsg(x_next[:3])
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ def eta_callback(self, msg: Odometry):
def send_request(self):
if self.eta_received:
req = Waypoint.Request()
wp_list = [[self.eta[0], self.eta[1]], [self.eta[0] + 3., self.eta[1]]]
wp_list = [[self.eta[0], self.eta[1]], [self.eta[0] + 3., self.eta[1] + 3]]
req.waypoint = [Point(x=float(wp[0]), y=float(wp[1]), z=0.0) for wp in wp_list]
self.get_logger().info(f'Sending request: {req}')
self.future = self.client.call_async(req)
Expand Down
2 changes: 1 addition & 1 deletion motion/lqr_controller/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ install(DIRECTORY
)

install(PROGRAMS
lqr_controller/lqr_controller_node.py
lqr_controller/lqr_controller_node.py
DESTINATION lib/${PROJECT_NAME}
)

Expand Down
4 changes: 2 additions & 2 deletions motion/lqr_controller/lqr_controller/lqr_controller_node.py
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
from rclpy.node import Node
from geometry_msgs.msg import Wrench
from nav_msgs.msg import Odometry
from lqr_controller.lqr_controller import LQRController
from lqr_controller.conversions import odometrymsg_to_state
from lqr_controller import LQRController
from conversions import odometrymsg_to_state
from time import sleep

from rclpy.qos import QoSProfile, qos_profile_sensor_data, QoSReliabilityPolicy
Expand Down
2 changes: 1 addition & 1 deletion motion/pid_controller/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ install(DIRECTORY
)

install(PROGRAMS
pid_controller/pid_controller_node.py
pid_controller/pid_controller_node.py
DESTINATION lib/${PROJECT_NAME}
)

Expand Down
Empty file modified motion/pid_controller/launch/pid_controller.launch.py
100644 → 100755
Empty file.
6 changes: 3 additions & 3 deletions motion/pid_controller/pid_controller/pid_controller_node.py
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
from rclpy.node import Node
from geometry_msgs.msg import Wrench
from nav_msgs.msg import Odometry
from pid_controller.pid_controller import PID
from pid_controller.conversions import odometrymsg_to_state
from pid_controller import PID
from conversions import odometrymsg_to_state
from time import sleep

from rclpy.qos import QoSProfile, qos_profile_sensor_data, QoSReliabilityPolicy
Expand Down Expand Up @@ -67,7 +67,7 @@ def guidance_cb(self, msg):
def controller_callback(self):
if hasattr(self, 'state') and hasattr(self, 'x_ref'):
control_input = self.pid.calculate_control_input(self.state[:3], self.x_ref, self.state[3:], self.controller_period)
self.get_logger().info(f"Control input: {control_input}")
# self.get_logger().info(f"Control input: {control_input}")
wrench_msg = Wrench()
wrench_msg.force.x = control_input[0]
wrench_msg.force.y = control_input[1]
Expand Down

0 comments on commit 4a1110f

Please sign in to comment.