Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: implementation of a pid dp controller #499

Open
wants to merge 130 commits into
base: main
Choose a base branch
from
Open
Changes from 1 commit
Commits
Show all changes
130 commits
Select commit Hold shift + click to select a range
3260506
feat: adding in the setup for dp controller, dosent build, need to fix
Talhanc Sep 27, 2024
a3da7f6
feat: adding in pid parts
Talhanc Oct 11, 2024
0705602
Develop (#481)
kluge7 Oct 11, 2024
b218088
self.reference_mode erstattes med States.REFERENCE_MODE
malenef Oct 13, 2024
3180183
Some formatting
Andeshog Oct 13, 2024
821c846
feat: add pid gains
Talhanc Oct 13, 2024
cb24307
refactor: move controller to control
Andeshog Oct 13, 2024
6c93dfe
refactor: change function name from J to create_J to avoid conflict w…
Andeshog Oct 13, 2024
2e66778
Vinklene restarter seg ikke til null når du slipper opp kontrolleren
malenef Oct 18, 2024
76249d7
feat: added a new main.cpp file with ros2 node class
Talhanc Oct 18, 2024
5de507d
feat: add pid controller for dp
Andeshog Oct 18, 2024
5ca0457
feat: add possiblity to tune the PID during runtime by publishing Flo…
Andeshog Oct 18, 2024
7f16b07
feat: add config file for parameters
Andeshog Oct 19, 2024
f21369f
remove unnecessary typedef
Andeshog Oct 19, 2024
ff279e0
refactor: move eta, eta_d and nu over to ros node
Andeshog Oct 19, 2024
ee91ca5
feat: add launch file
Andeshog Oct 19, 2024
59b362c
feat: add eta_dot_d as reference state
Andeshog Oct 19, 2024
7a71543
build fix
Andeshog Oct 19, 2024
23c313e
feat: add reference filter
Andeshog Oct 19, 2024
4dcf9f6
added zeta and omega as ros params
jorgenfj Oct 19, 2024
3c56eea
feat: initialized action server
Andeshog Oct 20, 2024
d13fca8
feat: action server for reference filter
Andeshog Oct 20, 2024
18ded87
feat: add odom subscriber for reference filter
Andeshog Oct 20, 2024
0063806
Add parameter file
malenef Oct 20, 2024
c486401
Add ssa
malenef Oct 20, 2024
bbbe77e
Add better formating and cleaner code
malenef Oct 20, 2024
30c3bd8
Add documentation
malenef Oct 20, 2024
5327a63
feat: adding joystick input
Talhanc Oct 20, 2024
c5dea38
Add documentation and remove spamming in terminal
malenef Oct 20, 2024
c46ba1e
fix: some issues with pid_controller_ros.hpp file
Talhanc Oct 20, 2024
5ffb4a2
Merge branch '434-task-dp-controller' into 432-task-expand-joystick-i…
Talhanc Oct 20, 2024
487830d
Merge pull request #490 from vortexntnu/432-task-expand-joystick-inte…
Talhanc Oct 20, 2024
79fc2aa
feat: add multithreaded executor
Andeshog Oct 20, 2024
af96056
Merge branch '434-task-dp-controller' of github.com:vortexntnu/vortex…
Andeshog Oct 20, 2024
7406b3a
feat: make new goals overwrite the old goal
Andeshog Oct 22, 2024
06662e1
feat: add rotation of velocity from body to NED
Andeshog Oct 22, 2024
a442e88
feat: tuning reference filter
Andeshog Oct 22, 2024
28e4e71
fix: fix conversions between quat and euler using tf2
Andeshog Oct 22, 2024
cfa688b
refactor: use tf2 for conversion between euler and quat
Andeshog Oct 22, 2024
8d0d38b
feat: init tuning process
Andeshog Oct 22, 2024
121c638
feat: added anti windup
Talhanc Oct 23, 2024
c1df6f9
fix: variable issue in controller input
Talhanc Oct 23, 2024
3a2076f
refactor: Update include order in pid_controller_utils.hpp
Talhanc Oct 23, 2024
5f46ee1
feat: added in quaternions instead of euler
Talhanc Oct 24, 2024
9a69032
feat: added quaternion normalization to fix error
Talhanc Oct 31, 2024
188efa2
fix: changed pid params
Talhanc Nov 1, 2024
ed2115e
refactor(dp_controller): removed previous version
Talhanc Nov 8, 2024
ad55492
docs: added documentation
Talhanc Nov 8, 2024
614bc3e
docs: added documentation
Talhanc Nov 8, 2024
b280119
Merge remote-tracking branch 'origin/develop' into 434-task-dp-contro…
Talhanc Nov 8, 2024
8ced2af
hey
Talhanc Nov 8, 2024
00a2424
hey
Talhanc Nov 8, 2024
d159315
refactor: applied formatting changes
Talhanc Nov 8, 2024
9ca02ca
refactor: did some changes asked by anders
Talhanc Nov 8, 2024
ddfd003
fix(pid_controller_utils): forgot ; in one line
Talhanc Nov 8, 2024
ca73be3
feat: add methods for filling vectors
Andeshog Nov 10, 2024
1c65a96
refactor: remove redundant code
Andeshog Nov 10, 2024
4a2d2e8
feat: add tf2_geometry_msgs dependency
Andeshog Nov 10, 2024
b2d8df1
fix: fix methods
Andeshog Nov 10, 2024
b6d17b8
refactor: make precommit hook happy
Andeshog Nov 10, 2024
99e859a
make pre-commit hook happy
Andeshog Nov 10, 2024
fbf26e8
fix: fix parameter names
Andeshog Nov 10, 2024
2a75ea4
feat: added struct elements for the quaternions and position
Talhanc Nov 10, 2024
cc0b3b6
Merge branch 'feat/dp_controller_euler' into 434-task-dp-controller
Andeshog Nov 18, 2024
69b4c3a
feat: add correct qos profile for odom sug
Andeshog Nov 18, 2024
0ac8b2e
fix: structure fix
Andeshog Nov 18, 2024
7717907
fix: make pre-commit guy habby
Andeshog Nov 18, 2024
ba23237
fix:something wrong
Talhanc Jan 7, 2025
87d0a4a
fix:something wrong
Talhanc Jan 7, 2025
ab7fd8b
fix: fixing the control input computation
Talhanc Jan 7, 2025
2e07a59
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Jan 7, 2025
222302b
fix: variabel error in guidance callback
Talhanc Jan 8, 2025
2868b8a
fix: some merge errors
Talhanc Jan 8, 2025
fde5507
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Jan 8, 2025
6683733
feat: added topics into config file for the euler pid controller
Talhanc Jan 9, 2025
2031df1
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Jan 9, 2025
25c245a
fix: Adeed kill switch and remove the msgs error
Talhanc Jan 9, 2025
3499682
fix: change in reference filter parameter
Talhanc Jan 9, 2025
0cf0c30
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Jan 9, 2025
ae4ee10
feat: Added adaptive backstepping controller
Talhanc Jan 19, 2025
9d6e417
fix: something happend
Talhanc Jan 19, 2025
67ec45e
feat: adding in the adaptive backstepping in cpp
Talhanc Jan 19, 2025
1698e19
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Jan 19, 2025
8ddb8c9
fix: fixed config file and added the rest of the adaptive controller
Talhanc Jan 20, 2025
ae5251a
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Jan 20, 2025
42dd28e
fix: some errors with the commits, removed some of the code
Talhanc Jan 20, 2025
758faed
refactor: improve consistency
Andeshog Jan 20, 2025
33ce6a2
refactor: remove callbacks for tuning params
Andeshog Jan 20, 2025
e1bb639
feat: adaptive backstepping controller works in dpp
Talhanc Jan 20, 2025
ab60c9c
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Jan 20, 2025
49c50fc
fix: standard cpp version
Andeshog Jan 20, 2025
54bfe6a
Merge branch '434-task-dp-controller' of github.com:vortexntnu/vortex…
Andeshog Jan 20, 2025
579bd3e
fix: changed and fixed som config file values
Talhanc Jan 20, 2025
6c9ea88
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Jan 20, 2025
4f27d42
feat: removed the python adaptive controller, it is now in local lega…
Talhanc Jan 20, 2025
a070b97
fix: containing was written wrong
Talhanc Jan 20, 2025
5700140
refactor: reference filter
Andeshog Jan 20, 2025
362d266
Merge branch '434-task-dp-controller' of github.com:vortexntnu/vortex…
Andeshog Jan 20, 2025
7e3dfe1
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Jan 20, 2025
18a7291
refactor: remove unused odom topic declaration
Andeshog Jan 20, 2025
6207e3f
Merge branch '434-task-dp-controller' of github.com:vortexntnu/vortex…
Andeshog Jan 20, 2025
8544f16
doc: add doc to pose and twist callback
Andeshog Jan 20, 2025
8d14381
fix: cpp version
Andeshog Jan 20, 2025
d03194e
fix: license
Andeshog Jan 20, 2025
51b8441
fix: removed iostream library from the files
Talhanc Jan 20, 2025
bd49885
remove iostream
Andeshog Jan 20, 2025
f9ae2d6
Merge branch '434-task-dp-controller' of github.com:vortexntnu/vortex…
Andeshog Jan 20, 2025
4fb8db7
fix: removed /orca/odom, and added /dvl/pose and twist
Talhanc Jan 22, 2025
d010a89
fix: added some changed requested
Talhanc Jan 22, 2025
963be51
fix: made it more readable
Talhanc Jan 22, 2025
c867f58
feat: added Readme for the adaptive backstepping controller
Talhanc Jan 23, 2025
a9b8b4f
fix: some problem in the README files
Talhanc Jan 23, 2025
830da9e
fix: tried to fix it again
Talhanc Jan 23, 2025
0948c70
fix: tried to fix it again v2
Talhanc Jan 23, 2025
e589ea0
fix: tried to fix it again v3
Talhanc Jan 23, 2025
357afd7
fix: tried to fix it again v4
Talhanc Jan 23, 2025
3d68a81
fix: trying to fix error in README
Talhanc Jan 23, 2025
c429e8a
fix: trying to fix error in README v2
Talhanc Jan 23, 2025
f0bc772
fix: trying to fix error in README v3
Talhanc Jan 23, 2025
1754f8e
fix: trying to fix error in README v4
Talhanc Jan 23, 2025
9a1175e
fix: trying to fix error in README v5
Talhanc Jan 23, 2025
f712dd2
fix: trying to fix error in README v6
Talhanc Jan 23, 2025
862a8b8
fix: trying to fix error in README v7
Talhanc Jan 23, 2025
b958d04
started readme for reference filter
Andeshog Jan 23, 2025
66880d2
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Jan 23, 2025
1a53f2e
started readme for reference filter v2
Andeshog Jan 23, 2025
72fcf01
fix readme
Andeshog Jan 23, 2025
606078a
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Jan 23, 2025
250e7fb
finish readme for reference filter
Andeshog Jan 26, 2025
5a94f76
Merge branch '434-task-dp-controller' of github.com:vortexntnu/vortex…
Andeshog Jan 26, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
hey
  • Loading branch information
Talhanc committed Nov 8, 2024
commit 8ced2af13dd183d454257b6d2a0c20bed1807765
Original file line number Diff line number Diff line change
Expand Up @@ -98,13 +98,9 @@ def __init__(self):
self.joystick_axes_map_ = []

self.joy_subscriber_ = self.create_subscription(
Joy, "joystick/joy", self.joystick_cb, 5)
self.wrench_publisher_ = self.create_publisher(Wrench,
"joystick/wrench",
10)
self.pose_publisher = self.create_publisher(PoseStamped, "/dp/guidance", 10)
self.timer_ = self.create_timer(0.1, self.timer_cb)

Joy, "joystick/joy", self.joystick_cb, 5
)
self.wrench_publisher_ = self.create_publisher(Wrench, "thrust/wrench_input", 5)

