Skip to content

Modular Rover system computer setup

Martin N edited this page Nov 2, 2024 · 4 revisions

Flash the SD card for Raspberry Pi. https://www.raspberrypi.com/software/

Configure the static IP using sudo nano /etc/network/interfaces Paste the configuration below, change the IP as necessary.

auto eth0
iface eth0 inet static
  address 192.168.69.100     # Static IP
  netmask 255.255.255.0     # Subnet mask
  gateway 192.168.69.1       # Default gateway

The host networking driver is important. docker-compose.yml

version: "3.8"

services:
  ros:
    build: . # Build from Dockerfile in the current directory
    # image: ros:humble-ros-core
    container_name: ros_core
    tty: true
    stdin_open: true
    restart: unless-stopped
    network_mode: host # Use host networking mode here
    volumes:
      - .:/app
      - /dev:/dev # Mounting all /dev devices
      - ./microros_ws:/root/microros_ws
    privileged: true # Add privileged mode here
    command: /bin/bash # Override default command to start a shell
    environment:
      # - ROS_DOMAIN_ID=10
      # - RMW_IMPLEMENTATION=rmw_cyclonedds_cpp
      - ROS_LOCALHOST_ONLY=0
# Remove the networks section entirely
# networks:
#   ros_network:
#     driver: bridge

Dockerfile

# Use the official ROS Humble base image
FROM ros:humble-ros-core

# Set environment variables for ROS and micro-ROS
ENV ROS_DISTRO=humble
ENV WORKSPACE_DIR=/root/microros_ws

# Update and install core dependencies, including rosdep and pip
RUN apt-get update

RUN apt-get install -y \
    git \
    build-essential \
    cmake \
    flex

RUN apt-get install -y \
    python3-colcon-common-extensions \
    python3-rosdep \
    python3-pip

RUN apt-get install -y \
    libasio-dev \
    libtinyxml2-dev \
    libcurl4-openssl-dev

RUN apt-get install -y curl
RUN pip3 install vcstool
RUN apt-get install -y ros-humble-ament-cmake-python
RUN sudo apt-get install -y iputils-ping iproute2
RUN apt-get install -y \
    ros-humble-rmw-cyclonedds-cpp

# Source ROS setup script
RUN echo "source /opt/ros/$ROS_DISTRO/setup.bash" >> ~/.bashrc
SHELL ["/bin/bash", "-c"]

# Create workspace and clone micro-ROS setup repository
RUN mkdir -p $WORKSPACE_DIR/src
WORKDIR $WORKSPACE_DIR/src
RUN if [ ! -d "micro_ros_setup" ]; then \
    git clone -b $ROS_DISTRO https://github.com/micro-ROS/micro_ros_setup.git $WORKSPACE_DIR/src/micro_ros_setup;\
    fi

# Install micro-ROS dependencies
# WORKDIR $WORKSPACE_DIR
# RUN rosdep update
# RUN rosdep install --from-paths src --ignore-src -y
# RUN colcon build
# RUN source install/local_setup.bash
# RUN echo "source $WORKSPACE_DIR/install/local_setup.bash" >> ~/.bashrc

# Set the default command to bash
CMD ["/bin/bash"]

Run

sudo ip route del default via 192.168.69.1 dev eth0
sudo ip route add default via 192.168.69.1 dev eth0 metric 1000

Restart networking services to apply the new configuration sudo systemctl restart networking

Do the same thing for the Linux host. Try ping 192.168.69.100 to see if the modular computer is found.

Clone this wiki locally