Skip to content

Commit 7de3db0

Browse files
authored
Merge pull request #706 from vortexntnu/dp_adaptive_backstepping_controler_to_quaternion
merge control stack from easter testing into main
2 parents 8a0f2e8 + b8b86b0 commit 7de3db0

65 files changed

Lines changed: 4121 additions & 617 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

auv_setup/README.md

Lines changed: 58 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,64 @@ The config folder contains physical parameters related to the AUV and the enviro
1010
* thrusters: Thruster configs for different thruster types
1111

1212
### Launch
13-
This package contains a launchfile for each specific AUV. Additionally the topside.launch file is to
14-
be used on the topside computer that the joystick is connected to, for ROV operations.
13+
14+
This package contains launchfiles for each specific AUV. Additionally `topside.launch.py` is used on the topside computer that the joystick is connected to, for ROV operations.
15+
16+
```bash
17+
ros2 launch auv_setup topside.launch.py --orientation_mode:=your_argument
18+
```
19+
20+
| Argument | Default | Description |
21+
|---|---|---|
22+
| `orientation_mode` |`euler`| Types to choose from `euler` or `quat` |
23+
24+
25+
26+
**`adaptive`** — launches `dp_adapt_backs_controller` with `reference_filter_dp` (Euler/RPY reference filter). Controller params are loaded from `dp_adapt_backs_controller/config/adapt_params_<drone>.yaml`.
27+
28+
```bash
29+
ros2 launch auv_setup dp.launch.py controller_type:=adaptive drone:=nautilus
30+
```
31+
32+
**`adaptive_quat`** — launches `dp_adapt_backs_controller` with `reference_filter_dp` (Quaternion reference filter). Controller params are loaded from `dp_adapt_backs_controller_quat/config/adapt_params_<drone>.yaml`.
33+
34+
```bash
35+
ros2 launch auv_setup dp_quat.launch.py controller_type:=adaptive drone:=nautilus
36+
```
37+
38+
#### dp.launch.py or dp_quat.launch.py
39+
40+
Both launch the DP (dynamic positioning) stack, consisting of a reference filter and a controller launched together in a composable node container to limit intra process communication and allow for shared memory.
41+
42+
```bash
43+
ros2 launch auv_setup dp.launch.py
44+
```
45+
46+
| Argument | Default | Description |
47+
|---|---|---|
48+
| `drone` | `nautilus` | Drone model — loads `auv_setup/config/robots/<drone>.yaml` |
49+
| `namespace` | `<drone>` | ROS namespace. Defaults to the drone name if left empty |
50+
| `controller_type` | `adaptive` | Controller to use: `adaptive`, `adaptive_quat` or `pid` |
51+
52+
**`adaptive`** — launches `dp_adapt_backs_controller` with `reference_filter_dp` (Euler/RPY reference filter). Controller params are loaded from `dp_adapt_backs_controller/config/adapt_params_<drone>.yaml`.
53+
54+
```bash
55+
ros2 launch auv_setup dp.launch.py controller_type:=adaptive drone:=nautilus
56+
```
57+
58+
**`adaptive_quat`** — launches `dp_adapt_backs_controller` with `reference_filter_dp` (Quaternion reference filter). Controller params are loaded from `dp_adapt_backs_controller_quat/config/adapt_params_<drone>.yaml`.
59+
60+
```bash
61+
ros2 launch auv_setup dp_quat.launch.py controller_type:=adaptive drone:=nautilus
62+
```
63+
64+
**`pid`** — launches `pid_controller_dp` with `reference_filter_dp_quat` (quaternion reference filter). Controller params are loaded from `pid_controller_dp/config/pid_params.yaml`.
65+
66+
```bash
67+
ros2 launch auv_setup dp.launch.py controller_type:=pid drone:=nautilus
68+
```
69+
70+
> When using the joystick to send references, make sure `orientation_mode` in `joystick_interface_auv` matches the controller: use `euler` with `adaptive` and `quat` with `pid`.
1571
1672
### Description
1773
The description folder contains the URDF and xacro files for the AUVs. The main description launch file is drone_description.launch.py, which makes all static transforms available to the ros graph.

auv_setup/config/robots/nautilus.yaml

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
/**:
1717
ros__parameters:
1818
physical:
19-
center_of_mass: [0.0, 0.0, 0.01] # CO is aligned with CM Position (x,y) in meters (M), small cg offset in z to keep drone naturally stable in roll/pitch
19+
center_of_mass: [0.0, 0.0, 0.025] # CO is aligned with CM Position (x,y) in meters (M), small cg offset in z to keep drone naturally stable in roll/pitch
2020
mass_matrix: [53.7, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 53.7, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 53.7, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 11.0628, 1.086, -3.17502, 0.0, 0.0, 0.0, 1.086, 23.1128, 0.1025, 0.0, 0.0, 0.0, -3.17502, 0.1025, 26.23998]
2121
# 6x6 mass_inertia_matrix
2222
propulsion:
@@ -53,22 +53,22 @@
5353
0.00000, # Heave
5454
]
5555
thruster_position: [ # Position (x0,x1 ... x7,y1,y2, ...,y7,z1,z2, ... ,z7) in meters (M). i.e thruster0 has position (x0,y0,z0)
56-
0.413892,
57-
0.140095,
58-
-0.163904,
59-
-0.413892,
60-
-0.413892,
61-
-0.163904,
62-
0.140095,
63-
0.413892, # x-positions of the thrusters
56+
0.45015,
57+
0.24060,
58+
-0.22970,
59+
-0.43861,
60+
-0.43861,
61+
-0.22970,
62+
0.240600,
63+
0.450150, # x-positions of the thrusters
64+
0.305680,
6465
0.313022,
6566
0.313022,
66-
0.313022,
67-
0.313022,
68-
-0.313022,
67+
0.305680,
68+
-0.305680,
6969
-0.313022,
7070
-0.313022,
71-
-0.313022, # y-positions of the thrusters
71+
-0.305680, # y-positions of the thrusters
7272
0.021736,
7373
0.021736,
7474
0.021736,
@@ -80,8 +80,8 @@
8080
]
8181

8282
constraints:
83-
max_force: 40.0
84-
min_force: -40.0
83+
max_force: 39.0
84+
min_force: -41.0
8585
input_matrix_weights: [1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0]
8686
slack_matrix_weights: [2000.0,2000.0,2000.0,2000.0,2000.0,2000.0]
8787

@@ -110,7 +110,7 @@
110110
waypoint: "waypoint"
111111
guidance:
112112
los: "guidance/los"
113-
dp: "guidance/dp"
113+
dp_rpy: "guidance/dp_rpy"
114114
dp_quat: "guidance/dp_quat"
115115
dvl_twist: "dvl/twist"
116116
dvl_altitude: "dvl/altitude"

auv_setup/config/robots/orca.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@
134134
waypoint: "waypoint"
135135
guidance:
136136
los: "guidance/los"
137-
dp: "guidance/dp"
137+
dp_rpy: "guidance/dp_rpy"
138138
dp_quat: "guidance/dp_quat"
139139
fsm:
140140
active_controller: "fsm/active_controller"

auv_setup/launch/dp_quat.launch.py

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
import os
2+
3+
from ament_index_python.packages import get_package_share_directory
4+
from launch import LaunchDescription
5+
from launch.actions import OpaqueFunction
6+
from launch_ros.actions import ComposableNodeContainer
7+
from launch_ros.descriptions import ComposableNode
8+
9+
from auv_setup.launch_arg_common import (
10+
declare_drone_and_namespace_args,
11+
resolve_drone_and_namespace,
12+
)
13+
14+
15+
def launch_setup(context, *args, **kwargs):
16+
drone, namespace = resolve_drone_and_namespace(context)
17+
18+
filter_config = os.path.join(
19+
get_package_share_directory("reference_filter_dp_quat"),
20+
"config",
21+
"reference_filter_params.yaml",
22+
)
23+
24+
drone_params = os.path.join(
25+
get_package_share_directory("auv_setup"),
26+
"config",
27+
"robots",
28+
f"{drone}.yaml",
29+
)
30+
31+
adapt_params = os.path.join(
32+
get_package_share_directory("dp_adapt_backs_controller_quat"),
33+
"config",
34+
f"adapt_params_{drone}.yaml",
35+
)
36+
37+
container = ComposableNodeContainer(
38+
name="dp_quat_container",
39+
namespace=namespace,
40+
package="rclcpp_components",
41+
executable="component_container_mt",
42+
composable_node_descriptions=[
43+
ComposableNode(
44+
package="reference_filter_dp_quat",
45+
plugin="ReferenceFilterNode",
46+
name="reference_filter_node",
47+
namespace=namespace,
48+
parameters=[filter_config, drone_params],
49+
extra_arguments=[{"use_intra_process_comms": True}],
50+
),
51+
ComposableNode(
52+
package="dp_adapt_backs_controller_quat",
53+
plugin="DPAdaptBacksControllerNode",
54+
name="dp_adapt_backs_controller_node",
55+
namespace=namespace,
56+
parameters=[adapt_params, drone_params],
57+
extra_arguments=[{"use_intra_process_comms": True}],
58+
),
59+
],
60+
output="screen",
61+
)
62+
63+
return [container]
64+
65+
66+
def generate_launch_description():
67+
return LaunchDescription(
68+
declare_drone_and_namespace_args()
69+
+ [
70+
OpaqueFunction(function=launch_setup),
71+
]
72+
)

control/dp_adapt_backs_controller/src/dp_adapt_backs_controller_ros.cpp

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,9 @@ void DPAdaptBacksControllerNode::set_subscribers_and_publisher() {
4040
vortex::utils::qos_profiles::sensor_data_profile(1)};
4141
const auto qos_reliable{vortex::utils::qos_profiles::reliable_profile(1)};
4242

43-
this->declare_parameter<std::string>("topics.guidance.dp");
43+
this->declare_parameter<std::string>("topics.guidance.dp_rpy");
4444
std::string dp_reference_topic =
45-
this->get_parameter("topics.guidance.dp").as_string();
45+
this->get_parameter("topics.guidance.dp_rpy").as_string();
4646
guidance_sub_ =
4747
this->create_subscription<vortex_msgs::msg::ReferenceFilter>(
4848
dp_reference_topic, qos_sensor_data,
@@ -234,10 +234,7 @@ void DPAdaptBacksControllerNode::publish_tau() {
234234
tau_msg.wrench.force.x = tau(0);
235235
tau_msg.wrench.force.y = tau(1);
236236
tau_msg.wrench.force.z = tau(2);
237-
238-
// comment out if roll control is not needed
239237
tau_msg.wrench.torque.x = tau(3);
240-
241238
tau_msg.wrench.torque.y = tau(4);
242239
tau_msg.wrench.torque.z = tau(5);
243240

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
cmake_minimum_required(VERSION 3.8)
2+
project(dp_adapt_backs_controller_quat)
3+
set(CMAKE_CXX_STANDARD 20)
4+
5+
if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")
6+
add_compile_options(-Wall -Wextra -Wpedantic)
7+
endif()
8+
9+
find_package(ament_cmake REQUIRED)
10+
find_package(vortex_utils REQUIRED)
11+
find_package(vortex_utils_ros REQUIRED)
12+
find_package(rclcpp REQUIRED)
13+
find_package(rclcpp_components REQUIRED)
14+
find_package(geometry_msgs REQUIRED)
15+
find_package(Eigen3 REQUIRED)
16+
find_package(vortex_msgs REQUIRED)
17+
find_package(fmt REQUIRED)
18+
find_package(spdlog REQUIRED)
19+
20+
21+
include_directories(include)
22+
23+
set(LIB_NAME "${PROJECT_NAME}_component")
24+
25+
add_library(${LIB_NAME} SHARED
26+
src/dp_adapt_backs_controller.cpp
27+
src/dp_adapt_backs_controller_ros.cpp
28+
src/dp_adapt_backs_controller_utils.cpp)
29+
30+
ament_target_dependencies(${LIB_NAME} PUBLIC
31+
rclcpp
32+
rclcpp_components
33+
geometry_msgs
34+
Eigen3
35+
fmt
36+
spdlog
37+
vortex_msgs
38+
vortex_utils
39+
vortex_utils_ros
40+
)
41+
42+
rclcpp_components_register_node(
43+
${LIB_NAME}
44+
PLUGIN "DPAdaptBacksControllerNode"
45+
EXECUTABLE ${PROJECT_NAME}_node
46+
)
47+
48+
ament_export_targets(export_${LIB_NAME})
49+
50+
install(TARGETS ${LIB_NAME}
51+
EXPORT export_${LIB_NAME}
52+
ARCHIVE DESTINATION lib
53+
LIBRARY DESTINATION lib
54+
RUNTIME DESTINATION bin
55+
)
56+
57+
install(
58+
DIRECTORY include/
59+
DESTINATION include
60+
)
61+
62+
install(DIRECTORY
63+
launch
64+
config
65+
DESTINATION share/${PROJECT_NAME}/
66+
)
67+
68+
if(BUILD_TESTING)
69+
add_subdirectory(test)
70+
endif()
71+
72+
ament_package()

0 commit comments

Comments
 (0)