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

Cant launch composable node for mavros UAS #1977

Open
TitikD opened this issue Aug 21, 2024 · 1 comment
Open

Cant launch composable node for mavros UAS #1977

TitikD opened this issue Aug 21, 2024 · 1 comment

Comments

@TitikD
Copy link

TitikD commented Aug 21, 2024

Issue details

Cant launch composable node for mavros UAS. Router executing normaly. But, if I use

ros2 run rclcpp_components component_container
ros2 component load /ComponentManager mavros mavros::uas::UAS

UAS executing normaly

MAVROS version and platform

Mavros: 2.8.0
ROS: Humble
Ubuntu: 22.04

Autopilot type and version

[X] ArduPilot
[ ] PX4

Version: 4.4.0

launch.py

from launch import LaunchDescription
from launch.actions import DeclareLaunchArgument, GroupAction
from launch.substitutions import LaunchConfiguration
from launch_ros.actions import ComposableNodeContainer, Node, PushRosNamespace, SetParameter
from launch_ros.descriptions import ComposableNode
from launch_ros.substitutions import FindPackageShare

def generate_launch_description():
    return LaunchDescription([
        DeclareLaunchArgument('name', default_value='drone1', description='Name of the drone'),
        DeclareLaunchArgument('fcu_url', default_value='udp://:14550@', description='FCU URL'),
        DeclareLaunchArgument('target_system_id', default_value='1', description='Target System ID'),
        DeclareLaunchArgument('respawn', default_value='false', description='Respawn flag'),
        
        SetParameter(name='use_sim_time', value=True),
        
        GroupAction([
            PushRosNamespace([LaunchConfiguration('name')]),
            ComposableNodeContainer(
                name='drone_container',
                namespace='',
                package='rclcpp_components',
                executable='component_container',
                composable_node_descriptions=[
                    ComposableNode(
                        package='mavros',
                        plugin='mavros::uas::UAS',
                        name='uas',
                        parameters=[
                            {'fcu_system_id': 1},
                            {'fcu_component_id': 1},
                            {'target_system_id': 1},
                            {'target_component_id': 1},
                        ],
                    ),
                ],
                output='screen',
            )
        ])
    ])

Node logs

