0
$\begingroup$

So I am new to ros2 and ros2_control. I am projecting a wheelchair with a rotating 2d LiDAR, to make a cheap 3d LiDAR. My problem is, I cannot solve the controller manager issue with the rotating LiDAR, i have looked in multiple tutorials and this problem doesn't go away. I started testing just the controller manager and it doesn't seem to work, even though I have installed all the necessaries packages.

I ran this on my terminal

ros2 run controller_manager spawner joint_trajectory_controller

and this was the result

$ ros2 run controller_manager spawner joint_trajectory_controller
[INFO] [1718035424.759147266] [spawner_joint_trajectory_controller]: Waiting for '/controller_manager' node to exist
[INFO] [1718035426.783524107] [spawner_joint_trajectory_controller]: Waiting for '/controller_manager' node to exist
[INFO] [1718035428.808219884] [spawner_joint_trajectory_controller]: Waiting for '/controller_manager' node to exist
[INFO] [1718035430.832621980] [spawner_joint_trajectory_controller]: Waiting for '/controller_manager' node to exist
[ERROR] [1718035432.856900297] [spawner_joint_trajectory_controller]: Controller manager not available
[ros2run]: Process exited with failure 1

this is the code i am using for ros2_control:

controller_manager:
  ros__parameters:
    update_rate: 30
    use_sim_time: true

    joint_trajectory_controller:
      type: joint_trajectory_controller/JointTrajectoryController
    
    joint_state_broadcaster:
      type: joint_state_broadcaster/JointStateBroadcaster
    
joint_trajectory_controller:
  ros__parameters:
    joints:
      - MotorLidar
    command_interfaces:
      - position
    state_interfaces:
      - position
      - effort
      - velocity

    state_publish_rate: 30.0
<?xml version="1.0"?>
<robot xmlns:xacro="http://www.ros.org/wiki/xacro">

    <ros2_control name="GazeboSystem" type="system">
        <hardware>
            <plugin>gazebo_ros2_control/GazeboSystem</plugin>
        </hardware>

        <joint name="MotorLidar">
            <command_interface name="position">
                <param name="min">-2</param>
                <param name="max">2</param>
                <param name="initial_value">0</param>
            </command_interface>
            <state_interface name="position" />
            <state_interface name="velocity" />
            <state_interface name="effort" />
        </joint>
    </ros2_control>

    <gazebo>
        <plugin name="diff_drive" filename="libgazebo_ros_diff_drive.so">

            <!-- Wheel Information -->
            <left_joint>MotorEsquerdo</left_joint>
            <right_joint>MotorDireito</right_joint>
            <wheel_separation>0.15</wheel_separation>
            <wheel_diameter>0.4</wheel_diameter>


            <!-- Limits -->
            <max_wheel_torque>100</max_wheel_torque>
            <max_wheel_acceleration>2.0</max_wheel_acceleration>

            
            <!-- Output -->
            <odometry_frame>odom</odometry_frame>
            <robot_base_frame>robot_base</robot_base_frame>

            <publish_odom>true</publish_odom>
            <publish_odom_tf>true</publish_odom_tf>
            <publish_wheel_tf>true</publish_wheel_tf>

        </plugin>
    </gazebo>

    <gazebo>
        <plugin filename="libgazebo_ros2_control" name="gazebo_ros2_control" >
            <parameters>$(find cadeira)/config/joint_controller.yaml</parameters>
        </plugin>
    </gazebo>

</robot>

this is my launch file:


import os

from ament_index_python.packages import get_package_share_directory


from launch import LaunchDescription
from launch.actions import IncludeLaunchDescription, ExecuteProcess
from launch.launch_description_sources import PythonLaunchDescriptionSource

from launch_ros.actions import Node



def generate_launch_description():

    package_name='cadeira' 

    rsp = IncludeLaunchDescription(
                PythonLaunchDescriptionSource([os.path.join(
                    get_package_share_directory(package_name),'launch','rsp.launch.py'
                )]), launch_arguments={'use_sim_time': 'true'}.items()
    )
    
    gazebo = IncludeLaunchDescription(
                PythonLaunchDescriptionSource([os.path.join(
                    get_package_share_directory('gazebo_ros'), 'launch', 'gazebo.launch.py')]),
             )

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

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


    # Launch them all!
    return LaunchDescription([
        rsp,
        gazebo,
        spawn_entity,
        load_joint_state_broadcaster,
        load_joint_trajectory_controller
    ])

and this is the output I get when a launch it:


$ ros2 launch cadeira launch_sim.launch.py 
[INFO] [launch]: All log files can be found below /home/ic/.ros/log/2024-06-11-13-05-54-777817-ic-Nitro-AN515-51-8442
[INFO] [launch]: Default logging verbosity is set to INFO
[INFO] [robot_state_publisher-1]: process started with pid [8446]
[INFO] [gzserver-2]: process started with pid [8448]
[INFO] [gzclient-3]: process started with pid [8450]
[INFO] [spawn_entity.py-4]: process started with pid [8452]
[INFO] [ros2-5]: process started with pid [8454]
[INFO] [ros2-6]: process started with pid [8456]
[robot_state_publisher-1] [INFO] [1718121956.453071547] [robot_state_publisher]: got segment ApoioBracoDireito
[robot_state_publisher-1] [INFO] [1718121956.453273800] [robot_state_publisher]: got segment ApoioBracoEsquerdo
[robot_state_publisher-1] [INFO] [1718121956.453294493] [robot_state_publisher]: got segment ApoioCostas
[robot_state_publisher-1] [INFO] [1718121956.453305103] [robot_state_publisher]: got segment ApoioLidar
[robot_state_publisher-1] [INFO] [1718121956.453313870] [robot_state_publisher]: got segment BaseDireita
[robot_state_publisher-1] [INFO] [1718121956.453322761] [robot_state_publisher]: got segment BaseEsquerda
[robot_state_publisher-1] [INFO] [1718121956.453332115] [robot_state_publisher]: got segment ColunaDireitaDianteira_2
[robot_state_publisher-1] [INFO] [1718121956.453341919] [robot_state_publisher]: got segment ColunaDireitaTraseira
[robot_state_publisher-1] [INFO] [1718121956.453351422] [robot_state_publisher]: got segment ColunaEsquerdaDianteira
[robot_state_publisher-1] [INFO] [1718121956.453360727] [robot_state_publisher]: got segment ColunaEsquerdaTraseira
[robot_state_publisher-1] [INFO] [1718121956.453369943] [robot_state_publisher]: got segment Lidar
[robot_state_publisher-1] [INFO] [1718121956.453379442] [robot_state_publisher]: got segment RodaDireitaDianteira
[robot_state_publisher-1] [INFO] [1718121956.453388548] [robot_state_publisher]: got segment RodaDireitaTraseira
[robot_state_publisher-1] [INFO] [1718121956.453398134] [robot_state_publisher]: got segment RodaEsquerdaDianteira
[robot_state_publisher-1] [INFO] [1718121956.453406878] [robot_state_publisher]: got segment RodaEsquerdaTraseira
[robot_state_publisher-1] [INFO] [1718121956.453415503] [robot_state_publisher]: got segment base_link
[robot_state_publisher-1] [INFO] [1718121956.453423873] [robot_state_publisher]: got segment robot_base
[spawn_entity.py-4] [INFO] [1718121956.961788878] [spawn_entity]: Spawn Entity started
[spawn_entity.py-4] [INFO] [1718121956.962362076] [spawn_entity]: Loading entity published on topic robot_description
[spawn_entity.py-4] /opt/ros/iron/lib/python3.10/site-packages/rclpy/qos.py:313: UserWarning: DurabilityPolicy.RMW_QOS_POLICY_DURABILITY_TRANSIENT_LOCAL is deprecated. Use DurabilityPolicy.TRANSIENT_LOCAL instead.
[spawn_entity.py-4]   warnings.warn(
[spawn_entity.py-4] [INFO] [1718121956.965476395] [spawn_entity]: Waiting for entity xml on robot_description
[spawn_entity.py-4] [INFO] [1718121956.976774027] [spawn_entity]: Waiting for service /spawn_entity, timeout = 30
[spawn_entity.py-4] [INFO] [1718121956.977335027] [spawn_entity]: Waiting for service /spawn_entity
[spawn_entity.py-4] [INFO] [1718121957.985194296] [spawn_entity]: Calling service /spawn_entity
[spawn_entity.py-4] [INFO] [1718121958.353158646] [spawn_entity]: Spawn status: SpawnEntity: Successfully spawned entity [my_bot]
[gzserver-2] [INFO] [1718121958.392211503] [diff_drive]: Wheel pair 1 separation set to [0.150000m]
[gzserver-2] [INFO] [1718121958.392816441] [diff_drive]: Wheel pair 1 diameter set to [0.400000m]
[gzserver-2] [INFO] [1718121958.395233565] [diff_drive]: Subscribed to [/cmd_vel]
[gzserver-2] [INFO] [1718121958.403905390] [diff_drive]: Advertise odometry on [/odom]
[gzserver-2] [INFO] [1718121958.411997170] [diff_drive]: Publishing odom transforms between [odom] and [robot_base]
[gzserver-2] [INFO] [1718121958.412046172] [diff_drive]: Publishing wheel transforms between [robot_base], [MotorEsquerdo] and [MotorDireito]
[INFO] [spawn_entity.py-4]: process has finished cleanly [pid 8452]
[ros2-6] Could not contact service /controller_manager/load_controller
[ros2-5] Could not contact service /controller_manager/load_controller
[ERROR] [ros2-6]: process has died [pid 8456, exit code 1, cmd 'ros2 control load_controller --set-state active joint_trajectory_controller'].
[ERROR] [ros2-5]: process has died [pid 8454, exit code 1, cmd 'ros2 control load_controller --set-state active joint_state_broadcaster'].


github with all my files: https://github.com/Victorms4/ic-cadeira.git

$\endgroup$
4
  • 1
    $\begingroup$ Please add the whole console output. Typically, the error happened earlier and the Waiting for 'controller_manager' node to exist is only a result of that. $\endgroup$ Commented Jun 7 at 10:51
  • $\begingroup$ That is the whole console output. I tried posting a printscreen but it doesn't seem to be loading, however I did update the console output and didn't left my own input this time. $\endgroup$ Commented Jun 10 at 16:13
  • $\begingroup$ OK you are calling the spawner only. But what about the console output when you launch your model in gazebo classic? it seems that gazebo_ros2_control was not loaded properly. $\endgroup$ Commented Jun 11 at 5:41
  • $\begingroup$ I edited in the whole console output and my launch file. The model is being properly loaded. To my knowledge I am having problems only with ros2_control and the controller_manager. Thanks for your patience, I appreciate any help! $\endgroup$ Commented Jun 11 at 16:11

1 Answer 1

0
$\begingroup$

There is not a single log output from gazebo_ros2_control.

By comparing your URDF with the demos, the only difference I see now is the filename: Can you try filename="libgazebo_ros2_control.so" instead?

$\endgroup$
1
  • $\begingroup$ It worked! After i changed that, the error logs became more clear, and I was able to correct other errors in my code. Thank you for your help and for your time! $\endgroup$ Commented Jun 12 at 17:50

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.