diff --git a/README.md b/README.md index 102d81b..289c6a7 100644 --- a/README.md +++ b/README.md @@ -51,7 +51,7 @@ Before developing please read these documents. ## CAN Setup -If trying to stimulate robot using canable, you will need to set up the CAN interface. +If you are stimulating the robot using canable, you will need to set up the CAN interface. Run the setup script: ```bash diff --git a/autonomy/perception/launch/perception.launch.py b/autonomy/perception/launch/perception.launch.py index 73447e3..6497cad 100644 --- a/autonomy/perception/launch/perception.launch.py +++ b/autonomy/perception/launch/perception.launch.py @@ -23,5 +23,20 @@ def generate_launch_description(): remappings=[ # Add any topic remappings here if needed ] + ), + Node( + package='realsense2_camera', + executable='realsense2_camera_node', + name='realsense_node', + output='screen', + parameters=[{ + 'depth_module.depth_profile': '640x480x30', + 'pointcloud.enable': True, + 'enable_rgbd': True, + 'enable_sync': True, + 'align_depth.enable': True, + 'enable_color': True, + 'enable_depth': True + }] ) ]) diff --git a/autonomy/perception/package.xml b/autonomy/perception/package.xml index 6e7e2f9..59b5cd8 100644 --- a/autonomy/perception/package.xml +++ b/autonomy/perception/package.xml @@ -11,7 +11,6 @@ ament_copyright diff --git a/docker/perception/perception.Dockerfile b/docker/perception/perception.Dockerfile index 6835dc3..96b3a44 100644 --- a/docker/perception/perception.Dockerfile +++ b/docker/perception/perception.Dockerfile @@ -3,43 +3,44 @@ ARG BASE_IMAGE=ghcr.io/watonomous/robot_base/base:humble-ubuntu22.04 ################################ Source ################################ FROM ${BASE_IMAGE} AS source -ARG AMENT_WS=/root/ament_ws WORKDIR ${AMENT_WS}/src # Copy in source code COPY autonomy/perception perception COPY autonomy/wato_msgs/common_msgs wato_msgs/common_msgs -# Scan for rosdeps -# RUN apt-get -qq update -# RUN rosdep update -# RUN rosdep install --from-paths . --ignore-src -r -s \ -# | grep 'apt-get install' \ -# | awk '{print $3}' \ -# | sort > /tmp/colcon_install_list +# Install rosdep if not present, update package lists +RUN apt-get update && \ + apt-get install -y --no-install-recommends python3-rosdep && \ + rm -rf /var/lib/apt/lists/* -RUN apt-get -qq update +# Update rosdep database (safe in containers) RUN rosdep update -RUN echo "" > /tmp/colcon_install_list + +# Generate dependency list (simulated install → extract apt packages) +RUN rosdep install \ + --from-paths . \ + --ignore-src \ + --rosdistro $ROS_DISTRO \ + -y \ + --simulate | \ + grep "apt-get install" | \ + sed 's/apt-get install -y //' > /tmp/colcon_install_list || true ################################# Dependencies ################################ FROM ${BASE_IMAGE} AS dependencies # Install Rosdep requirements COPY --from=source /tmp/colcon_install_list /tmp/colcon_install_list -RUN apt-fast install -qq -y --no-install-recommends $(cat /tmp/colcon_install_list) + +RUN apt-get update && \ + apt-fast install -qq -y --no-install-recommends $(cat /tmp/colcon_install_list) # Dependency Cleanup WORKDIR / RUN apt-get -qq autoremove -y && apt-get -qq autoclean && apt-get -qq clean && \ rm -rf /root/* /root/.ros /tmp/* /var/lib/apt/lists/* /usr/share/doc/* -# Avoid interactive package prompts -ENV DEBIAN_FRONTEND=noninteractive \ - TZ=Etc/UTC \ - LANG=C.UTF-8 \ - LC_ALL=C.UTF-8 - # Essential build & Python tooling RUN apt-get update && \ apt-get install -y --no-install-recommends \ @@ -55,8 +56,18 @@ RUN apt-get update && \ ca-certificates \ gnupg2 \ libgl1-mesa-glx \ - lsb-release && \ - rm -rf /var/lib/apt/lists/* + lsb-release \ + libssl-dev \ + usbutils \ + libusb-1.0-0-dev \ + pkg-config \ + libgtk-3-dev + +RUN apt-get update && \ + apt-get install -y --no-install-recommends \ + ros-$ROS_DISTRO-librealsense2* \ + ros-$ROS_DISTRO-realsense2-camera* && \ + rm -rf /var/lib/apt/lists/* RUN python3 -m pip install --upgrade pip @@ -64,30 +75,30 @@ RUN python3 -m pip install --no-cache-dir \ pccm>=0.4.16 \ ccimport>=0.4.4 \ pybind11>=2.6.0 \ + cv_bridge \ numpy \ fire \ - cv_bridge \ opencv-python -# Install prebuilt spconv-cu120 (compatible with CUDA 12.2 due to minor version compatibility) -RUN python3 -m pip install --no-cache-dir spconv-cu120 - # Dependency Cleanup WORKDIR / RUN apt-get -qq autoremove -y && apt-get -qq autoclean && apt-get -qq clean && \ - rm -rf /root/* /root/.ros /tmp/* /var/lib/apt/lists/* /usr/share/doc/* + rm -rf /root/.ros /tmp/* /var/lib/apt/lists/* /usr/share/doc/* ################################ Build ################################ FROM dependencies AS build -ARG AMENT_WS=/root/ament_ws +COPY --from=source ${AMENT_WS}/src ${AMENT_WS}/src + # Build ROS2 packages WORKDIR ${AMENT_WS} + RUN . /opt/ros/$ROS_DISTRO/setup.sh && \ colcon build \ - --cmake-args -DCMAKE_BUILD_TYPE=Release --install-base ${WATONOMOUS_INSTALL} + --cmake-args -DCMAKE_BUILD_TYPE=Release \ + --install-base ${WATONOMOUS_INSTALL} # Source and Build Artifact Cleanup -RUN rm -rf src/* build/* devel/* install/* log/* +RUN rm -rf build/* devel/* install/* log/* # Entrypoint will run before any CMD on launch. Sources ~/opt//setup.bash and ~/ament_ws/install/setup.bash COPY docker/wato_ros_entrypoint.sh ${AMENT_WS}/wato_ros_entrypoint.sh diff --git a/modules/docker-compose.perception.yaml b/modules/docker-compose.perception.yaml index 14f9030..770cdd1 100644 --- a/modules/docker-compose.perception.yaml +++ b/modules/docker-compose.perception.yaml @@ -22,9 +22,12 @@ services: devices: - driver: nvidia capabilities: [gpu] + devices: + - /dev/bus/usb:/dev/bus/usb + privileged: true volumes: - ${MONO_DIR}/autonomy/perception:/root/ament_ws/src/perception - command: tail -F anything + command: /bin/bash -c "ros2 launch perception perception.launch.py" perception_dev: build: *perception_build @@ -34,6 +37,10 @@ services: - NVIDIA_VISIBLE_DEVICES=all - NVIDIA_DRIVER_CAPABILITIES=compute,utility profiles: [develop] + privileged: true + devices: + - /dev/bus/usb:/dev/bus/usb volumes: - ${MONO_DIR}/autonomy/perception:/root/ament_ws/src/perception - command: tail -F anything + command: /bin/bash -c "ros2 launch perception perception.launch.py" + # command: tail -f /dev/null diff --git a/watod-config.sh b/watod-config.sh index 6651432..32d00df 100755 --- a/watod-config.sh +++ b/watod-config.sh @@ -13,7 +13,6 @@ ## - infrastructure : starts visualization tools ## - interfacing : starts interfacing nodes ## - perception : starts perception nodes -## - controller : starts controller nodes ## - simulation : starts simulation ## - behaviour : starts behaviour nodes ## - samples : starts sample ROS2 pubsub nodes