Skip to content

Instantly share code, notes, and snippets.

@HiceS
Last active January 31, 2025 22:04
Show Gist options
  • Save HiceS/ecbbb992fd13bdc3e171a7cbd0e8476d to your computer and use it in GitHub Desktop.
Save HiceS/ecbbb992fd13bdc3e171a7cbd0e8476d to your computer and use it in GitHub Desktop.
Kortex URDF Docker File
# Use the official ROS Noetic base image
FROM ros:noetic-ros-base-focal
# Make sure the package repository is up to date
RUN apt-get update && apt-get install -y \
curl \
gnupg2 \
&& rm -rf /var/lib/apt/lists/*
# Add the ROS repository to the sources list
RUN echo "deb http://packages.ros.org/ros/ubuntu $(lsb_release -sc) main" > /etc/apt/sources.list.d/ros-latest.list
RUN curl -s https://raw.githubusercontent.com/ros/rosdistro/master/ros.asc | apt-key add -
RUN apt-get update && apt-get install -y \
git \
python3-rosdep \
python3-catkin-tools \
python3-wstool \
python3-pip \
&& rm -rf /var/lib/apt/lists/*
RUN rosdep update
RUN apt-get update
ENV KINOVA_WS /root/kinova_ws
RUN mkdir -p $KINOVA_WS/src
WORKDIR $KINOVA_WS
RUN pip3 install conan==1.59
RUN conan config set general.revisions_enabled=1
RUN conan profile new default --detect > /dev/null
RUN conan profile update settings.compiler.libcxx=libstdc++11 default
ENV CONAN_BUILD_POLICY=missing
# Clone the Kinova description repository into the workspace
RUN git clone -b noetic-devel https://github.com/Kinovarobotics/ros_kortex.git src/ros_kortex
RUN rosdep install --from-paths src --ignore-src -y
RUN /bin/bash -c "source /opt/ros/noetic/setup.bash && catkin_make -DCONAN_TARGET_PLATFORM=jetson"
RUN echo "source $KINOVA_WS/devel/setup.bash" >> ~/.bashrc
# Define variables you can change to re-generate the output.
ENV XACRO_FILE gen3.xacro
ENV SIM false
ENV DOF 6
ENV GRIPPER robotiq_2f_85
# Original output location ?
RUN mkdir $KINOVA_WS/src/ros_kortex/kortex_description/urdf
RUN mkdir -p /output
# RUN "rosrun xacro xacro --inorder $KINOVA_WS/src/ros_kortex/kortex_description/robots/$XACRO_FILE sim:=$SIM"
# Generate the URDF file using xacro
RUN /bin/bash -c "source /opt/ros/noetic/setup.bash && \
source $KINOVA_WS/devel/setup.bash && \
rosrun xacro xacro $KINOVA_WS/src/ros_kortex/kortex_description/robots/$XACRO_FILE sim:=$SIM dof:=$DOF gripper:=$GRIPPER \
> /output/$XACRO_FILE.urdf"
# CMD ["/bin/bash"]
@HiceS
Copy link
Author

HiceS commented Jan 31, 2025

Build with buildx using the following

This annoyingly copies the entire root directory but you only need the output folder in the output folder.

docker buildx build --output type=local,dest=./output_dir,output=/output .

Change the following params to re-generate

ENV SIM false
ENV DOF 6
ENV GRIPPER robotiq_2f_85

TODO: If someone is using this in the future can you please make this a 2 step build which copies over the created files.

@HiceS
Copy link
Author

HiceS commented Jan 31, 2025

This version works for ARM based Macbooks.

Remove the following to make it work for x86 based processors:

 -DCONAN_TARGET_PLATFORM=jetson

@HiceS
Copy link
Author

HiceS commented Jan 31, 2025

NOTE: The default amount of memory is not enough to run this on a given docker installation. Try to increase to at least 16gb.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment