From 69ba51fa209cda5b88a17cdcb34e0005e1b90f83 Mon Sep 17 00:00:00 2001 From: Alex Davies Date: Tue, 23 Jan 2024 15:47:46 -0400 Subject: [PATCH] Almost done --- Dockerfile | 4 +- README.md | 74 ++---------------------------- docker-compose.yaml | 2 +- skel/spiri-sdk/docker-compose.yaml | 73 +++++++++++++++++++++++++++++ 4 files changed, 81 insertions(+), 72 deletions(-) create mode 100644 skel/spiri-sdk/docker-compose.yaml diff --git a/Dockerfile b/Dockerfile index ac78b8d..e2e01a1 100644 --- a/Dockerfile +++ b/Dockerfile @@ -21,7 +21,7 @@ RUN apt-get install docker-ce docker-ce-cli containerd.io docker-buildx-plugin d RUN apt-get install ros-$ROS_DISTRO-gazebo-ros-pkgs ros-$ROS_DISTRO-gazebo-ros-control gazebo11 -y RUN apt-get install ros-$ROS_DISTRO-mavros -y RUN apt-get install lxqt-core dbus-x11 udisks2- gvfs-daemons- gvfs-backends- gvfs-fuse- -y #A few things related to FUSE need to be explicityly not installed -RUN apt-get install vim nano htop git mesa-utils rsync -y +RUN apt-get install vim nano htop git mesa-utils rsync iputils-ping -y RUN apt-get install firefox -y RUN apt-get remove gnome-shell -y @@ -49,7 +49,7 @@ ARG USER_GID=$USER_UID RUN groupadd --gid $USER_GID $USERNAME RUN useradd --uid $USER_UID --gid $USER_GID --create-home --shell /bin/bash $USERNAME -RUN usermod -aG sudo,ssl-cert $USERNAME +RUN usermod -aG sudo,ssl-cert,docker $USERNAME RUN echo "$USERNAME ALL=(ALL) NOPASSWD:ALL" >> /etc/sudoers.d/$USERNAME RUN chmod 0440 /etc/sudoers.d/$USERNAME RUN echo "${USERNAME}:spiri-friend" | chpasswd diff --git a/README.md b/README.md index 7bff7f4..baa775a 100644 --- a/README.md +++ b/README.md @@ -8,75 +8,11 @@ docker run -p 127.0.0.1:8466:8466 \ git.spirirobotics.com/spiri/spiri-sdk-desktop:master ``` -Navigate to http://localhost:8466, and log in using the username `spiri` and the password `spiri-friend` +Navigate to http://localhost:8466, and log in using the username `spiri` and the password `spiri-friend`. -For a complete example try this: +From inside the SDK use the following commands to start gazebo and a virtual drone. -```yaml -version: "3.3" - -#Due to a bug in moby's libnetwork DNS resolver single domains like `gazebo` -# don't get resolved properly, even when we have ndots set to 0 like we're -# supposed to. So we need to reference `gazebo.compose-name_network-name`. -# We explicitly set the name variable so that changing folders doesn't break -# the install. -name: "spiri-sdk" - -volumes: - user-home: - dockeradmin: - docker-cache: - -services: - - drone-stack: - #The drone runs docker, so ultimately our drone stack is just a docker-in-docker container. - ## This can make it difficult to deal with GPU acceleration, but remember that ROS *is* - ## distributed. You don't need to run your GPU-accelerated rosnode on the drone-stack, - ## just make sure you can contact the ROS_MASTER. - runtime: sysbox-runc - image: docker:24-dind - command: dockerd -H unix:///var/run/docker.sock -H tcp://0.0.0.0:2375 --tls=false - healthcheck: - test: docker info - start_interval: 1s - ports: - - "127.0.0.1:5760:5760" #Ground control - - "127.0.0.1:4560:4560" # Simulation - - "127.0.0.1:14560:14560" # Simulation - - "127.0.0.1:11311:11311" #Ros master - - volumes: - - docker-cache:/var/lib/docker/ - - #Madness, setting a low ulimit here fixes memory leaks - # https://answers.ros.org/question/336963/rosout-high-memory-usage/ - ulimits: - nofile: - soft: 1024 - hard: 524288 - - gazebo: - image: git.spirirobotics.com/spiri/gazebo-classic:main - # command: gzserver --verbose /usr/share/gazebo-11/worlds/empty.world - command: gzserver --verbose /usr/share/gazebo-11/worlds/citadel_hill_world.world - ports: - - "127.0.0.1:11345:11345" #Ros master - - desktop: - image: git.spirirobotics.com/spiri/spiri-sdk-desktop:master - runtime: sysbox-runc - tty: true - environment: - DOCKER_HOST: tcp://drone-stack:2375 - ROS_MASTER_URI: http://drone-stack:11311 - GAZEBO_MASTER_URI: http://gazebo.spiri-sdk_default:11345 - - ports: - - 127.0.0.1:8466:8466 - volumes: - - ./spiri-sdk-home:/home/spiri - depends_on: - drone-stack: - condition: service_healthy +``` +cd ~/sdk/ +docker compose up ``` diff --git a/docker-compose.yaml b/docker-compose.yaml index 0d4cbfe..5408dfd 100644 --- a/docker-compose.yaml +++ b/docker-compose.yaml @@ -4,7 +4,7 @@ version: "3.3" # don't get resolved properly, even when we have ndots set to 0 like we're # supposed to. So we need to reference `gazebo.compose-name_network-name`. # We explicitly set the name variable so that changing folders doesn't break -# the install. +# the install. This only applies when using docker-in-docker name: "spiri-sdk" volumes: diff --git a/skel/spiri-sdk/docker-compose.yaml b/skel/spiri-sdk/docker-compose.yaml new file mode 100644 index 0000000..37c4283 --- /dev/null +++ b/skel/spiri-sdk/docker-compose.yaml @@ -0,0 +1,73 @@ +version: "3" + +name: "spiri-sdk" + +services: + + gazebo: + image: git.spirirobotics.com/spiri/gazebo-classic:main + # command: gzserver --verbose /usr/share/gazebo-11/worlds/empty.world + command: gzserver --verbose /usr/share/gazebo-11/worlds/citadel_hill_world.world + ports: + - 127.0.0.1:11345:11345 + + robot-coprocessor-simulation: + image: git.spirirobotics.com/spiri/px4-sim:master + environment: + ROS_MASTER_URI: "http://ros-master:11311" + GAZEBO_MASTER_URI: http://gazebo.spiri-sdk_default:11345 + + # MAVLINK_REPORT_STATS: "True" + PX4_SYS_AUTOSTART: 4001 #Generic Quadrotor X https://docs.px4.io/main/en/airframes/airframe_reference.html#quadrotor-x + PX4_SIMULATOR: "remote" # If we leave this field blank in the config file, the simulator will be set to 'gz' by default. To override this and use a remote simulator instead, we need to assign any value (in this case, "remote") to this field. + PX4_SIM_HOSTNAME: gazebo.spiri-sdk_default + restart: always + ports: + - "5760:5760" #Ground control + - "4560:4560" # Simulation + - "14560:14560" # Simulation + + mavros: + #This service bridges our mavlink-based robot-coprosessor into ROS + #In this example it connects to a simulated coprocessor. + image: radarku/mavros + command: roslaunch mavros px4.launch fcu_url:="udp://:14540@robot-coprocessor-simulation:14541" + environment: + - "ROS_MASTER_URI=http://ros-master:11311" + depends_on: + ros-master: + condition: service_healthy + deploy: + resources: + limits: + # cpus: '0.01' + memory: 200M + ulimits: + nofile: + soft: 1024 + hard: 524288 + + ros-master: + image: ros:noetic-ros-core + #command: roscore + command: stdbuf -o L roscore + environment: + - "ROS_MASTER_URI=http://ros-master:11311" + healthcheck: + test: ["CMD", "/ros_entrypoint.sh", "rostopic", "list"] + retries: 6 + restart: always + ports: + - 11311:11311 + deploy: + resources: + limits: + # cpus: '0.01' + memory: 1G + # #Madness, setting a low ulimit here fixes memory leaks + # # https://answers.ros.org/question/336963/rosout-high-memory-usage/ + ulimits: + nofile: + soft: 1024 + hard: 524288 +