0
$\begingroup$

Rosanswers logo

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,
    ])

Originally posted by gurselturkeri on ROS Answers with karma: 25 on 2023-02-22

Post score: 2


Original comments

Comment by Ranjit Kathiriya on 2023-02-22:
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

Comment by gurselturkeri on 2023-02-22:
I have already installed this package.

Comment by Ranjit Kathiriya on 2023-02-22:
Can you please, try running this command and share the output in the comment?

gazebo --verbose -s libgazebo_ros_factory.so

Comment by gurselturkeri on 2023-02-22:
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

Comment by gurselturkeri on 2023-02-22:
[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.

Comment by Ranjit Kathiriya on 2023-02-22:
try to install

sudo apt-get install ros--gazebo-ros

Comment by gurselturkeri on 2023-02-22:
already installed.

Comment by Ranjit Kathiriya on 2023-02-23:
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 ).

Comment by Ranjit Kathiriya on 2023-02-23:
please, share urdf and yaml file. and provide as much detail you can so to give proper answer.

Comment by Ranjit Kathiriya on 2023-02-24:\

gazebo --verbose -s libgazebo_ros_factory.so

are you able to open the gazebo?

sudo apt-get install ros-foxy-robot-state-publisher

did you install robot state publisher?

Comment by nihalar on 2023-02-28:
I have this same error, any fix?

Comment by gurselturkeri on 2023-02-28:
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.

Comment by nihalar on 2023-02-28:
Changing what in launch file?

Comment by gurselturkeri on 2023-02-28:
I have updated in question.

$\endgroup$

1 Answer 1

0
$\begingroup$

Rosanswers logo

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.


Originally posted by Ranjit Kathiriya with karma: 1622 on 2023-02-28

This answer was ACCEPTED on the original site

Post score: 4


Original comments

Comment by gurselturkeri on 2023-02-28:
thanks for answer it is also work clearly.

Comment by Ranjit Kathiriya on 2023-02-28:
Tick the answer, so it can help others in the community.

Comment by RodBelaFarin on 2023-03-09:
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.

Comment by Ranjit Kathiriya on 2023-03-09:
Can you add your full error?

Comment by RodBelaFarin on 2023-03-09:
[spawner-6] [INFO] [1678360335.484502457] [diff_drive_controller_spawner]: Waiting for '/controller_manager' node to exist [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:=/'].

Comment by Ranjit Kathiriya on 2023-03-09:
Is it possible for you to create new questions and upload your code output and the rest of other details?

Comment by RodBelaFarin on 2023-03-09:
You can find the question right here: https://answers.ros.org/question/413240/ros2-controller-manager-migration-from-foxy-to-humble-controller-manager-not-available/

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.