0
$\begingroup$

I keep getting the following error and I'm unsure what I'm doing wrong, any direction would be much appreciated. enter image description here

I've used moveit setup assistant to get me going initially.

The following is my launch file:

import os
from ament_index_python.packages import get_package_share_directory
from launch import LaunchDescription
from launch.actions import ExecuteProcess, DeclareLaunchArgument
from launch_ros.actions import Node
import yaml
import xacro



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:
        return None

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:
        return None

def generate_launch_description():
    package_share_dir = get_package_share_directory("kuka_kr210_arm")
    urdf_file = os.path.join(package_share_dir, "urdf", "kr210_.urdf")
    controller_file = os.path.join(package_share_dir, "config", "jtc.yaml")
    kinematics_yaml = load_yaml("kuka_kr210_arm", "config/kinematics.yaml")
    trajectory_execution = {
        "moveit_manage_controllers": True,
        "trajectory_execution.allowed_execution_duration_scaling": 1.2,
        "trajectory_execution.allowed_goal_duration_margin": 0.5,
        "trajectory_execution.allowed_start_tolerance": 0.01,
    }
    moveit_simple_controllers_yaml = load_yaml("kuka_kr210_arm", "config/moveit_controllers.yaml")
    moveit_controllers = {
        "moveit_simple_controller_manager": moveit_simple_controllers_yaml,
        "moveit_controller_manager": "moveit_simple_controller_manager/MoveItSimpleControllerManager",
    }
    kuka_description_path = os.path.join(
        get_package_share_directory('kuka_kr210_arm'))
    xacro_file = os.path.join(kuka_description_path,
                              'urdf',
                              'kr210.urdf.xacro')
    doc = xacro.process_file(xacro_file)
    robot_description_config = doc.toxml()
    robot_description_moveit = {'robot_description': robot_description_config}
    robot_description_semantic_config = load_file("kuka_kr210_arm", "config/kuka_kr210_arm.srdf")
    robot_description_semantic = {"robot_description_semantic": robot_description_semantic_config}
    planning_scene_monitor_parameters = {
        "publish_planning_scene": True,
        "publish_geometry_updates": True,
        "publish_state_updates": True,
        "publish_transforms_updates": True,
        "publish_robot_description": True,
        "publish_robot_description_semantic": True
    }
    with open(urdf_file, 'r') as infp:
        robot_description = infp.read()
    return LaunchDescription(
        [
            ExecuteProcess(
                cmd=["gazebo","--verbose","-s","libgazebo_ros_factory.so",],
                output="screen",
            ),
            Node(
                package="gazebo_ros",
                executable="spawn_entity.py",
                arguments=["-entity","kuka_kr210_arm","-b","-file", urdf_file,],
            ),
            Node(
                package="robot_state_publisher",
                executable="robot_state_publisher",
                output="screen",
                parameters=[{'robot_description': robot_description}],
                arguments=[urdf_file],
            ),
            
            Node(
                package="controller_manager",
                executable="ros2_control_node",
                parameters=[urdf_file, controller_file],
                output={
                    "stdout": "screen",
                    "stderr": "screen",
                },
            ),
            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"],
            ),
            Node(
                package="kuka_kr210_arm",
                executable="kuka_kr210_arm",
                parameters=["publish_robot_description", "publish_robot_description_semantic"]
            ),
            Node(
                package="moveit_ros_move_group",
                executable="move_group",
                output="screen",
                parameters=[
                    robot_description_moveit,
                    robot_description_semantic,
                    kinematics_yaml,
                    trajectory_execution,
                    moveit_controllers,
                    planning_scene_monitor_parameters,
                    ]
            )
        ]
    )

Thank you.

$\endgroup$

1 Answer 1

1
$\begingroup$

I'm not sure but I would suggest to use OMPL rather than CHOMP unless you have a clear reason to use CHOMP. The majority of MoveIt users choose OMPL.

That should be set similar to this:

https://github.com/ros-planning/moveit_resources/blob/dad863321cd2ded86a80c8013a821dabf2f72260/panda_moveit_config/launch/demo.launch.py#L47

$\endgroup$
2
  • $\begingroup$ Thank you for answering me, I'd like to try your suggestion but unless I don't understand something then from what understanding I need an OMPL file for my robot (in config), correct me if I'm wrong. And the setup assistant doesn't create a file like that, and I'm unsure how I go about creating one that fits my robot. $\endgroup$ Mar 5 at 19:59
  • 1
    $\begingroup$ I suspect something was broken with moveit_setup_assistant recently. Sorry! You can set things up manually by copying the files here: github.com/ros-planning/moveit_resources/tree/… In fact, if I were in your shoes, I wouldn't use MoveIt Setup Assistant at all. I'd start from that panda_moveit_config package and rename things. I'd also encourage you to open an issue on the MoveIt2 repo so they/we will be aware of the problem. $\endgroup$
    – AndyZe
    Mar 7 at 14:37

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.