self.declare_parameter('surge_scale_factor', 60.0)
self.declare_parameter('sway_scale_factor', 60.0)
Expand Down Expand Up @@ -135,51 +131,32 @@ def __init__(self):
self.joystick_pitch_scaling_ = self.get_parameter(
'pitch_scale_factor').value

#Gets the scaling factors for the reference mode from the yaml file
self.joystick_surge_param_ = self.get_parameter(
'surge_scale_ref_param').value
self.joystick_sway_param_ = self.get_parameter(
'sway_scale_ref_param').value
self.joystick_heave_param_ = self.get_parameter(
'heave_scale_ref_param').value
self.joystick_yaw_param_ = self.get_parameter(
'yaw_scale_ref_param').value
self.joystick_roll_param_ = self.get_parameter(
'roll_scale_ref_param').value
self.joystick_pitch_param_ = self.get_parameter(
'pitch_scale_ref_param').value

#Killswitch publisher
# Killswitch publisher
self.software_killswitch_signal_publisher_ = self.create_publisher(
Bool, "softwareKillSwitch", 10)
Bool, "softwareKillSwitch", 10
)
self.software_killswitch_signal_publisher_.publish(
Bool(data=True)) #Killswitch is active
Bool(data=True)
) # Killswitch is active

#Operational mode publisher
# Operational mode publisher
self.operational_mode_signal_publisher_ = self.create_publisher(
String, "softwareOperationMode", 10)
self.current_pose = PoseStamped()