[INFO] [launch]: All log files can be found below /home/user/.ros/log/2024-08-21-19-21-20-604944-userPC-72709
[INFO] [launch]: Default logging verbosity is set to INFO
[INFO] [component_container-1]: process started with pid [72721]
[component_container-1] [INFO] [1724257280.921034423] [drone1.drone_container]: Load Library: /home/user/ws/install/mavros/lib/libmavros.so
[component_container-1] [INFO] [1724257280.925046203] [drone1.drone_container]: Found class: rclcpp_components::NodeFactoryTemplatemavros::router::Router
[component_container-1] [INFO] [1724257280.925065939] [drone1.drone_container]: Found class: rclcpp_components::NodeFactoryTemplatemavros::uas::UAS
[component_container-1] [INFO] [1724257280.925071263] [drone1.drone_container]: Instantiate class: rclcpp_components::NodeFactoryTemplatemavros::uas::UAS
[INFO] [launch_ros.actions.load_composable_nodes]: Loaded node '/drone1/uas' in container '/drone1/drone_container'
[component_container-1] [INFO] [1724257280.955756120] [drone1.uas]: UAS Executor started, threads: 8
[component_container-1] [WARN] [1724257280.970039682] [rcl.logging_rosout]: Publisher already registered for provided node name. If this is due to multiple nodes with the same name then all logs for that logger name will go out over the existing publisher. As soon as any node with that name is destructed it will unregister the publisher, preventing any further logs for that name from being published on the rosout topic.
[component_container-1] [INFO] [1724257280.975013416] [drone1.uas]: Plugin actuator_control created
[component_container-1] [INFO] [1724257280.975380509] [drone1.uas]: Plugin actuator_control initialized
[component_container-1] [WARN] [1724257280.993841374] [rcl.logging_rosout]: Publisher already registered for provided node name. If this is due to multiple nodes with the same name then all logs for that logger name will go out over the existing publisher. As soon as any node with that name is destructed it will unregister the publisher, preventing any further logs for that name from being published on the rosout topic.
[component_container-1] [INFO] [1724257280.998305931] [drone1.uas]: Plugin adsb created
[component_container-1] [INFO] [1724257280.998557399] [drone1.uas]: Plugin adsb initialized
[component_container-1] [WARN] [1724257280.998753550] [rcl.logging_rosout]: Publisher already registered for provided node name. If this is due to multiple nodes with the same name then all logs for that logger name will go out over the existing publisher. As soon as any node with that name is destructed it will unregister the publisher, preventing any further logs for that name from being published on the rosout topic.
[component_container-1] [INFO] [1724257281.001555588] [drone1.uas]: Plugin altitude created
[component_container-1] [INFO] [1724257281.001694836] [drone1.uas]: Plugin altitude initialized
[component_container-1] [WARN] [1724257281.001871939] [rcl.logging_rosout]: Publisher already registered for provided node name. If this is due to multiple nodes with the same name then all logs for that logger name will go out over the existing publisher. As soon as any node with that name is destructed it will unregister the publisher, preventing any further logs for that name from being published on the rosout topic.
[component_container-1] [INFO] [1724257281.004328939] [drone1.uas]: Plugin cam_imu_sync created
[component_container-1] [INFO] [1724257281.004451477] [drone1.uas]: Plugin cam_imu_sync initialized
[component_container-1] [WARN] [1724257281.004605726] [rcl.logging_rosout]: Publisher already registered for provided node name. If this is due to multiple nodes with the same name then all logs for that logger name will go out over the existing publisher. As soon as any node with that name is destructed it will unregister the publisher, preventing any further logs for that name from being published on the rosout topic.
[component_container-1] [INFO] [1724257281.007185847] [drone1.uas]: Plugin camera created
[component_container-1] [INFO] [1724257281.007310529] [drone1.uas]: Plugin camera initialized
[component_container-1] [WARN] [1724257281.007470617] [rcl.logging_rosout]: Publisher already registered for provided node name. If this is due to multiple nodes with the same name then all logs for that logger name will go out over the existing publisher. As soon as any node with that name is destructed it will unregister the publisher, preventing any further logs for that name from being published on the rosout topic.
[component_container-1] [INFO] [1724257281.010718948] [drone1.uas]: Plugin cellular_status created
[component_container-1] [INFO] [1724257281.010751379] [drone1.uas]: Plugin cellular_status initialized
[component_container-1] [WARN] [1724257281.010936277] [rcl.logging_rosout]: Publisher already registered for provided node name. If this is due to multiple nodes with the same name then all logs for that logger name will go out over the existing publisher. As soon as any node with that name is destructed it will unregister the publisher, preventing any further logs for that name from being published on the rosout topic.
[component_container-1] [INFO] [1724257281.019837218] [drone1.uas]: Plugin command created
[component_container-1] [INFO] [1724257281.020011255] [drone1.uas]: Plugin command initialized
[component_container-1] [WARN] [1724257281.020252122] [rcl.logging_rosout]: Publisher already registered for provided node name. If this is due to multiple nodes with the same name then all logs for that logger name will go out over the existing publisher. As soon as any node with that name is destructed it will unregister the publisher, preventing any further logs for that name from being published on the rosout topic.
[component_container-1]
[component_container-1] >>> [rcutils|error_handling.c:108] rcutils_set_error_state()
[component_container-1] This error state is being overwritten:
[component_container-1]
[component_container-1] 'create_subscription() called for existing topic name rt/drone1/drone_container/status with incompatible type mavros_msgs::msg::dds_::CompanionProcessStatus_, at ./src/subscription.cpp:146, at ./src/rcl/subscription.c:109'
[component_container-1]
[component_container-1] with this new error message:
[component_container-1]
[component_container-1] 'invalid allocator, at ./src/rcl/subscription.c:219'
[component_container-1]
[component_container-1] rcutils_reset_error() should be called after error handling to avoid this.
[component_container-1] <<<
[component_container-1] invalid allocator, at ./src/rcl/subscription.c:219
[component_container-1] terminate called after throwing an instance of 'rclcpp::exceptions::RCLError'
[component_container-1] what(): could not create subscription: invalid allocator, at ./src/rcl/subscription.c:219
[ERROR] [component_container-1]: process has died [pid 72721, exit code -6, cmd '/opt/ros/humble/lib/rclcpp_components/component_container --ros-args -r __node:=drone_container -r __ns:=/drone1 -p use_sim_time:=True'].

@TitikD TitikD changed the title Cant create composable node for mavros UAS Cant launch composable node for mavros UAS Aug 21, 2024
@astomnbkn
Copy link

astomnbkn commented Aug 28, 2024

