Skip to content

✨ Your First C++ MoveIt Project Tutorial - #262

Merged
tylerjw merged 15 commits into
moveit:mainfrom
tylerjw:your_first_moveit_cpp_project
May 20, 2022
Merged

tylerjw merged 15 commits into
moveit:mainfrom
tylerjw:your_first_moveit_cpp_project

Conversation

@tylerjw

@tylerjw tylerjw commented Jan 6, 2022 •

Copy link
Copy Markdown
Member

This adds a initial tutorial walking a user through creating their first program using MoveIt.

Description

This is based on the MoveGroupInterface tutorial here: https://github.com/ros-planning/moveit2_tutorials/blob/main/doc/move_group_interface/src/move_group_interface_tutorial.cpp

@tylerjw tylerjw linked an issue Jan 6, 2022 that may be closed by this pull request
@tylerjw
tylerjw force-pushed the your_first_moveit_cpp_project branch from a6ebe40 to d0bbb6a Compare January 6, 2022 16:46
@tylerjw tylerjw changed the title ✨ Your First MoveIt C++ Project Tutorial ✨ Your First C++ MoveIt Project Tutorial Jan 6, 2022
@tylerjw
tylerjw force-pushed the your_first_moveit_cpp_project branch 2 times, most recently from 7e55982 to b36c42d Compare January 6, 2022 16:54
@tylerjw tylerjw mentioned this pull request Jan 6, 2022
@tylerjw
tylerjw force-pushed the your_first_moveit_cpp_project branch 6 times, most recently from 748e22f to 6b2a86e Compare January 13, 2022 18:44
@mergify

mergify Bot commented Jan 13, 2022

Copy link
Copy Markdown

This pull request is in conflict. Could you fix it @tylerjw?

@tylerjw
tylerjw force-pushed the your_first_moveit_cpp_project branch 2 times, most recently from d76bdb1 to 5c93c4d Compare January 14, 2022 20:52
@mergify

mergify Bot commented Jan 14, 2022

Copy link
Copy Markdown

This pull request is in conflict. Could you fix it @tylerjw?

@tylerjw
tylerjw force-pushed the your_first_moveit_cpp_project branch 2 times, most recently from 6a516f2 to f29e025 Compare January 14, 2022 21:03
@tylerjw tylerjw assigned tylerjw and unassigned Abishalini Jan 14, 2022
@tylerjw
tylerjw marked this pull request as ready for review January 14, 2022 21:04
@tylerjw
tylerjw force-pushed the your_first_moveit_cpp_project branch 3 times, most recently from c941896 to 4302b4d Compare January 14, 2022 23:23
@Abishalini

Copy link
Copy Markdown
Contributor

I was testing this PR and launching the demo file give me this error

[move_group-4] /home/abishalini/ws_tutorials/install/moveit_ros_move_group/lib/moveit_ros_move_group/move_group: symbol lookup error: /home/abishalini/ws_tutorials/install/moveit_simple_controller_manager/lib/libmoveit_simple_controller_manager.so: undefined symbol: _ZN13rclcpp_action10ClientBaseC2ESt10shared_ptrIN6rclcpp15node_interfaces17NodeBaseInterfaceEES1_INS3_18NodeGraphInterfaceEES1_INS3_20NodeLoggingInterfaceEERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEPK28rosidl_action_type_support_tRK27rcl_action_client_options_t
[ERROR] [move_group-4]: process has died [pid 8736, exit code 127, cmd '/home/abishalini/ws_tutorials/install/moveit_ros_move_group/lib/moveit_ros_move_group/move_group --ros-args --params-file /tmp/launch_params_o_rav6lz --params-file /tmp/launch_params_ctt1rnfj --params-file /tmp/launch_params_q1yr1wd2 --params-file /tmp/launch_params_x46drsfd --params-file /tmp/launch_params_6h5inkbh --params-file /tmp/launch_params_a5m6juj4 --params-file /tmp/launch_params_dsraqym_'].

Did anyone come across this?

@destogl

destogl commented Jan 16, 2022

Copy link
Copy Markdown

I am getting the error described in #303 on both, galactic and rolling distributions.

@tylerjw

tylerjw commented Jan 17, 2022

Copy link
Copy Markdown
Member Author

I am getting the error described in #303 on both, galactic and rolling distributions.

Thank you for trying this. I read the issue you posted but haven't had time to work on it yet.

@kylc

kylc commented Jan 17, 2022

Copy link
Copy Markdown

After adding the code in step 3, I'm getting an error relating to a missing robot_description parameter in the hello_moveit node.

[ERROR] [1642455060.905388060] [hello_moveit]: Could not find parameter robot_description and did not receive robot_description via std_msgs::msg::String subscription within 10.000000 seconds.
Error:   Error document empty.
         at line 71 in /tmp/binarydeb/ros-rolling-urdfdom-2.3.5/urdf_parser/src/model.cpp
Failed to parse robot description using: urdf_xml_parser/URDFXMLParser
[INFO] [1642455060.907010402] [moveit_rdf_loader.rdf_loader]: Unable to parse URDF
Error:   Error document empty.
         at line 71 in /tmp/binarydeb/ros-rolling-urdfdom-2.3.5/urdf_parser/src/model.cppFailed to parse robot description using: urdf_xml_parser/URDFXMLParser
