ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question
2

Controller manager not available in ROS2

asked 2023-02-22 06:43:00 -0500

gurselturkeri gravatar image

updated 2023-02-28 04:01:26 -0500

I can visualize my robot on gazebo but I get an error when launch file is starting like below. How can I fix that?

robot_on_gazebo

Error:

[spawn_entity.py-2] [INFO] [1677146674.436718834] [spawn_entity]: Calling service /spawn_entity
[spawn_entity.py-2] [INFO] [1677146674.546574796] [spawn_entity]: Spawn status: SpawnEntity: Successfully spawned entity [robotic_arm]
[spawn_entity.py-2] [INFO] [1677146674.546986992] [spawn_entity]: Waiting for shutdown to delete entity [robotic_arm]
[spawner.py-5] [INFO] [1677146675.487867687] [spawner_joint_state_broadcaster]: Waiting for /controller_manager services
[spawner.py-6] [INFO] [1677146675.520714798] [spawner_joint_trajectory_controller]: Waiting for /controller_manager services
[spawner.py-5] [INFO] [1677146677.503342629] [spawner_joint_state_broadcaster]: Waiting for /controller_manager services
[spawner.py-6] [INFO] [1677146677.535238788] [spawner_joint_trajectory_controller]: Waiting for /controller_manager services
[spawner.py-5] [INFO] [1677146679.521864875] [spawner_joint_state_broadcaster]: Waiting for /controller_manager services
[spawner.py-6] [INFO] [1677146679.554316012] [spawner_joint_trajectory_controller]: Waiting for /controller_manager services
[spawner.py-5] [INFO] [1677146681.537992430] [spawner_joint_state_broadcaster]: Waiting for /controller_manager services
[spawner.py-6] [INFO] [1677146681.572181275] [spawner_joint_trajectory_controller]: Waiting for /controller_manager services
[spawner.py-5] [ERROR] [1677146683.557500368] [spawner_joint_state_broadcaster]: Controller manager not available
[spawner.py-6] [ERROR] [1677146683.591099846] [spawner_joint_trajectory_controller]: Controller manager not available
[ERROR] [spawner.py-5]: process has died [pid 18233, exit code 1, cmd '/opt/ros/foxy/lib/controller_manager/spawner.py joint_state_broadcaster --controller-manager /controller_manager --ros-args'].
[ERROR] [spawner.py-6]: process has died [pid 18235, exit code 1, cmd '/opt/ros/foxy/lib/controller_manager/spawner.py joint_trajectory_controller -c /controller_manager --ros-args'].

SOLVED: The problem was ROS2 version and changing in launch file. It works with Ubuntu 22.04 Humble and you should install all control package such as joint_trajectory_controller, joint_state_broadcaster, controller_manager, joint-state-publisher-gui then edit your launch file.

New Launch File:

from launch import LaunchDescription
from launch.actions import ExecuteProcess, IncludeLaunchDescription, RegisterEventHandler
from launch.event_handlers import OnProcessExit
from launch.launch_description_sources import PythonLaunchDescriptionSource
from launch.substitutions import Command, FindExecutable, PathJoinSubstitution
from launch_ros.actions import Node
from launch_ros.substitutions import FindPackageShare