I have the same issue. Does anyone know how to resolve this?

Using composable node from libmavros or custom container node implementation including one Router and two UAS,
either way launching ends up in the same error of node name and topic names screwd up with 'image_container' token.
I don't think having two UAS nodes is relavant in latter case.
Using python launch file or xml launch file gives the same situation.
And the existance of Router node does not affect the situation neither.

I know that using 'ros2 component load' to load UAS comoposable node works. However it leaves plugin configuration messy and imperfect. Using launch mechanisms is much prefered.

Right after launch failes, node list and topic list shows somehting like below.
And launch.py and logs are attached below from the former case launching 1 UAS.
Note that component container is run before launching to load UAS into the container.

$ ros2 node list
WARNING: Be aware that there are nodes in the graph that share an exact name, which can have unintended side effects.
/ComponentManager
/image_container
/mavros1
/mavros1/image_container
/mavros1/image_container
/mavros1/image_container
/mavros1/image_container
/mavros1/image_container
/mavros1/image_container
/mavros1/image_container
/mavros1/image_container
/transform_listener_impl_5a6614445e58
$ ros2 topic list
/diagnostics
/mavros1/actuator_control
/mavros1/altitude
/mavros1/image_container/cam_imu_stamp
/mavros1/image_container/image_captured
/mavros1/image_container/send
/mavros1/image_container/status
/mavros1/image_container/vehicle
/mavros1/target_actuator_control
/parameter_events
/rosout
/tf
/tf_static

launch.py

from launch import LaunchDescription
from launch_ros.actions import LoadComposableNodes, Node
from launch_ros.descriptions import ComposableNode
from launch_ros.actions import PushROSNamespace
from launch.actions import GroupAction

def generate_launch_description():
    container = Node(
        name='image_container',
        package='rclcpp_components',
        executable='component_container',
        output='both',
    )

    pluginlists_yaml = "/opt/ros/iron/share/mavros/launch/apm_pluginlists.yaml"
    config_yaml = "/opt/ros/iron/share/mavros/launch/apm_config.yaml"

    params1 = {
        "target_system_id": 1,
        "target_component_id": 1,
        "system_id": 1,
        "component_id": 191,
        "uas_url": "/uas1",
        "log_output": "screen",
        "fcu_protocol": "v2.0"
    }

    load_composable_nodes = LoadComposableNodes(
        target_container='image_container',
        composable_node_descriptions=[
            ComposableNode(
                package='mavros',
                plugin='mavros::uas::UAS',
                name='mavros1',
                parameters=[params1, pluginlists_yaml, config_yaml],
            ),
        ],
    )

    return LaunchDescription([container,
                              load_composable_nodes])

Launch log