[INFO] [1642455070.909238553] [moveit_rdf_loader.rdf_loader]: Unable to parse URDF
[FATAL] [1642455070.909728671] [move_group_interface]: Unable to construct robot model. Please make sure all needed information is on the parameter server.
terminate called after throwing an instance of 'std::runtime_error'
  what():  Unable to construct robot model. Please make sure all needed information is on the parameter server.
[ros2run]: Aborted

I believe this is because that parameter is unmapped when running the node via a simple ros2 run command. Adding a launch file like the following and running with ros2 launch fixes the issues for me (copied from the move_group_interface_tutorial.launch.py file):

import os
import yaml
from launch import LaunchDescription
from launch_ros.actions import Node
from ament_index_python.packages import get_package_share_directory


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


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


def generate_launch_description():
    # planning_context
    robot_description_config = load_file(
        "moveit_resources_panda_description", "urdf/panda.urdf"
    )
    robot_description = {"robot_description": robot_description_config}

    robot_description_semantic_config = load_file(
        "moveit_resources_panda_moveit_config", "config/panda.srdf"
    )
    robot_description_semantic = {
        "robot_description_semantic": robot_description_semantic_config
    }

    kinematics_yaml = load_yaml(
        "moveit_resources_panda_moveit_config", "config/kinematics.yaml"
    )

    # MoveGroupInterface demo executable
    move_group_demo = Node(
        name="hello_moveit",
        package="hello_moveit",
        executable="hello_moveit",
        output="screen",
        parameters=[robot_description, robot_description_semantic, kinematics_yaml],
    )

    return LaunchDescription([move_group_demo])

@tylerjw

tylerjw commented Jan 17, 2022 •

Copy link
Copy Markdown
Member Author

After adding the code in step 3, I'm getting an error relating to a missing robot_description parameter in the hello_moveit node.

[ERROR] [1642455060.905388060] [hello_moveit]: Could not find parameter robot_description and did not receive robot_description via std_msgs::msg::String subscription within 10.000000 seconds.
Error:   Error document empty.
         at line 71 in /tmp/binarydeb/ros-rolling-urdfdom-2.3.5/urdf_parser/src/model.cpp
Failed to parse robot description using: urdf_xml_parser/URDFXMLParser
[INFO] [1642455060.907010402] [moveit_rdf_loader.rdf_loader]: Unable to parse URDF
Error:   Error document empty.
         at line 71 in /tmp/binarydeb/ros-rolling-urdfdom-2.3.5/urdf_parser/src/model.cppFailed to parse robot description using: urdf_xml_parser/URDFXMLParser
[INFO] [1642455070.909238553] [moveit_rdf_loader.rdf_loader]: Unable to parse URDF
[FATAL] [1642455070.909728671] [move_group_interface]: Unable to construct robot model. Please make sure all needed information is on the parameter server.
terminate called after throwing an instance of 'std::runtime_error'
  what():  Unable to construct robot model. Please make sure all needed information is on the parameter server.
[ros2run]: Aborted

The error you are getting is there is something wrong with the loading of the urdf_xml_parser/URDFXMLParser plugin. I think something is wrong with how this plugin is exported. I can't reliably isolate this issue. It happens sometimes and other times it doesn't for me. You don't need to provide robot_description as a parameter to the node using the MoveGroupIterface if there is a running MoveGroup node with these two parameters configured:

        "publish_robot_description": True,
        "publish_robot_description_semantic": True,

Doing ☝️ causes the MoveGroup node to publish the robot_description on a latched topic that the MoveGroupInterface node can subscribe to and get the value.

You'll notice that these two lines are added to the demo.launch.py in this PR so it should be publishing on those two topics.

@abake48 abake48 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I ran into the same issue that @kylc experienced. Outside of that, I have a few nitpicky suggestions.

@mergify

mergify Bot commented May 9, 2022

Copy link
Copy Markdown

This pull request is in conflict. Could you fix it @tylerjw?

@tylerjw
tylerjw force-pushed the your_first_moveit_cpp_project branch from e299fea to 78389a9 Compare May 17, 2022 01:54
Comment thread moveit2_tutorials.repos Resolved
@tylerjw
tylerjw force-pushed the your_first_moveit_cpp_project branch from 75d2761 to 78389a9 Compare May 17, 2022 15:42

@wyattrees wyattrees left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, but I think a couple things need a bit more explanation

@mergify

mergify Bot commented May 19, 2022

Copy link
Copy Markdown

This pull request is in conflict. Could you fix it @tylerjw?

@tylerjw
tylerjw force-pushed the your_first_moveit_cpp_project branch from 632fc64 to 788595b Compare May 19, 2022 20:37
tylerjw and others added 14 commits May 19, 2022 19:44
Signed-off-by: Tyler Weaver <[email protected]>
Signed-off-by: Tyler Weaver <[email protected]>
Signed-off-by: Tyler Weaver <[email protected]>
@tylerjw
tylerjw force-pushed the your_first_moveit_cpp_project branch from 788595b to c775152 Compare May 20, 2022 01:44

@stephanie-eng stephanie-eng left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks and works great! I highlighted a few areas in need of very minor grammatical fixes, but approved pending those changes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Write "Your First C++ MoveIt Project" tutorial

10 participants