4.1. Using MoveIt2#

This section explains how to use MoveIt2.

For specifications and details of MoveIt2, refer to the official MoveIt 2 documentation .

4.1.1. Creating a Workspace#

Create a workspace for using MoveIt2. Follow the steps below.

  1. Run the following to install the tools required for building.

    $ sudo apt update
    $ sudo apt install -y python3-colcon-common-extensions python3-rosdep
    $ sudo rosdep init
    $ rosdep update
    
  2. Then run the following to create the workspace, clone the required packages, and build them.

    $ source /opt/ros/<ROS_DISTRO>/setup.bash
    $ mkdir -p ~/hsr_ros2_ws/src && cd ~/hsr_ros2_ws/src
    $ git clone -b $ROS_DISTRO https://github.com/hsr-project/hsrb_moveit.git
    
    $ cd ~/hsr_ros2_ws/
    $ rosdep install --from-paths . -y --ignore-src
    $ colcon build --symlink-install --cmake-args -DCMAKE_BUILD_TYPE=Release
    $ source install/setup.bash
    

4.1.2. Launching MoveIt2#

Follow the steps below to launch MoveIt2.

  • Launching HSR

    1. Run the following to set the environment variables. Set ROS_DOMAIN_ID to an appropriate value.

      $ export ROS_DOMAIN_ID=XXX
      $ source /opt/ros/<ROS_DISTRO>/setup.bash
      
    2. Run the following to launch the simulator.

      $ cd ~/hsr_ros2_ws/
      $ source install/setup.bash
      $ ros2 launch hsrb_gazebo_launch hsrb_empty_world.launch.py rviz:=false
      
  • Launching MoveIt2

    1. Run the following to set the environment variables. Set ROS_DOMAIN_ID to the value specified when launching the simulator.

      $ export ROS_DOMAIN_ID=XXX
      $ source /opt/ros/<ROS_DISTRO>/setup.bash
      
    2. Run the following to launch MoveIt2.

      $ cd ~/hsr_ros2_ws/
      $ source install/setup.bash
      $ ros2 launch hsrb_moveit_config hsrb_demo.launch.py use_sim_time:=true
      

After completing the above steps, an RViz screen similar to the one shown below will appear.

../_images/MoveIt2_start_hsrb.png

4.1.3. Operation via GUI#

This section explains how to operate HSR using MoveIt2 through the GUI.

  1. Click “Panels” in the upper-left corner of the screen and check “MotionPlanning”.

    ../_images/MoveIt2_Panals.png

    Once checked, the “MotionPlanning” tab will appear as shown in the figure.

    ../_images/MoveIt2_MotionPlanning.png

    As an example, move the “arm_lift_joint”.

  2. In the “Joints” tab, move the “arm_lift_joint” slider to the right to increase the value. The target pose will be displayed.

    ../_images/MoveIt2_arm_lift_joint_up.png
  3. Click “Plan” in the “Planning” tab. In RViz, you can observe the planned motion toward the target pose, but the robot will not move yet.

    ../_images/MoveIt2_Plan_up.png
  4. Click “Execute” in the “Planning” tab. You can now observe that the robot actually moves to the target pose.

    ../_images/MoveIt2_Execute.png
  5. Change the “Planning Group” in the “Planning” tab from “arm” to “base”.

    ../_images/MoveIt2_base.png
  6. In the “Joints” tab, move the “odom_y” and “odom_x” sliders to the right to increase the values.

    ../_images/MoveIt2_base_odom.png
  7. This time, click “Plan & Execute” in the “Planning” tab. You can observe both the planned motion and the actual motion to the target pose simultaneously.

    ../_images/MoveIt2_PlanandExecute.png ../_images/MoveIt2_PlanandExecute_move.png

4.1.4. Example Programs#

This section explains how to run the example programs.

  1. Launch MoveIt2 by referring to Launching MoveIt2 .

  2. The procedure for running an example program is as follows.

    1. Refer to “On the Simulator” in Launching MoveIt2 and set the environment variables.

    2. Run the following to run an example program.

      Replace <Example PROGRAM> with the program name described below.

      $ cd ~/hsr_ros2_ws/
      $ source install/setup.bash
      $ ros2 launch hsrb_moveit_config hsrb_example.launch.py use_sim_time:=true example_name:=<Example PROGRAM>
      
  3. The sample programs provided are as follows.

    Program Name

    Description

    moveit_fk_demo

    An example program that operates HSR by sending command values to each joint axis.

    moveit_ik_demo

    An example program that operates HSR by specifying the end-effector position as the target value. In addition to the default method, you can also test two other methods: one that moves the base as much as possible and another that minimizes base movement.

    moveit_gripper_demo

    An example program that demonstrates hand opening/closing using position control and interruption behavior using torque control.

    moveit_constraints_demo

    An example program that sets constraints on the end-effector’s pose . You can compare the behavior with and without constraints applied.