[INFO] [launch]: All log files can be found below /home/nobukuni/.ros/log/2024-08-28-14-28-00-929710-kubota-dev-160842
[INFO] [launch]: Default logging verbosity is set to INFO
[INFO] [component_container-1]: process started with pid [160857]
[component_container-1] [INFO] [1724822881.888900473] [image_container]: Load Library: /opt/ros/iron/lib/libmavros.so
[component_container-1] [INFO] [1724822881.911132002] [image_container]: Found class: rclcpp_components::NodeFactoryTemplate<mavros::router::Router>
[component_container-1] [INFO] [1724822881.911567730] [image_container]: Found class: rclcpp_components::NodeFactoryTemplate<mavros::uas::UAS>
[component_container-1] [INFO] [1724822881.911606401] [image_container]: Instantiate class: rclcpp_components::NodeFactoryTemplate<mavros::uas::UAS>
[INFO] [launch_ros.actions.load_composable_nodes]: Loaded node '/mavros1' in container 'image_container'
[component_container-1] [INFO] [1724822881.991150923] [mavros1]: UAS Executor started, threads: 4
[component_container-1] [INFO] [1724822882.027705973] [mavros1]: Plugin actuator_control created
[component_container-1] [INFO] [1724822882.027872018] [mavros1]: Plugin actuator_control initialized
[component_container-1] [WARN] [1724822882.048211773] [rcl.logging_rosout]: Publisher already registered for provided node name. If this is due to multiple nodes with the same name then all logs for that logger name will go out over the existing publisher. As soon as any node with that name is destructed it will unregister the publisher, preventing any further logs for that name from being published on the rosout topic.
[component_container-1] [INFO] [1724822882.064992758] [mavros1]: Plugin adsb created
[component_container-1] [INFO] [1724822882.065132785] [mavros1]: Plugin adsb initialized
[component_container-1] [WARN] [1724822882.065625212] [rcl.logging_rosout]: Publisher already registered for provided node name. If this is due to multiple nodes with the same name then all logs for that logger name will go out over the existing publisher. As soon as any node with that name is destructed it will unregister the publisher, preventing any further logs for that name from being published on the rosout topic.
[component_container-1] [INFO] [1724822882.081200521] [mavros1]: Plugin altitude created
[component_container-1] [INFO] [1724822882.081849185] [mavros1]: Plugin altitude initialized
[component_container-1] [WARN] [1724822882.083296702] [rcl.logging_rosout]: Publisher already registered for provided node name. If this is due to multiple nodes with the same name then all logs for that logger name will go out over the existing publisher. As soon as any node with that name is destructed it will unregister the publisher, preventing any further logs for that name from being published on the rosout topic.
[component_container-1] [INFO] [1724822882.099430909] [mavros1]: Plugin cam_imu_sync created
[component_container-1] [INFO] [1724822882.099568864] [mavros1]: Plugin cam_imu_sync initialized
[component_container-1] [WARN] [1724822882.099935698] [rcl.logging_rosout]: Publisher already registered for provided node name. If this is due to multiple nodes with the same name then all logs for that logger name will go out over the existing publisher. As soon as any node with that name is destructed it will unregister the publisher, preventing any further logs for that name from being published on the rosout topic.
[component_container-1] [INFO] [1724822882.119291562] [mavros1]: Plugin camera created
[component_container-1] [INFO] [1724822882.119405492] [mavros1]: Plugin camera initialized
[component_container-1] [WARN] [1724822882.119704387] [rcl.logging_rosout]: Publisher already registered for provided node name. If this is due to multiple nodes with the same name then all logs for that logger name will go out over the existing publisher. As soon as any node with that name is destructed it will unregister the publisher, preventing any further logs for that name from being published on the rosout topic.
[component_container-1] [INFO] [1724822882.138430293] [mavros1]: Plugin cellular_status created
[component_container-1] [INFO] [1724822882.138537973] [mavros1]: Plugin cellular_status initialized
[component_container-1] [WARN] [1724822882.138762899] [rcl.logging_rosout]: Publisher already registered for provided node name. If this is due to multiple nodes with the same name then all logs for that logger name will go out over the existing publisher. As soon as any node with that name is destructed it will unregister the publisher, preventing any further logs for that name from being published on the rosout topic.
[component_container-1] [INFO] [1724822882.162998144] [mavros1]: Plugin command created
[component_container-1] [INFO] [1724822882.163124715] [mavros1]: Plugin command initialized
[component_container-1] [WARN] [1724822882.163451381] [rcl.logging_rosout]: Publisher already registered for provided node name. If this is due to multiple nodes with the same name then all logs for that logger name will go out over the existing publisher. As soon as any node with that name is destructed it will unregister the publisher, preventing any further logs for that name from being published on the rosout topic.
[component_container-1]
[component_container-1] >>> [rcutils|error_handling.c:108] rcutils_set_error_state()
[component_container-1] This error state is being overwritten:
[component_container-1]
[component_container-1]   'create_subscription() called for existing topic name rt/mavros1/image_container/status with incompatible type mavros_msgs::msg::dds_::CompanionProcessStatus_, at ./src/subscription.cpp:517, at ./src/rcl/subscription.c:112'
[component_container-1]
[component_container-1] with this new error message:
[component_container-1]
[component_container-1]   'invalid allocator, at ./src/rcl/subscription.c:261'
[component_container-1]
[component_container-1] rcutils_reset_error() should be called after error handling to avoid this.
[component_container-1] <<<
[component_container-1] invalid allocator, at ./src/rcl/subscription.c:261
[component_container-1] terminate called after throwing an instance of 'rclcpp::exceptions::RCLError'
[component_container-1]   what():  could not create subscription: invalid allocator, at ./src/rcl/subscription.c:261
[ERROR] [component_container-1]: process has died [pid 160857, exit code -6, cmd '/opt/ros/iron/lib/rclcpp_components/component_container --ros-args -r __node:=image_container'].

MAVROS version and platform

Mavros: 2.8.0
ROS: Iron
Ubuntu: 22.04

Autopilot type and version

[X] ArduPilot
[ ] PX4

Version: 4.5.1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants