Last active
May 9, 2022 23:20
-
-
Save jhurliman/47c06550ef22216583901b0e86938571 to your computer and use it in GitHub Desktop.
Build depthai-ros from source (OAK-D Luxonis DepthAI)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
docker build -t depthai-ros . | |
docker run \ | |
--rm \ | |
-it \ | |
--privileged \ | |
-v /dev/bus/usb:/dev/bus/usb \ | |
--device-cgroup-rule='c 189:* rmw' \ | |
-e ROS_HOSTNAME=$HOSTNAME \ | |
--net=host \ | |
--name depthai-ros \ | |
depthai-ros |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
FROM ros:noetic-ros-core-focal | |
# Install dependencies for depthai, ros, and build | |
RUN apt-get update && apt-get install -y \ | |
build-essential \ | |
cmake \ | |
git \ | |
libjpeg-dev \ | |
libopencv-dev \ | |
libpng-dev \ | |
libsm6 \ | |
libswscale-dev \ | |
libtbb-dev \ | |
libtbb2 \ | |
libtiff-dev \ | |
pkg-config \ | |
python3-rosdep \ | |
python3-vcstool \ | |
ros-noetic-catkin \ | |
sudo \ | |
wget | |
# Build a custom version of libusb with --disable-udev | |
RUN wget https://github.com/libusb/libusb/releases/download/v1.0.24/libusb-1.0.24.tar.bz2 | |
RUN tar xf libusb-1.0.24.tar.bz2 | |
RUN cd libusb-1.0.24 && \ | |
./configure --disable-udev && \ | |
make -j && make install | |
# Add all users to sudoers so rosdep install can run `sudo apt-get` commands | |
RUN echo '%sudo ALL=(ALL) NOPASSWD:ALL' >> /etc/sudoers | |
# Switch to bash so we can use `source` | |
SHELL ["/bin/bash", "-c"] | |
# One-time initialization of rosdep | |
RUN rosdep init | |
# Create the ubuntu user and ROS1 workspace | |
RUN useradd -ms /bin/bash ubuntu | |
RUN adduser ubuntu sudo | |
USER ubuntu | |
RUN mkdir -p /home/ubuntu/ros1_ws/src | |
WORKDIR /home/ubuntu/ros1_ws | |
# Build depthai-core from source | |
WORKDIR /home/ubuntu | |
RUN git clone https://github.com/luxonis/depthai-core.git | |
WORKDIR /home/ubuntu/depthai-core | |
RUN git submodule update --init --recursive | |
RUN cmake -S. -Bbuild -D'BUILD_SHARED_LIBS=ON' | |
RUN cmake --build build --parallel 4 | |
# Build depthai-ros from source | |
WORKDIR /home/ubuntu/ros1_ws | |
RUN rosdep update | |
RUN wget https://raw.githubusercontent.com/luxonis/depthai-ros/main/underlay.repos | |
RUN vcs import src < underlay.repos | |
RUN rosdep install --from-paths src --ignore-src -r -y | |
RUN source /opt/ros/noetic/setup.bash && catkin_make --cmake-args -D depthai_DIR=/home/ubuntu/depthai-core/build/ | |
CMD source devel/setup.bash && roslaunch depthai_examples stereo_inertial_node.launch |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
# Setup udev rules on the host | |
echo 'SUBSYSTEM=="usb", ATTRS{idVendor}=="03e7", MODE="0666"' | sudo tee /etc/udev/rules.d/80-movidius.rules | |
sudo udevadm control --reload-rules && sudo udevadm trigger |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment