Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Modified launch files tutorial, added a note to the README. #1008

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 47 additions & 1 deletion doc/examples/moveit_cpp/moveitcpp_tutorial.rst
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,50 @@ The entire code can be seen :codedir:`here in the MoveIt GitHub project<examples

The Launch File
---------------
The entire launch file is :codedir:`here<examples/moveit_cpp/launch/moveit_cpp_tutorial.launch.py>` on GitHub. All the code in this tutorial can be run from the **moveit2_tutorials** package that you have as part of your MoveIt setup.
The entire launch file is :codedir:`here<examples/moveit_cpp/launch/moveit_cpp_tutorial.launch.py>` on GitHub.
Notably, the launch file contains the following node

.. code-block:: python

# MoveItCpp demo executable
moveit_cpp_node = Node(
name="moveit_cpp_tutorial",
package="moveit2_tutorials",
executable="moveit_cpp_tutorial",
output="screen",
parameters=[moveit_config.to_dict()],
)
This node contains parameters which are passed to the executable associated with moveit_cpp_tutorial.
Copy link
Contributor

Choose a reason for hiding this comment

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

Use ``code_font`` here for the tutorial name

Comment on lines +44 to +45
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: Add a blank line in between these 2 -- although it seems to render fine as is


The CMakeLists.txt File
-----------------------
During the build process, the CMakeLists.txt file assigns where the launcher will look for the executable.
Below is the CMakeLists.txt file for this tutorial:
Comment on lines +47 to +50
Copy link
Contributor

Choose a reason for hiding this comment

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

Add code font: ``CMakeLists.txt`` to all these mentions

Also "launcher" --> "launch file"


.. code-block:: cmake

add_executable(moveit_cpp_tutorial src/moveit_cpp_tutorial.cpp)
target_include_directories(moveit_cpp_tutorial PUBLIC include)
ament_target_dependencies(moveit_cpp_tutorial ${THIS_PACKAGE_INCLUDE_DEPENDS} Boost)

install(TARGETS moveit_cpp_tutorial
DESTINATION lib/${PROJECT_NAME}
)
install(DIRECTORY launch
DESTINATION share/${PROJECT_NAME}
)
install(DIRECTORY config
DESTINATION share/${PROJECT_NAME}
)

``add_executable`` builds the executable named moveit_cpp_tutorial from the source file ``src/moveit_cpp_tutorial.cpp``.
Copy link
Contributor

Choose a reason for hiding this comment

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

code font for the executable name here too


``target_include_directories`` specifies the directories to search for header files during compilation.
``PUBLIC`` makes the include directory available to targets that depend on ``moveit_cpp_tutorial``.

``ament_target_dependencies`` specifies dependencies for the moveit_cpp_tutorial executable.
Copy link
Contributor

Choose a reason for hiding this comment

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

and here

``${THIS_PACKAGE_INCLUDE_DEPENDS}`` is a variable defined in the ``moveit2_tutorials`` root directory's CMakeLists.txt file, which list common dependencies used in moveit2_tutorials.
Copy link
Contributor

Choose a reason for hiding this comment

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

code font for all the things here as well


``install(TARGET ...)`` and ``install(DIRECTORY ...)`` specify where to put the built executable and directories needed to run your program.

For more details about custom executables, please browse the other examples on this site as well as the ROS documentation.
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
For more details about custom executables, please browse the other examples on this site as well as the ROS documentation.
For more details about building executables in ROS packages, please browse the other examples on this site as well as the ROS documentation.

Also, consider maybe linking to the ROS documentation here?

Original file line number Diff line number Diff line change
Expand Up @@ -167,21 +167,68 @@ or you can include selected sub-components as follows:

Note that the above syntax will automatically look for configuration files that match the default file naming patterns described in this document.
If you have a different naming convention, you can use the functions available in ``MoveItConfigsBuilder`` to directly set file names.
For example, to use a non-default robot description and IK solver file path, and configure planning pipelines:
Using the launch file from :doc:`/doc/tutorials/quickstart_in_rviz/quickstart_in_rviz_tutorial` as an example:

.. code-block:: python

from moveit_configs_utils import MoveItConfigsBuilder

# Define xacro mappings for the robot description file
launch_arguments = {
"robot_ip": "xxx.yyy.zzz.www",
"use_fake_hardware": "true",
"gripper": "robotiq_2f_85",
"dof": "7",
}

# Load the robot configuration
moveit_config = (
MoveItConfigsBuilder("my_robot")
.robot_description(file_path="config/my_robot.urdf.xacro")
.robot_description_kinematics(file_path="config/my_kinematics_solver.yaml")
MoveItConfigsBuilder(
"gen3", package_name="kinova_gen3_7dof_robotiq_2f_85_moveit_config"
)
.robot_description(mappings=launch_arguments)
.trajectory_execution(file_path="config/moveit_controllers.yaml")
.planning_scene_monitor(
publish_robot_description=True, publish_robot_description_semantic=True
)
.planning_pipelines(
pipelines=["ompl", "pilz_industrial_motion_planner"],
default_planning_pipeline="pilz_industrial_motion_planner",
pipelines=["ompl", "stomp", "pilz_industrial_motion_planner"]
)
.to_moveit_configs()
)


``MoveItConfigsBuilder`` (`defined here <https://github.com/moveit/moveit2/blob/main/moveit_configs_utils/moveit_configs_utils/moveit_configs_builder.py>`_) can take a few different types of arguments.

