|
| 1 | +:github_url: https://github.com/UniversalRobots/Universal_Robots_ROS2_Tutorials/blob/main/my_dual_robot_cell/doc/build_moveit_config.rst |
| 2 | + |
| 3 | + |
| 4 | +======================== |
| 5 | +Build the MoveIt! config |
| 6 | +======================== |
| 7 | + |
| 8 | +At this point, you should be able to run the ``ur_robot_driver`` for your custom UR setup. |
| 9 | +Now, we are only one last step away from actually planning and executing trajectories. |
| 10 | + |
| 11 | +To utilize MoveIt! 2 for this purpose, which will handle trajectory planning for us, we need to set up a MoveIt! configuration package. |
| 12 | +To create such a MoveIt! `configuration package <https://github.com/UniversalRobots/Universal_Robots_ROS2_Tutorials/tree/main/my_dual_robot_cell/my_dual_robot_cell_moveit_config>`_, MoveIt! provides a very useful Setup Assistant. |
| 13 | + |
| 14 | +Setup Assistant |
| 15 | +--------------- |
| 16 | + |
| 17 | +We can start the MoveIt! Setup Assistant by running: |
| 18 | + |
| 19 | +.. code-block:: bash |
| 20 | +
|
| 21 | + ros2 launch moveit_setup_assistant setup_assistant.launch.py |
| 22 | +
|
| 23 | +Please note that MoveIt! itself provides a detailed `tutorial <https://moveit.picknik.ai/main/doc/examples/setup_assistant/setup_assistant_tutorial.html?highlight=setup%20assistant>`_ on how to use the Setup Assistant, so you may want to go through that. |
| 24 | +Although the Setup Assistant is very straightforward, there are some tips and tricks we want to discuss in the following sections. |
| 25 | + |
| 26 | +The first task the MoveIt! Setup Assistant asks us to do is to load the URDF with the optional xacro arguments. If you would like to change the ``ur_type`` for example, you could also specify that here. For this demonstration we'll go with our description's default values. |
| 27 | + |
| 28 | +.. image:: load_urdf.png |
| 29 | + :alt: Load a URDF |
| 30 | + |
| 31 | +Next, make sure that the generated **self-collisions** are detected correctly. In our example the robot |
| 32 | +is positioned on the table in such a way, that it collides with the monitor on the table when all |
| 33 | +joints are in the 0 position. Hence, the collision is allowed as "Collision by default". We remove |
| 34 | +that tick, since we don't want that collision to be ignored. |
| 35 | + |
| 36 | +.. image:: self_collisions.png |
| 37 | + :alt: Adjust self-collisions - Remove the tick for the collision between monitor and ur20_upper_arm_link. |
| 38 | + |
| 39 | + |
| 40 | +We skip adding virtual joints for now and continue with our **planning group(s)**. |
| 41 | +We add a planning group called **ur_arm**. A reasonable and error-resistant approach is to define |
| 42 | +it as a kinematic chain in the following manner: |
| 43 | + |
| 44 | +.. image:: planning_group_kinematics.png |
| 45 | + :alt: Kinematic setup for our planning group |
| 46 | + |
| 47 | +.. image:: planning_group_chain.png |
| 48 | + :alt: Kinematic Chain |
| 49 | + |
| 50 | +Your planning groups should look something like this: |
| 51 | + |
| 52 | +.. image:: planning_groups.png |
| 53 | + :alt: Planning Groups |
| 54 | + |
| 55 | +We'll skip setting up ros2_control related points, since we've already configured that in our |
| 56 | +control package. |
| 57 | + |
| 58 | +In the **MoveIt Controllers** step we setup our desired controller to match the name |
| 59 | +"scaled_joint_trajectory_controller": |
| 60 | + |
| 61 | +.. image:: moveit_controllers.png |
| 62 | + :alt: MoveIt! coontrollers configuration |
| 63 | + |
| 64 | +We skip **perception** as we don't have any cameras setup in our scenario. |
| 65 | + |
| 66 | +In the next step we modify the **launch files** being generated by the assistant. We only generate |
| 67 | +"RViz Launch and Config", "MoveGroup Launch" and "Setup Assistant Launch". The other launch files |
| 68 | +are for starting a demo using mock hardware, which would basically be a duplication of what we |
| 69 | +already did in our control package. Since we also do not use the Warehouse feature for now, we also |
| 70 | +skip that file. |
| 71 | + |
| 72 | +.. image:: launch_files.png |
| 73 | + :alt: Select the launch files to be generated |
| 74 | + |
| 75 | +After the **Author information** we select which configuration files to generate. Again, we strip |
| 76 | +down all the files needed for mock hardware startup. |
| 77 | + |
| 78 | +.. image:: config_files.png |
| 79 | + :alt: Select the config files to be generated |
| 80 | + |
| 81 | +With all the information entered, you can **generate** the package and close the setup assistant. |
| 82 | + |
| 83 | +Manual adaptions |
| 84 | +---------------- |
| 85 | + |
| 86 | +Before we can actually use our package we have to adapt the joint limits. Since MoveIt! requires |
| 87 | +joint acceleration limits to be specified but the description doesn't contain those, we need to |
| 88 | +specify these inside the generated ``config/joint_limits.yaml`` file. |
| 89 | + |
| 90 | +They are not part of the arm's description since there are no physical acceleration limits, as |
| 91 | +those are highly dependent on the robot's current pose and TCP force (e.g. induced by the weight |
| 92 | +carried at the TCP). Setting the acceleration limits to ``5.0`` for all joints should be a |
| 93 | +conservative value. Higher values might lead to unwanted slowdowns during execution or even |
| 94 | +protective stops, while lower values will result in slower motions due to slow ramp-up and |
| 95 | +ramp-down parts of the trajectory. |
| 96 | + |
| 97 | +.. literalinclude:: ../my_dual_robot_cell_moveit_config/config/joint_limits.yaml |
| 98 | + :language: yaml |
| 99 | + :linenos: |
| 100 | + :caption: my_dual_robot_cell_moveit_config/config/joint_limits.yaml |
| 101 | + |
| 102 | +Please note that you could also change the default velocity and acceleration scaling in this file. |
| 103 | +Also, if you want to specify any limits (position or velocity) that differ from your description, you |
| 104 | +can set them here. Remember that these will only be used for planning trajectories, not necessarily |
| 105 | +for execution. If you send trajectories from another source than MoveIt!, those limits will not |
| 106 | +apply! |
| 107 | + |
| 108 | + |
| 109 | +Usage |
| 110 | +----- |
| 111 | + |
| 112 | +Before we can test our code, it's essential to build and source our Colcon workspace: |
| 113 | + |
| 114 | +.. code-block:: bash |
| 115 | +
|
| 116 | + #cd to your colcon workspace root |
| 117 | + cd ~/colcon_ws |
| 118 | +
|
| 119 | + #source and build your workspace |
| 120 | + colcon build |
| 121 | + source install/setup.bash |
| 122 | +
|
| 123 | +
|
| 124 | +Now you are ready to use MoveIt! with two actual robot arms, MoveIt! itself also provides you with the opportunity to start a robot with mock hardware. |
| 125 | + |
| 126 | +To startup the complete system, you'll have to start three launch files in three individual |
| 127 | +terminals. |
| 128 | + |
| 129 | +First, we need to start a robot, simulated or real. If you start a real robot, make sure that the |
| 130 | +*external_control* program is active on the robot. |
| 131 | + |
| 132 | +.. code-block:: bash |
| 133 | +
|
| 134 | + # You can switch to real hardware if you prefer |
| 135 | + ros2 launch my_dual_robot_cell_control start_robots.launch.py bob_use_mock_hardware:=true alice_use_mock_hardware:=true |
| 136 | +
|
| 137 | +
|
| 138 | +
|
| 139 | +Second, we can start the move_group node by running the launch file the setup assistant created for us: |
| 140 | + |
| 141 | +.. code-block:: bash |
| 142 | +
|
| 143 | + ros2 launch my_dual_robot_cell_moveit_config move_group.launch.py |
| 144 | +
|
| 145 | +If everything went well you should see the output: **"You can start planning now!"**. |
| 146 | + |
| 147 | +To interact with the MoveIt! setup, you can start RViz with the correct setup file: |
| 148 | + |
| 149 | +.. code-block:: bash |
| 150 | +
|
| 151 | + ros2 launch my_dual_robot_cell_moveit_config moveit_rviz.launch.py |
| 152 | +
|
| 153 | +From that setup you can start developing your application involving a custom move_group interface |
| 154 | +or similar. Please refer to the MoveIt! documentation for further reading. |
0 commit comments