From 3345b0ba07e13fe69a716ba8ddbc06762266a1ad Mon Sep 17 00:00:00 2001 From: Alex Davies Date: Tue, 28 May 2024 14:30:18 -0300 Subject: [PATCH] Tidied permissions, installed docker daemon in VM --- Dockerfile | 26 +++-- README.md | 9 ++ ova-compose.yml | 74 ------------ .../simulated-drone/docker-compose.yaml | 109 ++++++++++++++++++ 4 files changed, 136 insertions(+), 82 deletions(-) delete mode 100644 ova-compose.yml create mode 100644 skel/Desktop/simulated-drone/docker-compose.yaml diff --git a/Dockerfile b/Dockerfile index ac5967a..4d0b891 100644 --- a/Dockerfile +++ b/Dockerfile @@ -15,14 +15,24 @@ RUN git clone --depth 1 -b v1.15.0-beta1 https://github.com/PX4/PX4-Autopilot.gi WORKDIR /opt/spiri-sdk/PX4-Autopilot/ RUN DONT_RUN=1 make px4_sitl gazebo-classic -RUN apt-get install --yes virtualbox-guest-dkms virtualbox-guest-utils +RUN apt-get install --yes virtualbox-guest-dkms virtualbox-guest-utils spice-vdagent qemu-guest-agent +RUN apt-get install --yes docker-compose-v2 firefox +#Install our desktop environment last +RUN apt-get install --yes --no-install-recommends lubuntu-desktop sddm + +COPY ./skel/ /opt/spiri-sdk/user-home-skeleton/ +RUN cp -r /opt/spiri-sdk/user-home-skeleton/* /etc/skel/ + +RUN useradd -m -s /bin/bash spiri && echo 'spiri:spiri-friend' | chpasswd +RUN usermod -aG sudo,docker spiri +RUN userdel user + + +#Install vscodium, a vscode fork with no telemetry and a worse package store +# RUN sh -c "curl -fSsL https://gitlab.com/paulcarroty/vscodium-deb-rpm-repo/raw/master/pub.gpg | sudo gpg --dearmor | sudo tee /usr/share/keyrings/vscodium.gpg > /dev/null" +# RUN "echo deb [signed-by=/usr/share/keyrings/vscodium.gpg] https://download.vscodium.com/debs vscodium main | sudo tee /etc/apt/sources.list.d/vscodium.list" +# RUN apt update +# RUN apt install codium --yes #This should be the first real user created and the `users` group on most linux distros RUN chown -R 1000:100 /opt/spiri-sdk -#Install our desktop environment last -RUN apt-get install --yes --no-install-recommends lxqt - -RUN useradd -m -s /bin/bash spiri && echo 'spiri:spiri-friend' | chpasswd - -# Optional: Add spiri to sudo group if needed -RUN usermod -aG sudo spiri diff --git a/README.md b/README.md index 6d13921..72f11c2 100644 --- a/README.md +++ b/README.md @@ -14,6 +14,8 @@ integrate it with their existing linux workflows. ```bash distrobox create --image git.spirirobotics.com/spiri/spiri-sdk-desktop:main distrobox enter spiri-sdk-desktop-main +#You can optionally copy the standard SDK setup from /opt/spiri-sdk/user-home-skeleton/ +# cp -r /opt/spiri-sdk/user-home-skeleton/* ~/ cd /opt/spiri-sdk/PX4-Autopilot/ make px4_sitl gazebo-classic #Start the simulator ``` @@ -25,3 +27,10 @@ make px4_sitl gazebo-classic #Start the simulator # We mount the current working directory in the docker container as part of this script. ./virtualize.sh build ./ -s 100gb -o sdk.vdi ``` + +For testing the VM, I use the following + +```bash +./virtualize.sh build ./ -s 100gb -o sdk.qcow2 +qemu-system-x87_64 -display default,show-cursor=on -enable-kvm -device virtio-gpu -m 4g -smp 4 -hda sdk.qcow2 +``` diff --git a/ova-compose.yml b/ova-compose.yml deleted file mode 100644 index 503f51c..0000000 --- a/ova-compose.yml +++ /dev/null @@ -1,74 +0,0 @@ -system: - name: spiri-sdk - type: vmx-17 - os_vmw: other4xLinux64Guest - firmware: efi - secure_boot: false - -networks: - vm_network: - name: "VM Network" - description: "The VM Network network" - -hardware: - cpus: 2 - memory: 2048 - # sata1: - # type: sata_controller - scsi1: - type: scsi_controller - # cdrom1: - # type: cd_drive - # parent: sata1 - rootdisk: - type: hard_disk - parent: scsi1 - #Set automatically as part of our pipeline, do not change - disk_image: output.vmdk - usb1: - type: usb_controller - # ethernet1: - # type: ethernet - # subtype: VmxNet3 - # network: vm_network - # videocard1: - # type: video_card - # vmci1: - # type: vmci - -# configurations: -# tall: -# label: Tall -# description: too little for the money -# grande: -# label: Grande -# description: just right -# venti: -# label: Venti -# description: too much - -# environment: -# transports: -# - com.vmware.guestInfo -# - iso -# categories: -# email: Email Settings -# properties: -# guestinfo.admin.email: -# value: admin@company.org -# user_configurable: true -# type: string -# description: "The Admin's email address" -# label: "Email Address" -# category: email - -# extra_configs: -# feature.enabled: -# required: false -# value: true -# log.rotateSize: -# value: 2048000 - -product: - product: Spiri SDK desktop - vendor: Spiri Robotics diff --git a/skel/Desktop/simulated-drone/docker-compose.yaml b/skel/Desktop/simulated-drone/docker-compose.yaml new file mode 100644 index 0000000..dcd944c --- /dev/null +++ b/skel/Desktop/simulated-drone/docker-compose.yaml @@ -0,0 +1,109 @@ +version: "3.8" + +services: + + gscam: + image: git.spirirobotics.com/spiri/services-ros1-gscam_all_in_one:main + runtime: nvidia + environment: + ROS_MASTER_URI: http://localhost:11311 + ROS_LOG_LEVEL: DEBUG + PORT_GSCAM_CONFIG: > + nvarguscamerasrc sensor-id=0 aelock=true awblock=true ! video/x-raw(memory:NVMM), width=(int)$(arg width), height=(int)$(arg height), format=(string)NV12, framerate=(fraction)$(arg fps)/1 ! nvvidconv flip-method=0 ! video/x-raw, format=(string)BGRx ! videoconvert ! video/x-raw, format=(string)BGR + STARBOARD_GSCAM_CONFIG: > + nvarguscamerasrc sensor-id=1 aelock=true awblock=true ! video/x-raw(memory:NVMM), width=(int)$(arg width), height=(int)$(arg height), format=(string)NV12, framerate=(fraction)$(arg fps)/1 ! nvvidconv flip-method=0 ! video/x-raw, format=(string)BGRx ! videoconvert ! video/x-raw, format=(string)BGR + volumes: + - /tmp/argus_socket:/tmp/argus_socket + + udp-stream: + image: git.spirirobotics.com/spiri/services-ros1-gscam_all_in_one:main + privileged: true + runtime: nvidia + network_mode: host + environment: + DISPLAY: ":0" + volumes: + - /tmp/argus_socket:/tmp/argus_socket + - /tmp/.X11-unix:/tmp/.X11-unix + - /var/run/xauth/:/var/run/xauth/ + command: > + gst-launch-1.0 + nvarguscamerasrc sensor-id=0 + ! 'video/x-raw(memory:NVMM), width=(int)1280, height=(int)720, format=(string)NV12, framerate=(fraction)60/1' + ! tee name=raw + raw. ! queue + ! nvegltransform ! nveglglessink sync=false async=false + raw. ! queue + ! videorate max-rate=30 drop-only=true + ! queue max-size-buffers=3 leaky=downstream + ! nvv4l2h265enc + bitrate=2000000 + iframeinterval=300 + vbv-size=33333 + insert-sps-pps=true + control-rate=constant_bitrate + profile=Main + num-B-Frames=0 + ratecontrol-enable=true + preset-level=UltraFastPreset + EnableTwopassCBR=false + maxperf-enable=true + ! rtph265pay name=pay0 pt=96 config-interval=-1 mtu=1400 + ! udpsink host=192.168.1.100 auto-multicast=false port=5600 sync=false async=false + + mavproxy: + image: git.spirirobotics.com/spiri/services-mavproxy:main + command: > + mavproxy.py --non-interactive + --out=udpin:0.0.0.0:14551 + --out=udpin:0.0.0.0:14550 + --out=tcpin:0.0.0.0:5760 + --master=/dev/ttyTHS2 --baudrate 921600 + restart: always + devices: + - "/dev/ttyTHS2:/dev/ttyTHS2" + ports: + - "14550:14550/udp" + - "5760:5760/tcp" + + mavros: + #This service bridges our mavlink-based robot-coprosessor into ROS + #In this example it connects to a simulated coprocessor. + image: git.spirirobotics.com/spiri/services-ros1-mavros:master + command: roslaunch mavros px4.launch fcu_url:="udp://:14555@mavproxy:14550" + environment: + - "ROS_MASTER_URI=http://ros-master:11311" + depends_on: + ros-master: + condition: service_healthy + mavproxy: + condition: service_started + restart: always + deploy: + resources: + limits: + # cpus: '0.01' + memory: 200M + ulimits: + nofile: + soft: 1024 + hard: 524288 + + ros-master: + image: git.spirirobotics.com/spiri/services-ros1-core:main + command: stdbuf -o L roscore + environment: + - "ROS_MASTER_URI=http://ros-master:11311" + restart: always + ports: + - "0.0.0.0:11311:11311" + deploy: + resources: + limits: + 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