def generate_launch_description():

    robot_description_content = Command(
        [
            PathJoinSubstitution([FindExecutable(name='xacro')]),
            ' ',
            PathJoinSubstitution(
                [FindPackageShare(
                    'robotic_arm'),
                    'urdf',
                    'robotic_arm.urdf']
            ),
        ]
    )
    robot_description = {'robot_description': robot_description_content}

    node_robot_state_publisher = Node(
        package='robot_state_publisher',
        executable='robot_state_publisher',
        output='screen',
        parameters=[robot_description]
    )

    gazebo = IncludeLaunchDescription(
        PythonLaunchDescriptionSource(
            [FindPackageShare('gazebo_ros'), '/launch', '/gazebo.launch.py']
        ),
    )

    spawn_entity = Node(package='gazebo_ros', executable='spawn_entity.py',
                        arguments=['-topic', 'robot_description',
                                   '-entity', 'joints'],
                        output='screen')

    load_joint_state_controller = ExecuteProcess(
        cmd=['ros2', 'control', 'load_controller', '--set-state', 'active',
             'joint_state_broadcaster'],
        output='screen'
    )

    load_trajectory_controller = ExecuteProcess(
        cmd=['ros2', 'control', 'load_controller', '--set-state', 'active',
             'joint_trajectory_controller'],
        output='screen'
    )



    return LaunchDescription([
        RegisterEventHandler(
          event_handler=OnProcessExit(
                target_action=spawn_entity,
                on_exit=[load_joint_state_controller],
            )
        ),
        RegisterEventHandler(
            event_handler=OnProcessExit(
                target_action=load_joint_state_controller,
                on_exit=[load_trajectory_controller],
            )
        ),

        gazebo,
        node_robot_state_publisher,
        spawn_entity,
    ])
edit retag flag offensive close merge delete

Comments

Hello,

You need to install controller manager, you can do so by executing below command in your terminal.

sudo apt-get install ros-<Your-Distro>-controller-manager
Ranjit Kathiriya gravatar image Ranjit Kathiriya  ( 2023-02-22 07:00:40 -0500 )edit

I have already installed this package.

gurselturkeri gravatar image gurselturkeri  ( 2023-02-22 07:14:56 -0500 )edit

Can you please, try running this command and share the output in the comment?

gazebo --verbose -s libgazebo_ros_factory.so

Ranjit Kathiriya gravatar image Ranjit Kathiriya  ( 2023-02-22 07:22:44 -0500 )edit

Gazebo multi-robot simulator, version 11.11.0 Copyright (C) 2012 Open Source Robotics Foundation. Released under the Apache 2 License. http://gazebosim.org

[Msg] Waiting for master.
Gazebo multi-robot simulator, version 11.11.0
Copyright (C) 2012 Open Source Robotics Foundation.
Released under the Apache 2 License.
http://gazebosim.org

[Msg] Waiting for master.
[Msg] Connected to gazebo master @ http://127.0.0.1:11345
[Msg] Publicized address: 192.168.1.224
[Msg] Loading world file [/usr/share/gazebo-11/worlds/empty.world]
[INFO] [1677072233.288940555] [gazebo_ros_node]: ROS was initialized without arguments.
[Msg] Connected to gazebo master @ http://127.0.0.1:11345
[Msg] Publicized address: 192.168.1.224
gurselturkeri gravatar image gurselturkeri  ( 2023-02-22 07:25:48 -0500 )edit

[Err] [InsertModelWidget.cc:403] Missing model.config for model "/home/gursel/autoware/install/velodyne_description/share/ament_index" [Err] [InsertModelWidget.cc:403] Missing model.config for model "/home/gursel/autoware/install/velodyne_description/share/colcon-core" [Err] [InsertModelWidget.cc:403] Missing model.config for model "/home/gursel/autoware/install/velodyne_description/share/velodyne_description" [Wrn] [Event.cc:61] Warning: Deleting a connection right after creation. Make sure to save the ConnectionPtr from a Connect call [Wrn] [Publisher.cc:135] Queue limit reached for topic /gazebo/default/user_camera/pose, deleting message. This warning is printed only once.

gurselturkeri gravatar image gurselturkeri  ( 2023-02-22 07:26:29 -0500 )edit

try to install

sudo apt-get install ros-<distro>-gazebo-ros

Ranjit Kathiriya gravatar image Ranjit Kathiriya  ( 2023-02-22 08:05:04 -0500 )edit

already installed.

gurselturkeri gravatar image gurselturkeri  ( 2023-02-22 08:14:42 -0500 )edit

That missing model config has no effect on the simulation. Its just saying that some models on the .gazebo folder dont ave that config file ( sometimes because they are packages instead of modl folders ).

Ranjit Kathiriya gravatar image Ranjit Kathiriya  ( 2023-02-23 10:37:15 -0500 )edit

1 Answer

