I have a similar behaviour, trying to modify the panda simulation tutorial.
After changing to joint_state_broadcaster and adding the other controllers gazebo prompting controllers configured successfully and after a little while the joints goes wild.
my launch file as follows for the panda simulation:
# panda_simulation.launch.py:
# Launch file for the Panda Robot GAZEBO SIMULATION in ROS2 Foxy: ->ported to Humble (Experimental)
# Import libraries:
import os
from ament_index_python.packages import get_package_share_directory
from launch import LaunchDescription
from launch_ros.actions import Node
from launch.actions import ExecuteProcess, IncludeLaunchDescription, RegisterEventHandler
from launch.event_handlers import OnProcessExit
from launch.launch_description_sources import PythonLaunchDescriptionSource
import xacro
import yaml
# LOAD FILE:
def load_file(package_name, file_path):
package_path = get_package_share_directory(package_name)
absolute_file_path = os.path.join(package_path, file_path)
try:
with open(absolute_file_path, 'r') as file:
return file.read()
except EnvironmentError:
# parent of IOError, OSError *and* WindowsError where available.
return None
# LOAD YAML:
def load_yaml(package_name, file_path):
package_path = get_package_share_directory(package_name)
absolute_file_path = os.path.join(package_path, file_path)
try:
with open(absolute_file_path, 'r') as file:
return yaml.safe_load(file)
except EnvironmentError:
# parent of IOError, OSError *and* WindowsError where available.
return None
# ========== **GENERATE LAUNCH DESCRIPTION** ========== #
def generate_launch_description():
# ***** GAZEBO ***** #
# DECLARE Gazebo WORLD file:
panda_ros2_gazebo = os.path.join(
get_package_share_directory('panda_ros2_gazebo'),
'worlds',
'panda.world')
# DECLARE Gazebo LAUNCH file:
gazebo = IncludeLaunchDescription(
PythonLaunchDescriptionSource([os.path.join(
get_package_share_directory('gazebo_ros'), 'launch'), '/gazebo.launch.py']),
launch_arguments={'world': panda_ros2_gazebo}.items(),
)
# ***** ROBOT DESCRIPTION ***** #
# PANDA Description file package:
panda_description_path = os.path.join(
get_package_share_directory('panda_ros2_gazebo'))
# PANDA ROBOT urdf file path:
xacro_file = os.path.join(panda_description_path,
'urdf',
'panda.urdf.xacro')
# Generate ROBOT_DESCRIPTION for PANDA:
doc = xacro.parse(open(xacro_file))
xacro.process_doc(doc)
robot_description_config = doc.toxml()
robot_description = {'robot_description': robot_description_config}
# ROBOT STATE PUBLISHER NODE:
node_robot_state_publisher = Node(
package='robot_state_publisher',
executable='robot_state_publisher',
output='screen',
parameters=[robot_description]
)
# Static TF:
static_tf = Node(
package="tf2_ros",
executable="static_transform_publisher",
name="static_transform_publisher",
output="log",
arguments=["0.0", "0.0", "0.0", "0.0", "0.0", "0.0", "world", "base_link"],
)
# SPAWN ROBOT TO GAZEBO:
spawn_entity = Node(package='gazebo_ros', executable='spawn_entity.py',
arguments=['-topic', 'robot_description',
'-entity', 'panda'],
output='screen')
# ***** CONTROLLERS ***** #
# Joint STATE Controller:
#load_joint_state_controller = ExecuteProcess(
# cmd=['ros2', 'control', 'load_start_controller', 'joint_state_controller'],
# output='screen'
#)
joint_state_broadcaster_spawner = Node(
package="controller_manager",
executable="spawner",
arguments=["joint_state_broadcaster", "--controller-manager", "/controller_manager"],
)
# Joint TRAJECTORY Controller2:
joint_trajectory_arm_controller_spawner = Node(
package="controller_manager",
executable="spawner",
arguments=["panda_arm_controller", "-c", "/controller_manager"],
)
# panda_handleft_controller
joint_handleft_controller_spawner = Node(
package="controller_manager",
executable="spawner",
arguments=["panda_handleft_controller", "-c", "/controller_manager"],
)
# panda_handright_controller
joint_handright_controller_spawner = Node(
package="controller_manager",
executable="spawner",
arguments=["panda_handright_controller", "-c", "/controller_manager"],
)
# ***** RETURN LAUNCH DESCRIPTION ***** #
return LaunchDescription([
gazebo,
spawn_entity,
node_robot_state_publisher,
static_tf,
RegisterEventHandler(
OnProcessExit(
target_action = spawn_entity,
on_exit = [
joint_state_broadcaster_spawner,
]
)
),
RegisterEventHandler(
OnProcessExit(
target_action = joint_state_broadcaster_spawner,
on_exit = [
joint_trajectory_arm_controller_spawner,
joint_handleft_controller_spawner,
joint_handright_controller_spawner
]
)
),
])