mavlink / mavros

MAVLink to ROS gateway with proxy for Ground Control Station
Other
905 stars 994 forks source link

Unable to pass pluginlists_yaml file path in launch_arguments #1965

Closed itskalvik closed 4 months ago

itskalvik commented 4 months ago

Issue details

Hello everyone! I am trying to pass a custom pluginlists_yaml file to mavros as a launch file argument. Here is my launch file:

<launch>
       <arg name="fcu_url" default="udp://0.0.0.0:14550@" />
    <arg name="gcs_url" default="" />
    <arg name="tgt_system" default="1" />
    <arg name="tgt_component" default="1" />
    <arg name="log_output" default="screen" />
    <arg name="fcu_protocol" default="v2.0" />
    <arg name="respawn_mavros" default="false" />
    <arg name="namespace" default="mavros"/>
    <arg name="pluginlists_yaml" default="$(find-pkg-share my_package)/launch/apm_pluginlists.yaml" />
    <arg name="config_yaml" default="$(find-pkg-share mavros)/launch/apm_config.yaml" />
    <include file="$(find-pkg-share mavros)/launch/node.launch">
        <arg name="pluginlists_yaml" value="$(var pluginlists_yaml)" />
        <arg name="config_yaml" value="$(var config_yaml)" />
        <arg name="fcu_url" value="$(var fcu_url)" />
        <arg name="gcs_url" value="$(var gcs_url)" />
        <arg name="tgt_system" value="$(var tgt_system)" />
        <arg name="tgt_component" value="$(var tgt_component)" />
        <arg name="fcu_protocol" value="$(var fcu_protocol)" />
        <arg name="respawn_mavros" value="$(var respawn_mavros)" />
        <arg name="namespace" value="$(var namespace)"/>
    </include>
</launch>

The file works fine when called directly from the terminal with ros2 launch, but it does not work when I call it from another Python launch file. In particular, I am able to set the fcu_url without any issues, but not the pluginlists_yaml file path. Mavros ignores the custom pluginlists_yaml path and uses the default file shipped with the package. Here is my Python launch file:

import os
from launch import LaunchDescription
from launch_ros.actions import Node
from launch_xml.launch_description_sources import XMLLaunchDescriptionSource
from launch.actions import GroupAction, IncludeLaunchDescription
from launch_ros.actions import PushRosNamespace
from ament_index_python import get_package_share_directory

def generate_launch_description():
    return LaunchDescription([
        GroupAction(
            actions=[
                # push_ros_namespace to set namespace of included nodes
                PushRosNamespace('robot_0'),
                IncludeLaunchDescription(
                    XMLLaunchDescriptionSource(
                        os.path.join(
                            get_package_share_directory('my_package'),
                            'launch/mavros.launch')),
                    launch_arguments={
                        'fcu_url': 'udp://0.0.0.0:14551@',
                        'pluginlists_yaml': '$(find-pkg-share my_package)/launch/apm_pluginlists.yaml',
                    }.items()
                ),
            ]
        )
    ])

``

MAVROS version and platform

Mavros: 2.8.0 ROS: Humble Ubuntu: 22.04

Autopilot type and version

[x] ArduPilot [ ] PX4

Version: 3.7.1

Node logs

Note that actuator_control was blacklisted in my custom yaml file

[mavros_node-5] [INFO] [1720385679.795870751] [robot_0.mavros.mavros_node]: Starting mavros_node container
[mavros_node-5] [INFO] [1720385679.795969232] [robot_0.mavros.mavros_node]: FCU URL: udp://0.0.0.0:14551@
[mavros_node-5] [INFO] [1720385679.795977933] [robot_0.mavros.mavros_node]: GCS URL: 
[mavros_node-5] [INFO] [1720385679.795984608] [robot_0.mavros.mavros_node]: UAS Prefix: /uas1
[mavros_node-5] [INFO] [1720385679.795990951] [robot_0.mavros.mavros_node]: Starting mavros router node
[mavros_node-5] [INFO] [1720385679.815471449] [robot_0.mavros.mavros_router]: Built-in SIMD instructions: SSE, SSE2
[mavros_node-5] [INFO] [1720385679.815520949] [robot_0.mavros.mavros_router]: Built-in MAVLink package version: 2024.6.6
[mavros_node-5] [INFO] [1720385679.815537310] [robot_0.mavros.mavros_router]: Known MAVLink dialects: common ardupilotmega ASLUAV AVSSUAS all csAirLink cubepilot development icarous matrixpilot paparazzi standard storm32 uAvionix ualberta
[mavros_node-5] [INFO] [1720385679.815552309] [robot_0.mavros.mavros_router]: MAVROS Router started
[mavros_node-5] [INFO] [1720385679.815580152] [robot_0.mavros.mavros_router]: Requested to add endpoint: type: 0, url: udp://0.0.0.0:14551@
[mavros_node-5] [INFO] [1720385679.815622293] [robot_0.mavros.mavros_router]: Endpoint link[1000] created
[mavros_node-5] [INFO] [1720385679.816102401] [robot_0.mavros.mavros_router]: link[1000] opened successfully
[mavros_node-5] [INFO] [1720385679.816164877] [robot_0.mavros.mavros_router]: Requested to add endpoint: type: 2, url: /uas1
[mavros_node-5] [INFO] [1720385679.816185733] [robot_0.mavros.mavros_router]: Endpoint link[1001] created
[mavros_node-5] [INFO] [1720385679.820113206] [robot_0.mavros.mavros_router]: link[1001] opened successfully
[mavros_node-5] [INFO] [1720385679.820522772] [robot_0.mavros.mavros_node]: Starting mavros uas node
[mavros_node-5] [INFO] [1720385679.863569133] [robot_0.mavros.mavros]: UAS Executor started, threads: 16
[mavros_node-5] [INFO] [1720385679.881415836] [robot_0.mavros.mavros]: Plugin actuator_control created
[mavros_node-5] [INFO] [1720385679.881475818] [robot_0.mavros.mavros]: Plugin actuator_control initialized
[depth_publisher.py-3] [INFO] [1720385679.895187022] [robot_0.depth_publisher]: Initialized depth publisher
[mavros_node-5] [INFO] [1720385679.901165233] [robot_0.mavros.mavros]: Plugin adsb created
[mavros_node-5] [INFO] [1720385679.901205496] [robot_0.mavros.mavros]: Plugin adsb initialized
[mavros_node-5] [INFO] [1720385679.906910806] [robot_0.mavros.mavros]: Plugin altitude created
[mavros_node-5] [INFO] [1720385679.906949471] [robot_0.mavros.mavros]: Plugin altitude initialized

I would appreciate any help with the issue :)

itskalvik commented 4 months ago

Okay, the issue seems to be with setting a namespace. Whenever I launch the mavros node with a namespace other than 'mavros', all other parameters get ignored, and only the namespace goes into effect. I tried using both Python-based and XML-based scripts to launch mavros with a specific namespace, and I got the same result.

itskalvik commented 4 months ago

Figured it out! I had to change the first line in apm_pluginlists.yaml from 'mavros/**' to '*/mavros/**':

'*/mavros/**':
  ros__parameters:
    plugin_denylist:
      # common
      - '*'

    plugin_allowlist:
      - 'sys_*'
      - 'setpoint_position'
      - 'distance_sensor'
      - 'global_position'
      - 'imu'
      - 'command'
      - 'local_position'