def create_pose_message(self):
"""
Creates a PoseStamped message with the current pose of the AUV.

This function creates a PoseStamped message, sets the current time as the timestamp,
and assigns the current pose of the AUV to the pose field of the message.
String, "softwareOperationMode", 10
)

Returns:
PoseStamped: A ROS PoseStamped message containing the current pose of the AUV.
"""
pose_msg = PoseStamped()
pose_msg.header.stamp = self.get_clock().now().to_msg()
pose_msg.header.frame_id = "base_link"
pose_msg.pose = self.current_pose.pose
return pose_msg
# Signal that we are in XBOX mode
self.operational_mode_signal_publisher_.publish(String(data="XBOX"))

def create_wrench_message(self, surge: float, sway: float, heave: float, roll: float, pitch: float, yaw: float) -> Wrench:
"""
Creates a 2D wrench message with the given x, y, heave, roll, pitch, and yaw values.
def create_wrench_message(
self,
surge: float,
sway: float,
heave: float,
roll: float,
pitch: float,
yaw: float,
) -> Wrench:
"""Creates a 2D wrench message with the given x, y, heave, roll, pitch, and yaw values.

Args:
surge (float): The x component of the force vector.
Expand All @@ -205,22 +182,6 @@ def transition_to_xbox_mode(self) -> None:
"""Turns off the controller and signals that the operational mode has switched to Xbox mode."""
self.operational_mode_signal_publisher_.publish(String(data="XBOX"))
self.state_ = States.XBOX_MODE
self.get_logger().info("Transitioned to XBOX mode.")
self.get_logger().info("XBOX mode")


