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

Position controller causing model to jump around in Gazebo

asked 2023-02-14 12:12:54 -0500

bigblue gravatar image

updated 2023-02-14 12:15:13 -0500

Hello,

I am using ROS Humble on Ubuntu 22.04 with Gazebo 11.10.2 and the MoveIt2 package. When I launch the MoveIt! controller, the robot starts to drift slowly and then more wildly without any input commands. The issue only occurs when I launch the MoveIt! controller.

https://ibb.co/nL412St

When the robot starts to drift, there are no error messages or warning messages printed to the console or log files. I also wasn't seeing this issue when using Foxy but I cant switch back as I need some of the features Humble supports.

When I exclude the controller from my launch file, the arm just swings around as I'd expect, so I'm guessing that the issue lies with the position controller some issue with my gazebo version.

I am using the controller configuration file here:

ros__parameters:

update_rate: 60 

joint_state_broadcaster:
  type: joint_state_broadcaster/JointStateBroadcaster

position_trajectory_controller:
  type: joint_trajectory_controller/JointTrajectoryController

forward_position_controller:
  type: position_controllers/JointGroupPositionController #forward_command_controller/ForwardCommandController

position_trajectory_controller:
  ros__parameters:
    joints:
      - waist
      - shoulder
      - elbow
      - wrist_rotation
      - wrist_flex
      - hand_roll
    command_interfaces:
      - position

    state_interfaces:
      - position
      - velocity

    state_publish_rate: 100.0 # Defaults to 50
    action_monitor_rate: 20.0 # Defaults to 20

forward_position_controller:
  ros__parameters:
    joints:
      - waist
      - shoulder
      - elbow
      - wrist_rotation
      - wrist_flex
      - hand_roll
interface_name: position

Any help would be greatly appreciated.

I have also included my platform information here:

Repo: https://github.com/NWalker4483/merlin/tree/foxy
OS: Ubuntu 22.04
Architecture: x86_64
ROS Version: Humble
Gazebo Version: 11.10.2

Thank you.

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
0

answered 2023-03-04 18:34:39 -0500

airbutt gravatar image

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


    ])
edit flag offensive delete link more

Question Tools

1 follower

Stats

Asked: 2023-02-14 12:12:54 -0500

Seen: 545 times

Last updated: Feb 14 '23