|
| 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