def transition_to_reference_mode(self):
"""
Publishes a pose message and signals that the operational mode has switched to Reference mode.
"""
pose_msg = self.create_pose_message()
self.operational_mode_signal_publisher_.publish(String(data="Reference mode"))
self.pose_publisher.publish(pose_msg)
self.state_ = States.REFERENCE_MODE
self.get_logger().info("Transitioned to reference mode")
self.get_logger().info("Reference mode")



def transition_to_autonomous_mode(self) -> None:
"""Publishes a zero force wrench message and signals that the system is turning on autonomous mode."""
Expand All @@ -232,13 +193,23 @@ def transition_to_autonomous_mode(self) -> None:
self.get_logger().info("autonomous mode")


def check_number_of_buttons(self, msg: Joy) -> None:
"""
Checks if the controller is wireless (has 16 buttons) or wired and sets the joystick button and axis maps accordingly.

def joystick_cb(self, msg: Joy) -> Wrench:
"""Callback function that receives joy messages and converts them into wrench messages to be sent to the thruster allocation node.

Handles software killswitch and control mode buttons, and transitions between different states of operation.

Args:
msg: A ROS message containing the joy input data.
"""

Returns:
A ROS message containing the wrench data that was sent to the thruster allocation node.
"""
current_time = self.get_clock().now().to_msg().sec

