diff --git a/CMakeLists.txt b/CMakeLists.txt index f79c668431..b79af3aa35 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -81,6 +81,7 @@ add_subdirectory(doc/examples/moveit_cpp) # add_subdirectory(doc/examples/visualizing_collisions) # add_subdirectory(doc/examples/bullet_collision_checker) add_subdirectory(doc/examples/realtime_servo) +add_subdirectory(doc/how_to_guides/isaac_panda) ament_export_dependencies( ${THIS_PACKAGE_INCLUDE_DEPENDS} diff --git a/_static/videos/moveit_isaac_integration.mp4 b/_static/videos/moveit_isaac_integration.mp4 new file mode 100644 index 0000000000..85c23ff53b Binary files /dev/null and b/_static/videos/moveit_isaac_integration.mp4 differ diff --git a/doc/how_to_guides/how_to_guides.rst b/doc/how_to_guides/how_to_guides.rst index 945dd9fdc5..c02c8bc4b0 100644 --- a/doc/how_to_guides/how_to_guides.rst +++ b/doc/how_to_guides/how_to_guides.rst @@ -10,3 +10,4 @@ These how-to guides will help you quickly solve specific problems using MoveIt. how_to_generate_api_doxygen_locally how_to_setup_docker_containers_in_ubuntu how_to_write_doxygen + isaac_panda/isaac_panda_tutorial diff --git a/doc/how_to_guides/isaac_panda/.docker/Dockerfile b/doc/how_to_guides/isaac_panda/.docker/Dockerfile new file mode 100644 index 0000000000..725e244d72 --- /dev/null +++ b/doc/how_to_guides/isaac_panda/.docker/Dockerfile @@ -0,0 +1,44 @@ +FROM osrf/ros:humble-desktop-jammy + +SHELL ["/bin/bash", "-c", "-o", "pipefail"] + +RUN echo "deb [trusted=yes] https://raw.githubusercontent.com/moveit/moveit2_packages/jammy-humble/ ./" \ + | sudo tee /etc/apt/sources.list.d/moveit_moveit2_packages.list +RUN echo "yaml https://raw.githubusercontent.com/moveit/moveit2_packages/jammy-humble/local.yaml humble" \ + | sudo tee /etc/ros/rosdep/sources.list.d/1-moveit_moveit2_packages.list + +# Bring the container up to date to get the latest ROS2 humble sync on 01/27/23 +# hadolint ignore=DL3008, DL3013 +RUN apt-get update && apt-get upgrade -y && rosdep update + +# Install packages required to run the demo +RUN apt-get install -y --no-install-recommends \ + ros-humble-moveit \ + ros-humble-moveit-resources + +# Create Colcon workspace and clone the needed source code to run the demo +RUN mkdir -p /root/isaac_moveit_tutorial_ws/src +WORKDIR /root/isaac_moveit_tutorial_ws/src +RUN git clone https://github.com/PickNikRobotics/isaac_ros2_control.git +# Docker does not allow copying in parent directories from the host so grab another copy of the tutorials +RUN git clone https://github.com/MarqRazz/moveit2_tutorials.git -b pr-isaac_tutorial --depth 1 +WORKDIR /root/isaac_moveit_tutorial_ws +# hadolint ignore=SC1091 +RUN source /opt/ros/humble/setup.bash \ + && apt-get update -y \ + && rosdep install --from-paths src --ignore-src --rosdistro "$ROS_DISTRO" -y \ + && rm -rf /var/lib/apt/lists/* + +# Use Fast DDS as middleware and load the required config for NVIDIA Isaac Sim. +ENV RMW_IMPLEMENTATION=rmw_fastrtps_cpp +RUN mkdir -p /opt/.ros +COPY ./.docker/fastdds.xml /opt/.ros/fastdds.xml +ENV FASTRTPS_DEFAULT_PROFILES_FILE=/opt/.ros/fastdds.xml + +# Build the Colcon workspace for the user +RUN source /opt/ros/humble/setup.bash && colcon build + +# Set up the entrypoint for both container start and interactive terminals. +COPY .docker/ros_entrypoint.sh /opt/.ros/ +RUN echo "source /opt/.ros/ros_entrypoint.sh" >> ~/.bashrc +ENTRYPOINT [ "/opt/.ros/ros_entrypoint.sh" ] diff --git a/doc/how_to_guides/isaac_panda/.docker/fastdds.xml b/doc/how_to_guides/isaac_panda/.docker/fastdds.xml new file mode 100644 index 0000000000..20d9e85250 --- /dev/null +++ b/doc/how_to_guides/isaac_panda/.docker/fastdds.xml @@ -0,0 +1,28 @@ + + +NVIDIA Isaac ROS Software License + + + + UdpTransport + UDPv4 + + + + + + + UdpTransport + + false + + + diff --git a/doc/how_to_guides/isaac_panda/.docker/ros_entrypoint.sh b/doc/how_to_guides/isaac_panda/.docker/ros_entrypoint.sh new file mode 100755 index 0000000000..94852a5209 --- /dev/null +++ b/doc/how_to_guides/isaac_panda/.docker/ros_entrypoint.sh @@ -0,0 +1,18 @@ +#!/bin/bash + +# Source ROS 2 Humble +source /opt/ros/humble/setup.bash +echo "Sourced ROS 2 Humble" + +# Source the base workspace, if built +if [ -f /root/isaac_moveit_tutorial_ws/install/setup.bash ] +then + source /root/isaac_moveit_tutorial_ws/install/setup.bash + echo "Sourced isaac_moveit_tutorial workspace" +else + echo "Please build the isaac_moveit_tutorial workspace with:" + echo "colcon build" +fi + +# Execute the command passed into this entrypoint +exec "$@" diff --git a/doc/how_to_guides/isaac_panda/CMakeLists.txt b/doc/how_to_guides/isaac_panda/CMakeLists.txt new file mode 100644 index 0000000000..c68409aa9c --- /dev/null +++ b/doc/how_to_guides/isaac_panda/CMakeLists.txt @@ -0,0 +1,6 @@ +install(DIRECTORY launch + DESTINATION share/${PROJECT_NAME} +) +install(DIRECTORY config + DESTINATION share/${PROJECT_NAME} +) diff --git a/doc/how_to_guides/isaac_panda/config/panda_moveit_config.rviz b/doc/how_to_guides/isaac_panda/config/panda_moveit_config.rviz new file mode 100644 index 0000000000..462f0da40e --- /dev/null +++ b/doc/how_to_guides/isaac_panda/config/panda_moveit_config.rviz @@ -0,0 +1,508 @@ +Panels: + - Class: rviz_common/Displays + Help Height: 78 + Name: Displays + Property Tree Widget: + Expanded: ~ + Splitter Ratio: 0.5 + Tree Height: 363 + - Class: rviz_common/Selection + Name: Selection + - Class: rviz_common/Tool Properties + Expanded: + - /2D Goal Pose1 + - /Publish Point1 + Name: Tool Properties + Splitter Ratio: 0.5886790156364441 + - Class: rviz_common/Views + Expanded: + - /Current View1 + Name: Views + Splitter Ratio: 0.5 +Visualization Manager: + Class: "" + Displays: + - Alpha: 0.5 + Cell Size: 1 + Class: rviz_default_plugins/Grid + Color: 160; 160; 164 + Enabled: true + Line Style: + Line Width: 0.029999999329447746 + Value: Lines + Name: Grid + Normal Cell Count: 0 + Offset: + X: 0 + Y: 0 + Z: 0 + Plane: XY + Plane Cell Count: 10 + Reference Frame: + Value: true + - Class: rviz_default_plugins/MarkerArray + Enabled: true + Name: MarkerArray + Namespaces: + {} + Topic: + Depth: 100 + Durability Policy: Volatile + History Policy: Keep Last + Reliability Policy: Reliable + Value: /rviz_visual_tools + Value: true + - Class: moveit_rviz_plugin/Trajectory + Color Enabled: false + Enabled: true + Interrupt Display: false + Links: + All Links Enabled: true + Expand Joint Details: false + Expand Link Details: false + Expand Tree: false + Link Tree Style: Links in Alphabetic Order + panda_hand: + Alpha: 1 + Show Axes: false + Show Trail: false + Value: true + panda_leftfinger: + Alpha: 1 + Show Axes: false + Show Trail: false + Value: true + panda_link0: + Alpha: 1 + Show Axes: false + Show Trail: false + Value: true + panda_link1: + Alpha: 1 + Show Axes: false + Show Trail: false + Value: true + panda_link2: + Alpha: 1 + Show Axes: false + Show Trail: false + Value: true + panda_link3: + Alpha: 1 + Show Axes: false + Show Trail: false + Value: true + panda_link4: + Alpha: 1 + Show Axes: false + Show Trail: false + Value: true + panda_link5: + Alpha: 1 + Show Axes: false + Show Trail: false + Value: true + panda_link6: + Alpha: 1 + Show Axes: false + Show Trail: false + Value: true + panda_link7: + Alpha: 1 + Show Axes: false + Show Trail: false + Value: true + panda_link8: + Alpha: 1 + Show Axes: false + Show Trail: false + panda_rightfinger: + Alpha: 1 + Show Axes: false + Show Trail: false + Value: true + Loop Animation: false + Name: Trajectory + Robot Alpha: 0.5 + Robot Color: 150; 50; 150 + Robot Description: robot_description + Show Robot Collision: false + Show Robot Visual: true + Show Trail: false + State Display Time: 0.05 s + Trail Step Size: 1 + Trajectory Topic: /display_planned_path + Use Sim Time: false + Value: true + - Class: moveit_rviz_plugin/PlanningScene + Enabled: true + Move Group Namespace: "" + Name: PlanningScene + Planning Scene Topic: /monitored_planning_scene + Robot Description: robot_description + Scene Geometry: + Scene Alpha: 0.8999999761581421 + Scene Color: 50; 230; 50 + Scene Display Time: 0.009999999776482582 + Show Scene Geometry: true + Voxel Coloring: Z-Axis + Voxel Rendering: Occupied Voxels + Scene Robot: + Attached Body Color: 150; 50; 150 + Links: + All Links Enabled: true + Expand Joint Details: false + Expand Link Details: false + Expand Tree: false + Link Tree Style: Links in Alphabetic Order + panda_hand: + Alpha: 1 + Show Axes: false + Show Trail: false + Value: true + panda_leftfinger: + Alpha: 1 + Show Axes: false + Show Trail: false + Value: true + panda_link0: + Alpha: 1 + Show Axes: false + Show Trail: false + Value: true + panda_link1: + Alpha: 1 + Show Axes: false + Show Trail: false + Value: true + panda_link2: + Alpha: 1 + Show Axes: false + Show Trail: false + Value: true + panda_link3: + Alpha: 1 + Show Axes: false + Show Trail: false + Value: true + panda_link4: + Alpha: 1 + Show Axes: false + Show Trail: false + Value: true + panda_link5: + Alpha: 1 + Show Axes: false + Show Trail: false + Value: true + panda_link6: + Alpha: 1 + Show Axes: false + Show Trail: false + Value: true + panda_link7: + Alpha: 1 + Show Axes: false + Show Trail: false + Value: true + panda_link8: + Alpha: 1 + Show Axes: false + Show Trail: false + panda_rightfinger: + Alpha: 1 + Show Axes: false + Show Trail: false + Value: true + Robot Alpha: 1 + Show Robot Collision: false + Show Robot Visual: true + Value: true + - Acceleration_Scaling_Factor: 0.1 + Class: moveit_rviz_plugin/MotionPlanning + Enabled: true + Move Group Namespace: "" + MoveIt_Allow_Approximate_IK: false + MoveIt_Allow_External_Program: false + MoveIt_Allow_Replanning: false + MoveIt_Allow_Sensor_Positioning: false + MoveIt_Planning_Attempts: 10 + MoveIt_Planning_Time: 5 + MoveIt_Use_Cartesian_Path: false + MoveIt_Use_Constraint_Aware_IK: false + MoveIt_Workspace: + Center: + X: 0 + Y: 0 + Z: 0 + Size: + X: 2 + Y: 2 + Z: 2 + Name: MotionPlanning + Planned Path: + Color Enabled: false + Interrupt Display: false + Links: + All Links Enabled: true + Expand Joint Details: false + Expand Link Details: false + Expand Tree: false + Link Tree Style: Links in Alphabetic Order + panda_hand: + Alpha: 1 + Show Axes: false + Show Trail: false + Value: true + panda_leftfinger: + Alpha: 1 + Show Axes: false + Show Trail: false + Value: true + panda_link0: + Alpha: 1 + Show Axes: false + Show Trail: false + Value: true + panda_link1: + Alpha: 1 + Show Axes: false + Show Trail: false + Value: true + panda_link2: + Alpha: 1 + Show Axes: false + Show Trail: false + Value: true + panda_link3: + Alpha: 1 + Show Axes: false + Show Trail: false + Value: true + panda_link4: + Alpha: 1 + Show Axes: false + Show Trail: false + Value: true + panda_link5: + Alpha: 1 + Show Axes: false + Show Trail: false + Value: true + panda_link6: + Alpha: 1 + Show Axes: false + Show Trail: false + Value: true + panda_link7: + Alpha: 1 + Show Axes: false + Show Trail: false + Value: true + panda_link8: + Alpha: 1 + Show Axes: false + Show Trail: false + panda_rightfinger: + Alpha: 1 + Show Axes: false + Show Trail: false + Value: true + Loop Animation: false + Robot Alpha: 0.5 + Robot Color: 150; 50; 150 + Show Robot Collision: false + Show Robot Visual: true + Show Trail: false + State Display Time: 3x + Trail Step Size: 1 + Trajectory Topic: /display_planned_path + Use Sim Time: false + Planning Metrics: + Payload: 1 + Show Joint Torques: false + Show Manipulability: false + Show Manipulability Index: false + Show Weight Limit: false + TextHeight: 0.07999999821186066 + Planning Request: + Colliding Link Color: 255; 0; 0 + Goal State Alpha: 1 + Goal State Color: 250; 128; 0 + Interactive Marker Size: 0 + Joint Violation Color: 255; 0; 255 + Planning Group: panda_arm + Query Goal State: true + Query Start State: false + Show Workspace: false + Start State Alpha: 1 + Start State Color: 0; 255; 0 + Planning Scene Topic: /monitored_planning_scene + Robot Description: robot_description + Scene Geometry: + Scene Alpha: 0.8999999761581421 + Scene Color: 50; 230; 50 + Scene Display Time: 0.009999999776482582 + Show Scene Geometry: true + Voxel Coloring: Z-Axis + Voxel Rendering: Occupied Voxels + Scene Robot: + Attached Body Color: 150; 50; 150 + Links: + All Links Enabled: true + Expand Joint Details: false + Expand Link Details: false + Expand Tree: false + Link Tree Style: Links in Alphabetic Order + panda_hand: + Alpha: 1 + Show Axes: false + Show Trail: false + Value: true + panda_leftfinger: + Alpha: 1 + Show Axes: false + Show Trail: false + Value: true + panda_link0: + Alpha: 1 + Show Axes: false + Show Trail: false + Value: true + panda_link1: + Alpha: 1 + Show Axes: false + Show Trail: false + Value: true + panda_link2: + Alpha: 1 + Show Axes: false + Show Trail: false + Value: true + panda_link3: + Alpha: 1 + Show Axes: false + Show Trail: false + Value: true + panda_link4: + Alpha: 1 + Show Axes: false + Show Trail: false + Value: true + panda_link5: + Alpha: 1 + Show Axes: false + Show Trail: false + Value: true + panda_link6: + Alpha: 1 + Show Axes: false + Show Trail: false + Value: true + panda_link7: + Alpha: 1 + Show Axes: false + Show Trail: false + Value: true + panda_link8: + Alpha: 1 + Show Axes: false + Show Trail: false + panda_rightfinger: + Alpha: 1 + Show Axes: false + Show Trail: false + Value: true + Robot Alpha: 1 + Show Robot Collision: false + Show Robot Visual: true + Value: true + Velocity_Scaling_Factor: 0.1 + Enabled: true + Global Options: + Background Color: 48; 48; 48 + Fixed Frame: panda_link0 + Frame Rate: 30 + Name: root + Tools: + - Class: rviz_default_plugins/Interact + Hide Inactive Objects: true + - Class: rviz_default_plugins/MoveCamera + - Class: rviz_default_plugins/Select + - Class: rviz_default_plugins/FocusCamera + - Class: rviz_default_plugins/Measure + Line color: 128; 128; 0 + - Class: rviz_default_plugins/SetInitialPose + Covariance x: 0.25 + Covariance y: 0.25 + Covariance yaw: 0.06853891909122467 + Topic: + Depth: 5 + Durability Policy: Volatile + History Policy: Keep Last + Reliability Policy: Reliable + Value: /initialpose + - Class: rviz_default_plugins/SetGoal + Topic: + Depth: 5 + Durability Policy: Volatile + History Policy: Keep Last + Reliability Policy: Reliable + Value: /goal_pose + - Class: rviz_default_plugins/PublishPoint + Single click: true + Topic: + Depth: 5 + Durability Policy: Volatile + History Policy: Keep Last + Reliability Policy: Reliable + Value: /clicked_point + Transformation: + Current: + Class: rviz_default_plugins/TF + Value: true + Views: + Current: + Class: rviz_default_plugins/Orbit + Distance: 3.119211196899414 + Enable Stereo Rendering: + Stereo Eye Separation: 0.05999999865889549 + Stereo Focal Distance: 1 + Swap Stereo Eyes: false + Value: false + Focal Point: + X: 0.02386285550892353 + Y: 0.15478567779064178 + Z: 0.039489321410655975 + Focal Shape Fixed Size: true + Focal Shape Size: 0.05000000074505806 + Invert Z Axis: false + Name: Current View + Near Clip Distance: 0.009999999776482582 + Pitch: 0.5953981876373291 + Target Frame: + Value: Orbit (rviz) + Yaw: 5.958578109741211 + Saved: ~ +Window Geometry: + Displays: + collapsed: false + Height: 1043 + Hide Left Dock: false + Hide Right Dock: true + MotionPlanning: + collapsed: false + MotionPlanning - Trajectory Slider: + collapsed: false + QMainWindow State: 000000ff00000000fd0000000400000000000001c9000003bdfc020000000cfb0000001200530065006c0065006300740069006f006e00000001e10000009b0000005c00fffffffb0000001e0054006f006f006c002000500072006f007000650072007400690065007302000001ed000001df00000185000000a3fb000000120056006900650077007300200054006f006f02000001df000002110000018500000122fb000000200054006f006f006c002000500072006f0070006500720074006900650073003203000002880000011d000002210000017afb000000100044006900730070006c006100790073010000003b000001f4000000c700fffffffb0000002000730065006c0065006300740069006f006e00200062007500660066006500720200000138000000aa0000023a00000294fb00000014005700690064006500530074006500720065006f02000000e6000000d2000003ee0000030bfb0000000c004b0069006e0065006300740200000186000001060000030c00000261fb0000003c005400720061006a006500630074006f007200790020002d0020005400720061006a006500630074006f0072007900200053006c00690064006500720000000000ffffffff0000003f00fffffffb000000280020002d0020005400720061006a006500630074006f0072007900200053006c00690064006500720000000000ffffffff0000000000000000fb00000044004d006f00740069006f006e0050006c0061006e006e0069006e00670020002d0020005400720061006a006500630074006f0072007900200053006c00690064006500720000000000ffffffff0000003f00fffffffb0000001c004d006f00740069006f006e0050006c0061006e006e0069006e00670100000235000001c30000016900ffffff000000010000010f000003abfc0200000003fb0000001e0054006f006f006c002000500072006f00700065007200740069006500730100000041000000780000000000000000fb0000000a00560069006500770073000000003b000003ab000000a000fffffffb0000001200530065006c0065006300740069006f006e010000025a000000b200000000000000000000000200000490000000a9fc0100000001fb0000000a00560069006500770073030000004e00000080000002e10000019700000003000004420000003efc0100000002fb0000000800540069006d00650100000000000004420000000000000000fb0000000800540069006d00650100000000000004500000000000000000000005b1000003bd00000004000000040000000800000008fc0000000100000002000000010000000a0054006f006f006c00730100000000ffffffff0000000000000000 + Selection: + collapsed: false + Tool Properties: + collapsed: false + Trajectory - Trajectory Slider: + collapsed: false + Views: + collapsed: true + Width: 1920 + X: 1920 + Y: 0 diff --git a/doc/how_to_guides/isaac_panda/docker-compose.yaml b/doc/how_to_guides/isaac_panda/docker-compose.yaml new file mode 100644 index 0000000000..5e8b37fde4 --- /dev/null +++ b/doc/how_to_guides/isaac_panda/docker-compose.yaml @@ -0,0 +1,41 @@ +# Docker Compose file for Isaac ROS 2 Control +# +# Usage: +# +# To build the images: +# docker compose build +# +# To start up a specific service by name: +# docker compose up +# +# To open an interactive shell to a running container: +# (You can tab complete to get the container name) +# docker exec -it bash + +services: + base: + image: isaac_moveit_tutorial + build: + context: . + dockerfile: .docker/Dockerfile + # Interactive shell + stdin_open: true + tty: true + # Networking and IPC for ROS 2 + network_mode: host + ipc: host + privileged: true + environment: + - ROS_DOMAIN_ID + # Allows graphical programs in the container + - DISPLAY=${DISPLAY} + - QT_X11_NO_MITSHM=1 + volumes: + # Allows graphical programs in the container + - /tmp/.X11-unix:/tmp/.X11-unix:rw + demo_isaac: + extends: base + command: ros2 launch moveit2_tutorials isaac_demo.launch.py + demo_mock_components: + extends: base + command: ros2 launch moveit2_tutorials isaac_demo.launch.py ros2_control_hardware_type:=mock_components diff --git a/doc/how_to_guides/isaac_panda/isaac_panda_tutorial.rst b/doc/how_to_guides/isaac_panda/isaac_panda_tutorial.rst new file mode 100644 index 0000000000..9c18e724cd --- /dev/null +++ b/doc/how_to_guides/isaac_panda/isaac_panda_tutorial.rst @@ -0,0 +1,143 @@ +How To Command Simulated Isaac Robot +==================================== + +This tutorial requires a machine with ``Isaac 2022.2.0`` installed. +For Isaac requirements and installation please see the `Omniverse documentation `_. + +This tutorial has the following assumptions on system configuration: + +1. NVIDIA Isaac Sim 2022.2.0 is installed on a Ubuntu 20.04 host in the "$HOME/.local/share/ov/pkg/isaac_sim-2022.2.0" directory. (this is the default location) +2. Docker is installed. +3. You clone this repo so that you can build a Ubuntu 22.04 Humble based Docker image that can communicate with Isaac and run this tutorial. + +Introduction to ros2_control +---------------------------- + +One of the recommended ways to execute trajectories calculated by MoveIt is to use the `ros2_control `_ +framework to manage and communicate with your robot, real or simulated. It comes highly recommended because it offers a developers a common API that +allows your software to switch between many different robot types, and the sensors they have built in, by simply changing some launch arguments. +For example if we inspect the Panda Robot's ``ros2_control.xacro`` we can see it uses a flag ``use_fake_hardware`` to switch between being +simulated or connecting to a physical robot. + +.. code-block:: XML + + + + mock_components/GenericSystem + + + franka_hardware/FrankaHardwareInterface + ${robot_ip} + + + + +`Hardware Components `_ +can be of different types, but the plugin ``mock_components/GenericSystem`` is very a simple ``System`` +that forwards the incoming ``command_interface`` values to the tracked ``state_interface`` of the joints (i.e., perfect control of the simulated joints). + +For us to expand our Panda robot to Isaac Sim we first have to introduce `topic_based_ros2_control `_. +This Hardware Interface is a ``System`` that subscribes and publishes on a configured topics. +For this tutorial the topic ``/isaac_joint_states`` will contain the robot's current state and ``/isaac_joint_commands`` will be used to actuate it. +The `moveit_resources_panda_moveit_config `_ +we are using in this tutorial does not support connecting to hardware, so our ``ros2_control.xacro`` is now +updated to load the ``TopicBasedSystem`` plugin when the flag ``ros2_control_hardware_type`` is set to ``isaac``. + +.. code-block:: XML + + + mock_components/GenericSystem + + + topic_based_ros2_control/TopicBasedSystem + /isaac_joint_commands + /isaac_joint_states + + +In this tutorial we have included a Python script that loads a Panda robot +and builds an `OmniGraph `_ +to publish and subscribe to the ROS topics used to control the robot. +To learn about configuring your Isaac Sim robot to communicate with ROS 2 please see the +`Joint Control tutorial `_ +on Omniverse. + +Computer Setup +-------------- + +1. Install `Isaac Sim `_. + +2. For RViz to run inside Docker we have to tell the host to allow it to display applications. + +.. note:: this step is only required once every host machine login + +.. code-block:: bash + + xhost +local:docker + +3. Perform a shallow clone of the MoveIt2 Tutorials repo. + +.. code-block:: bash + + git clone https://github.com/ros-planning/moveit2_tutorials.git -b humble --depth 1 + +4. Go to the folder in which you cloned the tutorials and then switch to the following directory. + +.. code-block:: bash + + cd moveit2_tutorials/doc/how_to_guides/isaac_panda + +5. Build the Docker image. + +.. code-block:: bash + + docker compose build + +Running the MoveIt Interactive Marker Demo with Mock Components +--------------------------------------------------------------- + +1. To test out the ``mock_components/GenericSystem`` hardware interface run: + +.. code-block:: bash + + docker compose up demo_mock_components + +This will open up RViz with the Panda robot using ``mock_components`` to simulate the robot and execute trajectories. + +Please see the :doc:`Quickstart in RViz ` +tutorial if this is your first time using MoveIt with RViz. + +After you are done testing press ``crtl-c`` in the terminal to stop the container. + +Running the MoveIt Interactive Marker Demo with Isaac Sim +--------------------------------------------------------- + +1. On the host computer, go to the tutorials launch directory. + +.. code-block:: bash + + cd moveit2_tutorials/doc/how_to_guides/isaac_panda/launch + +2. Then run the following command to load the Panda Robot pre-configured to work with this tutorial. + +.. note:: This step assumes Isaac is installed on the host in the ``$HOME/.local/share/ov/pkg/isaac_sim-2022.2.0" directory``. + This step also takes a few minutes to download the assets and setup Isaac Sim so please be + patient and don't click the ``Force Quit`` dialog that pops up while the simulator starts. + +.. code-block:: bash + + ./python.sh isaac_moveit.py + +3. From the ``moveit2_tutorials/doc/how_to_guides/isaac_panda`` directory start a container that connects to Isaac Sim using the ``topic_based_ros2_control/TopicBasedSystem`` hardware interface. + +.. code-block:: bash + + docker compose up demo_isaac + +This will open up RViz with the Panda robot using ``TopicBasedSystem`` to simulate the robot and execute trajectories. + +.. raw:: html + + diff --git a/doc/how_to_guides/isaac_panda/launch/isaac_demo.launch.py b/doc/how_to_guides/isaac_panda/launch/isaac_demo.launch.py new file mode 100644 index 0000000000..fe1ff933b3 --- /dev/null +++ b/doc/how_to_guides/isaac_panda/launch/isaac_demo.launch.py @@ -0,0 +1,135 @@ +import os +from launch import LaunchDescription +from launch.actions import DeclareLaunchArgument +from launch.substitutions import LaunchConfiguration +from launch.conditions import IfCondition, UnlessCondition +from launch_ros.actions import Node +from launch.actions import ExecuteProcess +from ament_index_python.packages import get_package_share_directory +from moveit_configs_utils import MoveItConfigsBuilder + + +def generate_launch_description(): + + # Command-line arguments + ros2_control_hardware_type = DeclareLaunchArgument( + "ros2_control_hardware_type", + default_value="isaac", + description="ROS2 control hardware interface type to use for the launch file -- possible values: [mock_components, isaac]", + ) + + moveit_config = ( + MoveItConfigsBuilder("moveit_resources_panda") + .robot_description( + file_path="config/panda.urdf.xacro", + mappings={ + "ros2_control_hardware_type": LaunchConfiguration( + "ros2_control_hardware_type" + ) + }, + ) + .robot_description_semantic(file_path="config/panda.srdf") + .trajectory_execution(file_path="config/gripper_moveit_controllers.yaml") + .planning_pipelines( + pipelines=["ompl", "chomp", "pilz_industrial_motion_planner"] + ) + .to_moveit_configs() + ) + + # Start the actual move_group node/action server + move_group_node = Node( + package="moveit_ros_move_group", + executable="move_group", + output="screen", + parameters=[moveit_config.to_dict()], + arguments=["--ros-args", "--log-level", "info"], + ) + + # RViz + rviz_config_file = os.path.join( + get_package_share_directory("moveit2_tutorials"), + "config", + "panda_moveit_config.rviz", + ) + + rviz_node = Node( + package="rviz2", + executable="rviz2", + name="rviz2", + output="log", + arguments=["-d", rviz_config_file], + parameters=[ + moveit_config.robot_description, + moveit_config.robot_description_semantic, + moveit_config.robot_description_kinematics, + moveit_config.planning_pipelines, + moveit_config.joint_limits, + ], + ) + + # Static TF + static_tf_node = Node( + package="tf2_ros", + executable="static_transform_publisher", + name="static_transform_publisher", + output="log", + arguments=["0.0", "0.0", "0.0", "0.0", "0.0", "0.0", "world", "panda_link0"], + ) + + # Publish TF + robot_state_publisher = Node( + package="robot_state_publisher", + executable="robot_state_publisher", + name="robot_state_publisher", + output="both", + parameters=[moveit_config.robot_description], + ) + + # ros2_control using FakeSystem as hardware + ros2_controllers_path = os.path.join( + get_package_share_directory("moveit_resources_panda_moveit_config"), + "config", + "ros2_controllers.yaml", + ) + ros2_control_node = Node( + package="controller_manager", + executable="ros2_control_node", + parameters=[moveit_config.robot_description, ros2_controllers_path], + output="screen", + ) + + joint_state_broadcaster_spawner = Node( + package="controller_manager", + executable="spawner", + arguments=[ + "joint_state_broadcaster", + "--controller-manager", + "/controller_manager", + ], + ) + + panda_arm_controller_spawner = Node( + package="controller_manager", + executable="spawner", + arguments=["panda_arm_controller", "-c", "/controller_manager"], + ) + + panda_hand_controller_spawner = Node( + package="controller_manager", + executable="spawner", + arguments=["panda_hand_controller", "-c", "/controller_manager"], + ) + + return LaunchDescription( + [ + ros2_control_hardware_type, + rviz_node, + static_tf_node, + robot_state_publisher, + move_group_node, + ros2_control_node, + joint_state_broadcaster_spawner, + panda_arm_controller_spawner, + panda_hand_controller_spawner, + ] + ) diff --git a/doc/how_to_guides/isaac_panda/launch/isaac_moveit.py b/doc/how_to_guides/isaac_panda/launch/isaac_moveit.py new file mode 100644 index 0000000000..e88af7cfe2 --- /dev/null +++ b/doc/how_to_guides/isaac_panda/launch/isaac_moveit.py @@ -0,0 +1,159 @@ +# -*- coding: utf-8 -*- +# Copyright (c) 2020-2022, NVIDIA CORPORATION. All rights reserved. +# +# NVIDIA CORPORATION and its licensors retain all intellectual property +# and proprietary rights in and to this software, related documentation +# and any modifications thereto. Any use, reproduction, disclosure or +# distribution of this software and related documentation without an express +# license agreement from NVIDIA CORPORATION is strictly prohibited. + +import sys + +import carb +import numpy as np +from omni.isaac.kit import SimulationApp + +FRANKA_STAGE_PATH = "/Franka" +FRANKA_USD_PATH = "/Isaac/Robots/Franka/franka_alt_fingers.usd" +BACKGROUND_STAGE_PATH = "/background" +BACKGROUND_USD_PATH = "/Isaac/Environments/Simple_Room/simple_room.usd" + +CONFIG = {"renderer": "RayTracedLighting", "headless": False} + +# Example ROS2 bridge sample demonstrating the manual loading of stages +# and creation of ROS components +simulation_app = SimulationApp(CONFIG) +import omni.graph.core as og # noqa E402 +from omni.isaac.core import SimulationContext # noqa E402 +from omni.isaac.core.utils import ( # noqa E402 + extensions, + nucleus, + prims, + rotations, + stage, + viewports, +) +from omni.isaac.core_nodes.scripts.utils import set_target_prims # noqa E402 +from pxr import Gf # noqa E402 + +# enable ROS2 bridge extension +extensions.enable_extension("omni.isaac.ros2_bridge") + +simulation_context = SimulationContext(stage_units_in_meters=1.0) + +# Locate Isaac Sim assets folder to load environment and robot stages +assets_root_path = nucleus.get_assets_root_path() +if assets_root_path is None: + carb.log_error("Could not find Isaac Sim assets folder") + simulation_app.close() + sys.exit() + +# Preparing stage +viewports.set_camera_view(eye=np.array([1.2, 1.2, 0.8]), target=np.array([0, 0, 0.5])) + +# Loading the simple_room environment +stage.add_reference_to_stage( + assets_root_path + BACKGROUND_USD_PATH, BACKGROUND_STAGE_PATH +) + +# Loading the franka robot USD +prims.create_prim( + FRANKA_STAGE_PATH, + "Xform", + position=np.array([0, -0.64, 0]), + orientation=rotations.gf_rotation_to_np_array(Gf.Rotation(Gf.Vec3d(0, 0, 1), 90)), + usd_path=assets_root_path + FRANKA_USD_PATH, +) + +simulation_app.update() + +# Creating a action graph with ROS component nodes +try: + og.Controller.edit( + {"graph_path": "/ActionGraph", "evaluator_name": "execution"}, + { + og.Controller.Keys.CREATE_NODES: [ + ("OnImpulseEvent", "omni.graph.action.OnImpulseEvent"), + ("ReadSimTime", "omni.isaac.core_nodes.IsaacReadSimulationTime"), + ("Context", "omni.isaac.ros2_bridge.ROS2Context"), + ("PublishJointState", "omni.isaac.ros2_bridge.ROS2PublishJointState"), + ( + "SubscribeJointState", + "omni.isaac.ros2_bridge.ROS2SubscribeJointState", + ), + ( + "ArticulationController", + "omni.isaac.core_nodes.IsaacArticulationController", + ), + ("PublishClock", "omni.isaac.ros2_bridge.ROS2PublishClock"), + ], + og.Controller.Keys.CONNECT: [ + ("OnImpulseEvent.outputs:execOut", "PublishJointState.inputs:execIn"), + ("OnImpulseEvent.outputs:execOut", "SubscribeJointState.inputs:execIn"), + ("OnImpulseEvent.outputs:execOut", "PublishClock.inputs:execIn"), + ( + "OnImpulseEvent.outputs:execOut", + "ArticulationController.inputs:execIn", + ), + ("Context.outputs:context", "PublishJointState.inputs:context"), + ("Context.outputs:context", "SubscribeJointState.inputs:context"), + ("Context.outputs:context", "PublishClock.inputs:context"), + ( + "ReadSimTime.outputs:simulationTime", + "PublishJointState.inputs:timeStamp", + ), + ("ReadSimTime.outputs:simulationTime", "PublishClock.inputs:timeStamp"), + ( + "SubscribeJointState.outputs:jointNames", + "ArticulationController.inputs:jointNames", + ), + ( + "SubscribeJointState.outputs:positionCommand", + "ArticulationController.inputs:positionCommand", + ), + ( + "SubscribeJointState.outputs:velocityCommand", + "ArticulationController.inputs:velocityCommand", + ), + ( + "SubscribeJointState.outputs:effortCommand", + "ArticulationController.inputs:effortCommand", + ), + ], + og.Controller.Keys.SET_VALUES: [ + # Setting the /Franka target prim to Articulation Controller node + ("ArticulationController.inputs:usePath", True), + ("ArticulationController.inputs:robotPath", FRANKA_STAGE_PATH), + ("PublishJointState.inputs:topicName", "isaac_joint_states"), + ("SubscribeJointState.inputs:topicName", "isaac_joint_commands"), + ], + }, + ) +except Exception as e: + print(e) + + +# Setting the /Franka target prim to Publish JointState node +set_target_prims( + primPath="/ActionGraph/PublishJointState", targetPrimPaths=[FRANKA_STAGE_PATH] +) + +simulation_app.update() + +# need to initialize physics getting any articulation..etc +simulation_context.initialize_physics() + +simulation_context.play() + +while simulation_app.is_running(): + + # Run with a fixed step size + simulation_context.step(render=True) + + # Tick the Publish/Subscribe JointState, Publish TF and Publish Clock nodes each frame + og.Controller.set( + og.Controller.attribute("/ActionGraph/OnImpulseEvent.state:enableImpulse"), True + ) + +simulation_context.stop() +simulation_app.close() diff --git a/doc/how_to_guides/isaac_panda/launch/python.sh b/doc/how_to_guides/isaac_panda/launch/python.sh new file mode 100755 index 0000000000..7dd19bebd8 --- /dev/null +++ b/doc/how_to_guides/isaac_panda/launch/python.sh @@ -0,0 +1,23 @@ +#!/bin/bash + +# Copyright 2023 PickNik Inc. +# All rights reserved. +# +# Unauthorized copying of this code base via any medium is strictly prohibited. +# Proprietary and confidential. + +# Script to call the isaac launch system (see python.sh in the ISAAC_SCRIPT_DIR) + +ISAAC_SCRIPT_DIR="$HOME/.local/share/ov/pkg/isaac_sim-2022.2.0" + +# Prepend the path to all arguments passed in +CUR_SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" +NEW_ARGS="" +for arg in "$@" +do + NEW_ARGS="${NEW_ARGS} ${CUR_SCRIPT_DIR}/${arg}" +done + +pushd ${ISAAC_SCRIPT_DIR} +./python.sh $NEW_ARGS +popd