Skip to content

Commit b825174

Browse files
committed
launch file refactor
1 parent 1820e75 commit b825174

8 files changed

Lines changed: 742 additions & 301 deletions

File tree

auv_setup/config/robots/nautilus.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,7 @@
122122
imu: "imu/data_raw"
123123
sonar_info: "fls/sonar_info"
124124
pressure_sensor: "pressure"
125+
magnetometer: "magnetometer"
125126
gripper_servos: "gripper_servos"
126127

127128

auv_setup/launch/mru.launch.py

Lines changed: 115 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,115 @@
1+
"""Kongsberg MRU — IMU driver.
2+
3+
Two modes:
4+
5+
standalone=true (default)
6+
Launches a regular Node.
7+
8+
standalone=false
9+
Uses LoadComposableNodes to attach to an already-running container
10+
identified by `container_name`.
11+
"""
12+
13+
import os
14+
15+
import yaml
16+
from ament_index_python.packages import get_package_share_directory
17+
from launch import LaunchDescription
18+
from launch.actions import DeclareLaunchArgument, OpaqueFunction
19+
from launch.substitutions import LaunchConfiguration
20+
from launch_ros.actions import LoadComposableNodes, Node
21+
from launch_ros.descriptions import ComposableNode
22+
23+
from auv_setup.launch_arg_common import (
24+
declare_drone_and_namespace_args,
25+
resolve_drone_and_namespace,
26+
)
27+
28+
29+
def _launch_setup(context, *args, **kwargs):
30+
drone, namespace = resolve_drone_and_namespace(context)
31+
standalone = LaunchConfiguration('standalone').perform(context).lower() == 'true'
32+
container_name = LaunchConfiguration('container_name').perform(context)
33+
host_ip = LaunchConfiguration('host_ip').perform(context)
34+
35+
drone_params = os.path.join(
36+
get_package_share_directory('auv_setup'),
37+
'config',
38+
'robots',
39+
f'{drone}.yaml',
40+
)
41+
42+
with open(drone_params) as f:
43+
robot_topics = yaml.safe_load(f)['/**']['ros__parameters']['topics']
44+
45+
parameters = [
46+
{
47+
"imu_pub_topic": robot_topics['imu'],
48+
'frame_id': f'/{namespace}/imu_link',
49+
'connection_params.remote_ip': '10.0.0.20',
50+
'connection_params.data_remote_port': 7550,
51+
'connection_params.data_local_port': 7551,
52+
'connection_params.control_local_port': 7552,
53+
'mru_settings.channel': 'UDP1',
54+
'mru_settings.port': 7551,
55+
'mru_settings.ip_addr': host_ip,
56+
'mru_settings.format': 'MRUBIN',
57+
'mru_settings.interval': 5,
58+
'mru_settings.token': 21,
59+
}
60+
]
61+
62+
if standalone:
63+
return [
64+
Node(
65+
package='mru_ros_interface',
66+
executable='mru_ros_interface_node',
67+
name='mru_ros_interface_node',
68+
namespace=namespace,
69+
parameters=parameters,
70+
output='screen',
71+
)
72+
]
73+
else:
74+
return [
75+
LoadComposableNodes(
76+
target_container=container_name,
77+
composable_node_descriptions=[
78+
ComposableNode(
79+
package='mru_ros_interface',
80+
plugin='MruRosInterface',
81+
name='mru_ros_interface_node',
82+
namespace=namespace,
83+
parameters=parameters,
84+
extra_arguments=[{'use_intra_process_comms': True}],
85+
)
86+
],
87+
)
88+
]
89+
90+
91+
def generate_launch_description():
92+
return LaunchDescription(
93+
[
94+
DeclareLaunchArgument(
95+
'standalone',
96+
default_value='true',
97+
description=(
98+
'true = launch as a regular node; '
99+
'false = attach to an existing container named by container_name'
100+
),
101+
),
102+
DeclareLaunchArgument(
103+
'container_name',
104+
default_value='',
105+
description='Container to attach to when standalone=false',
106+
),
107+
DeclareLaunchArgument(
108+
'host_ip',
109+
default_value='10.0.0.67',
110+
description='IP address of this host machine, sent to the MRU so it knows where to stream data.',
111+
),
112+
]
113+
+ declare_drone_and_namespace_args()
114+
+ [OpaqueFunction(function=_launch_setup)]
115+
)

auv_setup/launch/ms5837.launch.py

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
"""MS5837 pressure/depth sensor driver."""
2+
3+
import os
4+
5+
import yaml
6+
from ament_index_python.packages import get_package_share_directory
7+
from launch import LaunchDescription
8+
from launch.actions import DeclareLaunchArgument, OpaqueFunction
9+
from launch.substitutions import LaunchConfiguration
10+
from launch_ros.actions import Node
11+
12+
from auv_setup.launch_arg_common import (
13+
declare_drone_and_namespace_args,
14+
resolve_drone_and_namespace,
15+
)
16+
17+
18+
def _launch_setup(context, *args, **kwargs):
19+
drone, namespace = resolve_drone_and_namespace(context)
20+
environment = LaunchConfiguration('environment').perform(context)
21+
22+
env_params_path = os.path.join(
23+
get_package_share_directory('auv_setup'),
24+
'config',
25+
'environments',
26+
f'{environment}.yaml',
27+
)
28+
29+
with open(env_params_path) as f:
30+
env = yaml.safe_load(f)['/**']['ros__parameters']
31+
32+
fluid_density = env['water']['density']
33+
atmospheric_pressure = env['atmosphere']['pressure']
34+
gravity = env['gravity']['acceleration']
35+
36+
return [
37+
Node(
38+
package='ms5837_driver',
39+
executable='ms5837_node',
40+
name='ms5837_driver_node',
41+
namespace=namespace,
42+
parameters=[
43+
{
44+
'frame_id': f'{namespace}/pressure_sensor_link',
45+
'fluid_density': fluid_density,
46+
'atmospheric_pressure': atmospheric_pressure,
47+
'gravity': gravity,
48+
'publish_depth': True,
49+
'publish_altitude': False,
50+
}
51+
],
52+
output='screen',
53+
)
54+
]
55+
56+
57+
def generate_launch_description():
58+
return LaunchDescription(
59+
[
60+
DeclareLaunchArgument(
61+
'environment',
62+
default_value='trondheim_freshwater',
63+
description='Environment config to load from auv_setup/config/environments/.',
64+
choices=[
65+
'longbeach',
66+
'stonefish_sim',
67+
'trondheim_freshwater',
68+
'trondheim_saltwater',
69+
],
70+
),
71+
]
72+
+ declare_drone_and_namespace_args()
73+
+ [OpaqueFunction(function=_launch_setup)]
74+
)

auv_setup/launch/nucleus.launch.py

Lines changed: 134 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,134 @@
1+
"""Nortek Nucleus 1000 — DVL/INS/pressure driver.
2+
3+
Two modes:
4+
5+
standalone=true (default)
6+
Launches a regular Node.
7+
8+
standalone=false
9+
Uses LoadComposableNodes to attach to an already-running container
10+
identified by `container_name`.
11+
"""
12+
13+
import os
14+
15+
import yaml
16+
from ament_index_python.packages import get_package_share_directory
17+
from launch import LaunchDescription
18+
from launch.actions import DeclareLaunchArgument, OpaqueFunction
19+
from launch.substitutions import LaunchConfiguration
20+
from launch_ros.actions import LoadComposableNodes, Node
21+
from launch_ros.descriptions import ComposableNode
22+
23+
from auv_setup.launch_arg_common import (
24+
declare_drone_and_namespace_args,
25+
resolve_drone_and_namespace,
26+
)
27+
28+
29+
def _launch_setup(context, *args, **kwargs):
30+
drone, namespace = resolve_drone_and_namespace(context)
31+
standalone = LaunchConfiguration('standalone').perform(context).lower() == 'true'
32+
container_name = LaunchConfiguration('container_name').perform(context)
33+
34+
drone_params = os.path.join(
35+
get_package_share_directory('auv_setup'),
36+
'config',
37+
'robots',
38+
f'{drone}.yaml',
39+
)
40+
41+
with open(drone_params) as f:
42+
robot_topics = yaml.safe_load(f)['/**']['ros__parameters']['topics']
43+
44+
parameters = [
45+
{
46+
'frame_id': f'/{namespace}/dvl_link',
47+
'qos': 'best_effort',
48+
'connection_params.remote_ip': '10.0.0.42',
49+
'connection_params.data_remote_port': 9000,
50+
'connection_params.password': '',
51+
'enable_imu': False,
52+
'enable_ins_odom': True,
53+
'enable_dvl': True,
54+
'enable_pressure': True,
55+
'enable_altimeter': True,
56+
'enable_magnetometer': True,
57+
'enable_ins_twist': False,
58+
'enable_ins_position': False,
59+
'enable_ins_pose': False,
60+
"imu_data_raw_pub_topic": f"/{namespace}/nucleus/imu/data_raw",
61+
"imu_data_pub_topic": f"/{namespace}/nucleus/imu/data",
62+
"ins_pub_topic": f"/{namespace}/nucleus/odom",
63+
"dvl_pub_topic": robot_topics['dvl_twist'],
64+
"altimeter_pub_topic": robot_topics['dvl_altitude'],
65+
"pressure_pub_topic": f"/{namespace}/nucleus/pressure", # Not used atm
66+
"magnetometer_pub_topic": robot_topics['magnetometer'],
67+
"ins_twist_pub_topic": f"/{namespace}/nucleus/ins/twist",
68+
"ins_position_pub_topic": f"/{namespace}/nucleus/ins/position",
69+
"ins_pose_pub_topic": f"/{namespace}/nucleus/ins/pose",
70+
'imu_settings.freq': 125,
71+
'ahrs_settings.freq': 10,
72+
'ahrs_settings.mode': 0,
73+
'bottom_track_settings.mode': 2,
74+
'bottom_track_settings.velocity_range': 5,
75+
'bottom_track_settings.enable_watertrack': False,
76+
'fast_pressure_settings.enable': True,
77+
'fast_pressure_settings.sampling_rate': 16,
78+
'magnetometer_settings.freq': 75,
79+
'magnetometer_settings.mode': 0,
80+
'instrument_settings.rotxy': 0.0,
81+
'instrument_settings.rotyz': 0.0,
82+
'instrument_settings.rotxz': 0.0,
83+
}
84+
]
85+
86+
if standalone:
87+
return [
88+
Node(
89+
package='nortek_nucleus_ros_interface',
90+
executable='nortek_nucleus_ros_interface_node',
91+
name='nortek_nucleus_ros_interface_node',
92+
namespace=namespace,
93+
parameters=parameters,
94+
output='screen',
95+
)
96+
]
97+
else:
98+
return [
99+
LoadComposableNodes(
100+
target_container=container_name,
101+
composable_node_descriptions=[
102+
ComposableNode(
103+
package='nortek_nucleus_ros_interface',
104+
plugin='NortekNucleusRosInterface',
105+
name='nortek_nucleus_ros_interface_node',
106+
namespace=namespace,
107+
parameters=parameters,
108+
extra_arguments=[{'use_intra_process_comms': True}],
109+
)
110+
],
111+
)
112+
]
113+
114+
115+
def generate_launch_description():
116+
return LaunchDescription(
117+
[
118+
DeclareLaunchArgument(
119+
'standalone',
120+
default_value='true',
121+
description=(
122+
'true = launch as a regular node; '
123+
'false = attach to an existing container named by container_name'
124+
),
125+
),
126+
DeclareLaunchArgument(
127+
'container_name',
128+
default_value='',
129+
description='Container to attach to when standalone=false',
130+
),
131+
]
132+
+ declare_drone_and_namespace_args()
133+
+ [OpaqueFunction(function=_launch_setup)]
134+
)

0 commit comments

Comments
 (0)