buttons = {}
axes = {}

# Check if the controller is wireless (has 16 buttons) or wired
if len(msg.buttons) == 16:
self.joystick_buttons_map_ = WirelessXboxSeriesX.joystick_buttons_map_
self.joystick_axes_map_ = WirelessXboxSeriesX.joystick_axes_map_
Expand Down Expand Up @@ -389,7 +360,37 @@ def joystick_cb(self, msg: Joy) -> Wrench:
left_shoulder = buttons.get("LB", 0)
right_shoulder = buttons.get("RB", 0)

self.calculate_movement(axes, left_trigger, right_trigger, left_shoulder, right_shoulder)
# Extract axis values
surge = (
axes.get("vertical_axis_left_stick", 0.0)
* self.joystick_surge_scaling_
* self.precise_manuevering_scaling_
)
sway = (
-axes.get("horizontal_axis_left_stick", 0.0)
* self.joystick_sway_scaling_
* self.precise_manuevering_scaling_
)
heave = (
(left_trigger - right_trigger)
* self.joystick_heave_scaling_
* self.precise_manuevering_scaling_
)
roll = (
(right_shoulder - left_shoulder)
* self.joystick_roll_scaling_
* self.precise_manuevering_scaling_
)
pitch = (
-axes.get("vertical_axis_right_stick", 0.0)
* self.joystick_pitch_scaling_
* self.precise_manuevering_scaling_
)
yaw = (
-axes.get("horizontal_axis_right_stick", 0.0)
* self.joystick_yaw_scaling_
* self.precise_manuevering_scaling_
)

# Debounce for the buttons
if current_time - self.last_button_press_time_ < self.debounce_duration_:
Expand All @@ -399,13 +400,43 @@ def joystick_cb(self, msg: Joy) -> Wrench:
reference_mode_button = False

# If any button is pressed, update the last button press time
if software_control_mode_button or xbox_control_mode_button or software_killswitch_button or reference_mode_button:

if (
software_control_mode_button
or xbox_control_mode_button
or software_killswitch_button
or precise_manuevering_mode_button
):
self.last_button_press_time_ = current_time

# Toggle killswitch on and off
if software_killswitch_button:
self.handle_killswitch_button()
if self.state_ == States.NO_GO:
# Signal that killswitch is not blocking
self.software_killswitch_signal_publisher_.publish(Bool(data=False))
self.transition_to_xbox_mode()
return

self.get_logger().info("SW killswitch", throttle_duration_sec=1)
# Signal that killswitch is blocking
self.software_killswitch_signal_publisher_.publish(Bool(data=True))

# Publish a zero wrench message when killswitch is activated
wrench_msg = self.create_wrench_message(0.0, 0.0, 0.0, 0.0, 0.0, 0.0)
self.wrench_publisher_.publish(wrench_msg)
self.state_ = States.NO_GO
return wrench_msg

# Toggle precise maneuvering mode on and off
if precise_manuevering_mode_button:
self.precise_manuevering_mode_ = not self.precise_manuevering_mode_
mode = "ENABLED" if self.precise_manuevering_mode_ else "DISABLED"
self.get_logger().info(f"Precise maneuvering mode {mode}.")
self.precise_manuevering_scaling_ = (
0.5 if self.precise_manuevering_mode_ else 1.0
)

# Publish wrench message from joystick_interface to thrust allocation
wrench_msg = self.create_wrench_message(surge, sway, heave, roll, pitch, yaw)

if self.state_ == States.XBOX_MODE:
wrench_msg = self.create_wrench_message(self.surge, self.sway, self.heave,
Expand Down
You are viewing a condensed version of this merge commit. You can view the full changes here.