Skip to content
Merged
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
3 changes: 1 addition & 2 deletions launch/tutorial_6_launch.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

import xacro
from ament_index_python.packages import get_package_share_directory
from launch import LaunchContext, LaunchDescription
from launch.actions import (
DeclareLaunchArgument,
IncludeLaunchDescription,
Expand All @@ -17,8 +18,6 @@
from launch.substitutions import LaunchConfiguration
from launch_ros.actions import Node

from launch import LaunchContext, LaunchDescription


def get_robot_description_and_controllers(context: LaunchContext, robot_type):
robot_type_str = context.perform_substitution(robot_type)
Expand Down
68 changes: 65 additions & 3 deletions launch/tutorial_7_launch.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

import xacro
from ament_index_python.packages import get_package_share_directory
from launch import LaunchContext, LaunchDescription
from launch.actions import (
DeclareLaunchArgument,
IncludeLaunchDescription,
Expand All @@ -17,8 +18,6 @@
from launch.substitutions import LaunchConfiguration
from launch_ros.actions import Node

from launch import LaunchContext, LaunchDescription


def get_robot_description_and_controllers(context: LaunchContext, robot_type):
robot_type_str = context.perform_substitution(robot_type)
Expand All @@ -45,6 +44,23 @@ def get_robot_description_and_controllers(context: LaunchContext, robot_type):
},
).toxml()

detachable_joint_plugin = f"""
<gazebo>
<plugin filename="gz-sim-detachable-joint-system" name="gz::sim::systems::DetachableJoint">
<parent_link>{robot_type_str}_hand</parent_link>
<child_model>box</child_model>
<child_link>base_link</child_link>
<attach_topic>/box/attach</attach_topic>
<detach_topic>/box/detach</detach_topic>
<suppress_child_warning>true</suppress_child_warning>
</plugin>
</gazebo>
</robot>
"""
robot_description_xml = robot_description_xml.replace(
"</robot>", detachable_joint_plugin
)

# Replace the Franka default controllers YAML with our tutorial controllers
franka_controllers = os.path.join(
get_package_share_directory("franka_gazebo_bringup"),
Expand Down Expand Up @@ -88,6 +104,9 @@ def get_robot_description_and_controllers(context: LaunchContext, robot_type):

def generate_launch_description():
robot_type = LaunchConfiguration("robot_type")
tutorial_share = get_package_share_directory("hpp_tutorial")
box_urdf = os.path.join(tutorial_share, "urdf", "box.urdf")
ground_urdf = os.path.join(tutorial_share, "urdf", "ground.urdf")

# Gazebo Sim
os.environ["GZ_SIM_RESOURCE_PATH"] = os.path.dirname(
Expand All @@ -111,10 +130,51 @@ def generate_launch_description():
output="screen",
)

spawn_box = Node(
package="ros_gz_sim",
executable="create",
arguments=[
"-name",
"box",
"-file",
box_urdf,
"-x",
"0.4",
"-y",
"-0.2",
"-z",
"0.0251",
],
output="screen",
)

spawn_ground = Node(
package="ros_gz_sim",
executable="create",
arguments=[
"-name",
"ground",
"-file",
ground_urdf,
"-x",
"0.0",
"-y",
"0.0",
"-z",
"0.0",
],
output="screen",
)

bridge = Node(
package="ros_gz_bridge",
executable="parameter_bridge",
arguments=["/clock@rosgraph_msgs/msg/Clock[gz.msgs.Clock"],
arguments=[
"/clock@rosgraph_msgs/msg/Clock[gz.msgs.Clock",
"/box/attach@std_msgs/msg/Empty]gz.msgs.Empty",
"/box/detach@std_msgs/msg/Empty]gz.msgs.Empty",
"/world/empty/set_pose@ros_gz_interfaces/srv/SetEntityPose",
],
output="screen",
)

Expand All @@ -126,6 +186,8 @@ def generate_launch_description():
function=get_robot_description_and_controllers, args=[robot_type]
),
spawn,
spawn_ground,
spawn_box,
bridge,
]
)
3 changes: 3 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,8 @@ extend-exclude = ["cmake"]
[tool.ruff.lint]
extend-select = ["I", "NPY", "RUF", "UP", "W"]

[tool.ruff.lint.isort]
known-third-party = ["launch", "launch_ros"]

[tool.tomlsort]
all = true
26 changes: 13 additions & 13 deletions tutorial_6/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
# Extends the base tutorial image with ROS2 control + Gazebo + Franka packages
# for executing planned trajectories on a simulated Panda/FR3 robot.
#
# Build: docker build --build-arg DOCKER_USER=`id -u` --build-arg DOCKER_GROUP=`id -g` -t hpp-tutorial-ros2 .
# Build: docker build --build-arg DOCKER_USER=`id -u` --build-arg DOCKER_GROUP=`id -g` -t hpp-ros2:tuto .
# Run: See tutorial_6/README.md for docker run instructions.

FROM hpp:tuto

ARG FRANKA_DESCRIPTION_VERSION=2.6.0
ARG FRANKA_ROS2_VERSION=v3.2.2

USER root

# ROS2 control packages
Expand All @@ -24,33 +27,30 @@ RUN apt-get update -y && DEBIAN_FRONTEND=noninteractive apt-get install -qqy \
ros-jazzy-sdformat-urdf \
ros-jazzy-gz-ros2-control \
ros-jazzy-ros-gz-sim \
ros-jazzy-ros-gz-bridge \
ros-jazzy-joint-state-publisher-gui \
ros-jazzy-xacro \
&& apt-get clean && rm -rf /var/lib/apt/lists/*

# Franka Panda packages (description + Gazebo bringup)
# Franka packages used by the tutorial. Pin the source versions because the
# upstream jazzy branch can add runtime dependencies for hardware controllers
# that are not needed for this Gazebo-only example.
WORKDIR /opt/franka_ws
RUN mkdir -p src \
&& cd src \
&& git clone --depth 1 https://github.com/frankarobotics/franka_description.git \
&& git clone --branch jazzy --depth 1 https://github.com/frankarobotics/franka_ros2.git

RUN apt-get update && apt-get install -y python3-rosdep \
&& (rosdep init 2>/dev/null || true) \
&& rosdep update \
&& . /opt/ros/jazzy/setup.sh \
&& rosdep install --from-paths src --ignore-src -r -y \
&& apt-get clean && rm -rf /var/lib/apt/lists/*
&& git clone --branch ${FRANKA_DESCRIPTION_VERSION} --depth 1 https://github.com/frankarobotics/franka_description.git \
&& git clone --branch ${FRANKA_ROS2_VERSION} --depth 1 https://github.com/frankarobotics/franka_ros2.git

RUN chown -R user:user /opt/franka_ws

USER user

RUN . /opt/ros/jazzy/setup.sh \
&& colcon build --packages-up-to \
&& colcon build --packages-select \
franka_description \
franka_mobile_sensors \
franka_gazebo_bringup \
--cmake-args -DCMAKE_BUILD_TYPE=Release
--cmake-args -DCMAKE_BUILD_TYPE=Release -DBUILD_TESTING=OFF

RUN echo 'source /opt/franka_ws/install/setup.bash 2>/dev/null' >> /home/user/.bashrc

Expand Down
Loading