0
$\begingroup$

i got a problem with "Controller_manager" and i tried everything but i could not find out why it does not work i am trying to simulate a quaderocopter on Gazebo. the only thing i need now to be able to controle it with cmd or any other way. the main task for me to make it move now :( can someone help me out ?

ros2 run teleop_twist_keyboard teleop_twist_keyboard --ros-args -r /cmd_vel:=^cmd_vel

Logs:

[gzserver-2] [INFO] [1726298008.864534726] [gazebo_ros2_control]:
> Loading joint: base_to_b1 [gzserver-2] [INFO] [1726298008.865058906]
> [gazebo_ros2_control]: State: [gzserver-2] [INFO]
> [1726298008.865304843] [gazebo_ros2_control]: velocity [gzserver-2]
> [INFO] [1726298008.865550580] [gazebo_ros2_control]: Command:
> [gzserver-2] [INFO] [1726298008.865997148] [gazebo_ros2_control]:
> velocity [gzserver-2] [INFO] [1726298008.866252286]
> [gazebo_ros2_control]: Loading joint: base_to_b2 [gzserver-2] [INFO]
> [1726298008.866493223] [gazebo_ros2_control]: State: [gzserver-2]
> [INFO] [1726298008.866944491] [gazebo_ros2_control]: velocity
> [gzserver-2] [INFO] [1726298008.867187428] [gazebo_ros2_control]:
> Command: [gzserver-2] [INFO] [1726298008.867424663]
> [gazebo_ros2_control]: velocity [gzserver-2] [INFO]
> [1726298008.867673401] [gazebo_ros2_control]: Loading joint:
> base_to_b3 [gzserver-2] [INFO] [1726298008.868077262]
> [gazebo_ros2_control]: State: [gzserver-2] [INFO]
> [1726298008.868315498] [gazebo_ros2_control]: velocity [gzserver-2]
> [INFO] [1726298008.868553334] [gazebo_ros2_control]: Command:
> [gzserver-2] [INFO] [1726298008.868939592] [gazebo_ros2_control]:
> velocity [gzserver-2] [INFO] [1726298008.869187030]
> [gazebo_ros2_control]: Loading joint: base_to_b4 [gzserver-2] [INFO]
> [1726298008.869427566] [gazebo_ros2_control]: State: [gzserver-2]
> [INFO] [1726298008.869667002] [gazebo_ros2_control]: velocity
> [gzserver-2] [INFO] [1726298008.870072263] [gazebo_ros2_control]:
> Command: [gzserver-2] [INFO] [1726298008.870313200]
> [gazebo_ros2_control]: velocity [gzserver-2] [INFO]
> [1726298008.870915391] [resource_manager]: Initialize hardware
> 'GazeboSystem' [gzserver-2] [INFO] [1726298008.871324953]
> [resource_manager]: Successful initialization of hardware
> 'GazeboSystem' [gzserver-2] [INFO] [1726298008.871635000]
> [resource_manager]: 'configure' hardware 'GazeboSystem' [gzserver-2]
> [INFO] [1726298008.871980752] [resource_manager]: Successful
> 'configure' of hardware 'GazeboSystem' [gzserver-2] [INFO]
> [1726298008.872127674] [resource_manager]: 'activate' hardware
> 'GazeboSystem' [gzserver-2] [INFO] [1726298008.872273896]
> [resource_manager]: Successful 'activate' of hardware 'GazeboSystem'
> [gzserver-2] [INFO] [1726298008.872633651] [gazebo_ros2_control]:
> Loading controller_manager [gzserver-2] [WARN] [1726298008.978654374]
> [gazebo_ros2_control]: Desired controller update period (0.02 s) is
> slower than the gazebo simulation period (0.001 s). [gzserver-2]
> [INFO] [1726298008.979865557] [gazebo_ros2_control]: Loaded
> gazebo_ros2_control. [INFO] [spawner-7]: process started with pid
> [38531] [gzserver-2] [INFO] [1726298010.995336568]
> [controller_manager]: Loading controller 'joint_state_broadcaster'
> [spawner-7] [INFO] [1726298011.293255595]
> [spawner_joint_state_broadcaster]: Loaded joint_state_broadcaster
> [gzserver-2] [INFO] [1726298011.304390778] [controller_manager]:
> Configuring controller 'joint_state_broadcaster' [gzserver-2] [INFO]
> [1726298011.307354325] [joint_state_broadcaster]: 'joints' or
> 'interfaces' parameter is empty. All available state interfaces will
> be published [spawner-7] [INFO] [1726298011.404351785]
> [spawner_joint_state_broadcaster]: Configured and activated
> joint_state_broadcaster [INFO] [spawner-7]: process has finished
> cleanly [pid 38531] [gzclient-3] context mismatch in
> svga_surface_destroy [gzclient-3] context mismatch in
> svga_surface_destroy [INFO] [spawner-8]: process started with pid
> [38546] [gzserver-2] [INFO] [1726298017.129551568]
> [controller_manager]: Loading controller 'velocity_controller'
> [spawner-8] [INFO] [1726298017.465302613]
> [spawner_velocity_controller]: Loaded velocity_controller [gzserver-2]
> [INFO] [1726298017.484964485] [controller_manager]: Configuring
> controller 'velocity_controller' [gzserver-2] [INFO]
> [1726298017.499302851] [velocity_controller]: configure successful
> [gzserver-2] [INFO] [1726298017.561079988] [velocity_controller]:
> activate successful [spawner-8] [INFO] [1726298017.607934670]
> [spawner_velocity_controller]: Configured and activated
> velocity_controller [INFO] [spawner-8]: process has finished cleanly
> [pid 38546]

launch_sim.launch.py:

 import os
 from ament_index_python.packages import get_package_share_directory
 from launch import LaunchDescription
 from launch.actions import IncludeLaunchDescription, 
 DeclareLaunchArgument, 
 TimerAction
 from launch.launch_description_sources import 
 PythonLaunchDescriptionSource
 from launch_ros.actions import Node
 from launch.substitutions import LaunchConfiguration

def generate_launch_description():
package_name = 'my_bot'

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'
)

joint_state_broadcaster_spawner = Node(
    package="controller_manager",
    executable="spawner",
    arguments=["joint_state_broadcaster"],
    output="screen"
)

velocity_controller_spawner = Node(
    package="controller_manager",
    executable="spawner",
    arguments=["velocity_controller"],
    output="screen"
)

use_sim_time = LaunchConfiguration('use_sim_time')

joy_params = os.path.join(get_package_share_directory('my_bot'), 'config', 'joystick.yaml')

joy_node = Node(
    package='joy',
    executable='joy_node',
    parameters=[joy_params, {'use_sim_time': use_sim_time}],
)

teleop_node = Node(
    package='teleop_twist_joy',
    executable='teleop_node',
    name='teleop_node',
    parameters=[joy_params, {'use_sim_time': use_sim_time}],
    remappings=[('/cmd_vel','/cmd_vel')]
)

return LaunchDescription([
    rsp,
    gazebo,
    spawn_entity,

    TimerAction(
        period=5.0,
        actions=[joint_state_broadcaster_spawner]
    ),
    TimerAction(
        period=10.0,
        actions=[velocity_controller_spawner]
    ),
    DeclareLaunchArgument(
        'use_sim_time',
        default_value='false',
        description='Use sim time if true',
    ),
    joy_node,
    teleop_node,
])

drone.urdf.xacro:

<robot xmlns:xacro="http://www.ros.org/wiki/xacro">

  <gazebo>
  <plugin name="gazebo_ros2_control" filename="libgazebo_ros2_control.so">
  <robot_param>robot_description</robot_param>
  <robot_param_node>robot_state_publisher</robot_param_node>
  <parameters>/home/alba/dev_ws/src/my_bot/config/rotor_controller.yaml</parameters>
</plugin>
<ros2_control name="GazeboSystem" type="system">
<hardware>
    <plugin>gazebo_ros2_control/GazeboSystem</plugin>
</hardware>

<joint name="base_to_b1">
    <command_interface name="velocity"/>
    <state_interface name="velocity"/>
</joint>
<joint name="base_to_b2">
    <command_interface name="velocity"/>
    <state_interface name="velocity"/>
</joint>
<joint name="base_to_b3">
    <command_interface name="velocity"/>
    <state_interface name="velocity"/>
</joint>
<joint name="base_to_b4">
    <command_interface name="velocity"/>
    <state_interface name="velocity"/>
</joint>
</ros2_control>

rotor_controller.yaml:

controller_manager:
    ros__parameters:
      update_rate: 50
      joint_state_broadcaster:
       type: joint_state_broadcaster/JointStateBroadcaster
      velocity_controller:
       type: velocity_controllers/JointGroupVelocityController
       
velocity_controller:
  ros__parameters:
    joints:
      - base_to_b1
      - base_to_b2
      - base_to_b3
      - base_to_b4

joystick.yaml:

joy_node:
  ros__parameters:
    device_id: 0
    deadzone: 0.05
    autorepeat_rate: 20.0

teleop_node:
  ros__parameters:
    axis_linear:
      z: 4
      x: 1
      y: 3
    scale_linear:
      z: 2.0
      x: 5.0
      y: 5.0
    scale_linear_turbo:
      z: 5.0
      x: 10.0
      y: 10.0
    axis_angular:
      yaw: 0
    scale_angular:
      yaw: 5.0
    scale_angular_turbo: 
      yaw: 10.0
    enable_turbo_button: 1
    require_enable_button: false

i updated my code up there and my question. i am new here as you can see. so sorry for that

$\endgroup$
5
  • $\begingroup$ can you please add the full log from gazebo? The spawners can't find the CM, which is just the consequence of an earlier issue. $\endgroup$ Commented Sep 9, 2024 at 8:27
  • $\begingroup$ hi! thx for answering now. What do you mean with the log from gazebo ?. my english is not that good $\endgroup$ Commented Sep 9, 2024 at 10:24
  • $\begingroup$ exactly what you have posted above. I don't see any evidence that gazebo_ros2_control.was launched at all. which ROS distro are you using? does gazebo start and you see your robot? $\endgroup$ Commented Sep 9, 2024 at 13:38
  • $\begingroup$ i am using humble 22.04 on VMware Gazebo is working and i can see the robot (a drone) the only thing is missing that i can not controll it. i want to be able to move it with cmd command $\endgroup$ Commented Sep 9, 2024 at 19:40
  • $\begingroup$ and just to make sure i am using Ros2 with Gazebo classic. $\endgroup$ Commented Sep 10, 2024 at 6:37

2 Answers 2

0
$\begingroup$

You don't need to launch the ros2_control_node if you are using gazebo_ros2_control. Please have a look on the demos or gazebo_ros2_control_demos how to setup your project.

$\endgroup$
1
  • $\begingroup$ well i realise i did not need it so i did some changes and i could fix the errors but i still cant move my robot, tbh i dont know anymore what i have to do. so i hope someone can help me out: i tried to remapping i updated my code you might find somthing out better than me. your answer helped me out to fix the errors, thx! $\endgroup$ Commented Sep 14, 2024 at 10:33
0
$\begingroup$

I was stuck with a similar issue (although the robot was based on differential drive kinematics) a while ago and i couldn't move my robot using teleop. After a good amount of research and a long time,I figured out that my twist messages needed to be time stamped, as that's what the receiver node was expecting.

There's a package called Twist_Stamper that does exactly this. It simply takes a twist_message in and spits out one that is stamped with the current time.

twist_stamper = Node(
    package='twist_stamper',
    executable='twist_stamper',
    remappings=[
        ('/cmd_vel_in','/cmd_vel'),
        ('/cmd_vel_out','/diff_cont/cmd_vel')
    ]
)

Add the above code snippet to your launch file and remap the topics appropriately according to your code. (Don't forget to launch your node :))

Do let me know how it goes. Cheers!

$\endgroup$

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.