* ``MoveItConfigsBuilder(package_name="package_name")`` will search for a package named "package_name".
Copy link
Contributor

Choose a reason for hiding this comment

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

code font on "package_name" as well

* ``MoveItConfigsBuilder("robot_name")`` will search for an explicitly given package name.
Both arguments can be given, in which case the robot name is stored and the package with the explicitly given name will be loaded.
As seen above, ``gen3`` is the robot name, and MoveIt looks for the package ``kinova_gen3_7dof_robotiq_2f_85_moveit_config`` instead of ``gen3_moveit_config``.

``.robot_description`` can optionally take a file path to ``robot_name.urdf`` and/or assign a dictionary of argument mappings that are passed to the robot's urdf.xacro file.
The file path to ``robot_name.urdf`` must be relative to your robot package, so if your robot package is ``/robot_package`` and the urdf (or urdf xacro) file is ``robot_package/config/robot_name.urdf``
you would pass ``.robot_description(filepath="config/robot_name.urdf")``.
Comment on lines +209 to +210
Copy link
Contributor

@sea-bass sea-bass Feb 8, 2025

Choose a reason for hiding this comment

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

I think there may be a whitespace missing here

EDIT: actually it's fine, seems the line break adds the space

If you don't provide a file path, but you do give ``MoveItConfigsBuilder`` a robot name (see above paragraph), MoveIt will look for ``robot_package/config/robot_name.urdf``.

``.trajectory_execution`` loads trajectory execution and MoveIt controller manager's parameters from an optionally provided file path.
If a file path isn't given, MoveIt looks for files in the package's ``config`` folder for files ending with ``controllers.yaml``.

``.planning_scene_monitor`` allows you to set various parameters about what scene information is published and how often is it published.

``.planning_pipelines`` allows to you to list the names of the planners you want available to be used by your robot.
If you opt to not list pipelines, as in ``.planning_pipelines()``, MoveIt will look in the config folder of your package for files that end with "_planning.yaml".
Additionally, if no pipelines are listed, MoveIt will load a set of planners from its own library - this can be disabled adding ``load_all=False`` as an argument to ``.planning_pipelines``.
Listing the planner names specifiies which planners MoveIt should load; again these should be in your config folder.
MoveIt will also pick one of your planners to be the default planner.
If OMPL is one of your planners, it will be the default planner unless you set ``default_planning_pipeline`` to your desired default planner as in

.. code-block:: python

.planning_pipelines(
pipelines=["ompl", "your_favorite_planner"],
default_planning_pipeline="your_favorite_planner",
)

If OMPL is not in your planner list and you don't set a default planner, MoveIt will pick the first planner in the list.
Comment on lines +208 to +232
Copy link
Contributor

Choose a reason for hiding this comment

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

Consider putting this in a bulleted list. Right now it renders like this which is a little dense to parse

image

Comment on lines +208 to +232
Copy link
Contributor

Choose a reason for hiding this comment

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

Consider linking to the OMPL Planner doc page here


Now that you have read this page, you should be able to better understand the launch files available throughout the MoveIt 2 tutorials, and when encountering other MoveIt configuration packages in the wild.
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ A handy way to refer to a MoveIt configuration package is to use the ``MoveItCon
Launching Move Group
--------------------

Once all the MoveIt configuration parameters have been loaded, you can launch the :ref:`Move Group Interface` using the entire set of loaded MoveIt parameters.
Once all the MoveIt configuration parameters have been loaded, you can define the :ref:`Move Group Interface` Node using the entire set of loaded MoveIt parameters.
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
Once all the MoveIt configuration parameters have been loaded, you can define the :ref:`Move Group Interface` Node using the entire set of loaded MoveIt parameters.
Once all the MoveIt configuration parameters have been loaded, you can define the :ref:`Move Group Interface` node using the entire set of loaded MoveIt parameters.


.. code-block:: python

Expand Down Expand Up @@ -187,6 +187,7 @@ In our example, we have:
arguments=["robotiq_gripper_controller", "-c", "/controller_manager"],
)


Launching all the nodes
-----------------------

Expand All @@ -213,3 +214,8 @@ Finally, we can tell our launch file to actually launch everything we described
hand_controller_spawner,
]
)

Launching a custom executable
----------------------------

Later on these tutorials (:doc:`/doc/examples/moveit_cpp/moveit_cpp_tutorial`), you will learn how to create and launch a custom executable.
Comment on lines +218 to +221
Copy link
Contributor

Choose a reason for hiding this comment

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

I would remove this.

Loading