Sort by ยป oldest newest most voted
4

answered 2023-02-28 04:33:30 -0500

Ranjit Kathiriya gravatar image

updated 2023-02-28 05:12:31 -0500

Hello there,

Thanks @gurselturkeri, for updating the launch file in the question, but I am sharing the details answer over here,

As @gurselturkeri suggested to installed joint_trajectory_controller, joint_state_broadcaster, controller_manager, joint-state-publisher-gui library.

I think you also need this below library to access gazebo controls. sudo apt-get install ros-humble-gazebo-ros2-control

About the Launch file, If you are using Ros2 Humble you need to correct

Check Which command is working in your case After installing controller-manager hit this commands in terminal ros2 run controller_manager spawner.py -h or ros2 run controller_manager spawner -h - This command is working in my case if it is so then change spawner.py to spawner in executable node.

Node(
            package="controller_manager",
            executable="spawner",   
            arguments=["joint_state_broadcaster", "--controller-manager", "/controller_manager"],
            ),
Node(
           package="controller_manager",
           executable="spawner",    
            arguments=["joint_trajectory_controller", "-c", "/controller_manager"],
            )

You can check every thing is working by executing the command into your terminal:

ros2 topic pub /joint_trajectory_controller/joint_trajectory trajectory_msgs/msg/JointTrajectory "header:
  stamp:
    sec: 0
    nanosec: 0
  frame_id: ''
joint_names: ['joint_1','joint_2','joint_4']
points: [ {"positions":[-1.57,-0.59,-1.2]} ]"

feel free to drop a comment in case it is not working.

edit flag offensive delete link more

Comments

thanks for answer it is also work clearly.

gurselturkeri gravatar image gurselturkeri  ( 2023-02-28 08:29:10 -0500 )edit

Tick the answer, so it can help others in the community.

Ranjit Kathiriya gravatar image Ranjit Kathiriya  ( 2023-02-28 08:30:27 -0500 )edit
1

Unfortunately exactly this is not working for me in ROS2 Humble.

I am ending in the exact same error as @gurselturkeri

It was working in Foxy, applied the changes mentioned by @Ranjit Kathiriya and installed all mentioned packages.

But it says controller manager not available.

RodBelaFarin gravatar image RodBelaFarin  ( 2023-03-09 05:15:23 -0500 )edit

Can you add your full error?

Ranjit Kathiriya gravatar image Ranjit Kathiriya  ( 2023-03-09 05:42:22 -0500 )edit
[spawner-5] [INFO] [1678360335.486055845] [joint_state_broadcaster_spawner]: Waiting for '/controller_manager' node to exist
[spawner-6] [ERROR] [1678360337.503889166] [diff_drive_controller_spawner]: Controller manager not available
[spawner-5] [ERROR] [1678360337.506222462] [joint_state_broadcaster_spawner]: Controller manager not available
[ERROR] [spawner-6]: process has died [pid 10538, exit code 1, cmd '/opt/ros/humble/lib/controller_manager/spawner diff_drive_controller --controller-manager /controller_manager --ros-args -r __node:=diff_drive_controller_spawner -r __ns:=/'].
[ERROR] [spawner-5]: process has died [pid 10536, exit code 1, cmd '/opt/ros/humble/lib/controller_manager/spawner joint_state_broadcaster --controller-manager /controller_manager --ros-args -r __node:=joint_state_broadcaster_spawner -r __ns:=/'].
RodBelaFarin gravatar image RodBelaFarin  ( 2023-03-09 05:53:12 -0500 )edit

Is it possible for you to create new questions and upload your code output and the rest of other details?

Ranjit Kathiriya gravatar image Ranjit Kathiriya  ( 2023-03-09 05:54:53 -0500 )edit

You can find the question right here: https://answers.ros.org/question/4132...

RodBelaFarin gravatar image RodBelaFarin  ( 2023-03-09 06:10:35 -0500 )edit

Question Tools

Stats

Asked: 2023-02-22 06:43:00 -0500

Seen: 7,155 times

Last updated: Feb 28 '23