Change of direction, we're now deploying as a virtual machine image

This commit is contained in:
Alex Davies 2024-05-09 13:00:38 -03:00
parent 601496f3df
commit 3b3f3bd794
9 changed files with 27 additions and 395 deletions

View File

@ -1,75 +1,21 @@
FROM nestybox/ubuntu-focal-systemd FROM px4io/px4-dev-simulation-focal
ENV ROS_DISTRO noetic
ENV DEBIAN_FRONTEND noninteractive
RUN apt-get update
RUN apt-get install curl gnupg2 software-properties-common -y
RUN sh -c 'curl -s https://raw.githubusercontent.com/ros/rosdistro/master/ros.asc | apt-key add -'
RUN sh -c 'echo "deb http://packages.ros.org/ros/ubuntu $(lsb_release -sc) main" > /etc/apt/sources.list.d/ros-latest.list'
RUN sh -c 'curl -fsSL https://download.docker.com/linux/ubuntu/gpg | apt-key add -'
RUN sh -c 'add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu focal stable"'
# RUN add-apt-repository ppa:flatpak/stable
#Make sure we're running latest gazebo11, since px4io/px4-dev-ros-noetic does.
RUN sh -c "curl -sSL http://get.gazebosim.org | sh"
RUN apt-get update
RUN apt-get install ros-$ROS_DISTRO-ros-core -y
RUN apt-get install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin -y
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 iputils-ping -y
RUN apt-get install firefox -y
RUN apt-get remove gnome-shell -y
RUN apt-get autoremove -y
RUN wget https://github.com/kasmtech/KasmVNC/releases/download/v1.2.0/kasmvncserver_focal_1.2.0_amd64.deb
RUN apt-get install ./kasmvncserver_focal_1.2.0_amd64.deb --yes
RUN rm ./kasmvncserver_focal_1.2.0_amd64.deb
COPY ./kasmvnc.yaml /etc/kasmvnc/kasmvnc.yaml
COPY ./userhome.service /etc/systemd/system/
RUN systemctl enable userhome
COPY ./kasmvnc.service /etc/systemd/system/
RUN systemctl enable kasmvnc
#Custom user skel overrides. We're not going to be too worried about permissions for this one.
COPY ./skel /etc/skel/
#Delete default user and replace it with our own
RUN userdel -r admin
ARG USERNAME=spiri
ARG USER_UID=1000
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,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
COPY --chown=$USER_UID:$USER_GID --chmod=0755 ./xstartup /opt/xstartup
COPY ./background.png /opt/spiri-wallpaper.png
run sed -i 's|/usr/share/lxqt/themes/debian/wallpaper.svg|/opt/spiri-wallpaper.png|' /etc/xdg/pcmanfm-qt/lxqt/settings.conf
#Remove transparency it can make lead to compression artifacts
run sed -i 's|TerminalTransparency=10|/TerminalTransparency=0|' /etc/xdg/qterminal.org/qterminal.ini
#Copy in our custom gazebo resources
COPY --link --from=git.spirirobotics.com/spiri/gazebo-resources:latest /models /usr/share/gazebo-11/models/ COPY --link --from=git.spirirobotics.com/spiri/gazebo-resources:latest /models /usr/share/gazebo-11/models/
COPY --link --from=git.spirirobotics.com/spiri/gazebo-resources:latest /worlds /usr/share/gazebo-11/worlds/ COPY --link --from=git.spirirobotics.com/spiri/gazebo-resources:latest /worlds /usr/share/gazebo-11/worlds/
COPY --link --from=git.spirirobotics.com/spiri/gazebo-resources:latest /plugins /usr/lib/x86_64-linux-gnu/gazebo-11/plugins COPY --link --from=git.spirirobotics.com/spiri/gazebo-resources:latest /plugins /usr/lib/x86_64-linux-gnu/gazebo-11/plugins
VOLUME /home/spiri/ RUN apt-get update && apt-get upgrade --yes
# # #Install nix, for easy mixin packages. Homebrew would also work... #Install base packages for distrobox
# RUN curl -L https://nixos.org/nix/install | sh -s -- --no-daemon # RUN apt-get install --yes bc bzip2 chpasswd curl diff find findmnt gpg hostname less lsof man mount passwd pigz pinentry ping ps rsync script ssh sudo time tree umount unzip useradd wc wget xauth zip
# COPY ./nix.conf /etc/nix/nix.conf
# # # RUN nix flake init WORKDIR /opt/spiri-sdk
# USER 0
RUN git clone --depth 1 -b v1.15.0-beta1 https://github.com/PX4/PX4-Autopilot.git --recursive
WORKDIR /opt/spiri-sdk/PX4-Autopilot/
RUN DONT_RUN=1 make px4_sitl gazebo-classic
#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 lxqt

View File

@ -1,20 +1,18 @@
Make sure sysbox and docker are installed and run # Ways of running
```sh There are two main ways of running this software.
docker run -p 127.0.0.1:8466:8466 \
--volume ./spiri-sdk-home:/home/spiri:rw \ Most users are recomended to install [VirtualBox](https://www.virtualbox.org/) and load the
--runtime=sysbox-runc -it \ virtual appliance file into it.
git.spirirobotics.com/spiri/spiri-sdk-desktop:master
Advanced users can also use the SDK as a docker image. It pairs well with
[distrobox](https://github.com/89luca89/distrobox) to better
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
cd /opt/spiri-sdk/PX4-Autopilot/
make px4_sitl gazebo-classic #Start the simulator
``` ```
Navigate to http://localhost:8466, and log in using the username `spiri` and the password `spiri-friend`.
From inside the SDK use the following commands to start gazebo and a virtual drone.
```
cd ~/sdk/
docker compose up
```
Run `gzclient` to launch gazebo, then insert a `3DR Iris` and your simulated drone will be ready for takeoff.

View File

@ -1,67 +0,0 @@
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. This only applies when using docker-in-docker
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

View File

@ -1,19 +0,0 @@
[Unit]
Description=KasmVNC
After=network.target
[Service]
Type=simple
ExecStart=kasmvncserver :23 -fg -select-de LXQT -xstartup /opt/xstartup
ExectStop=kasmvncserver -kill :23
User=spiri
Group=spiri
Requires=userhome.service
After=userhome.service
Restart=on-failure
RestartSec=3
[Install]
WantedBy=default.target

View File

@ -1,131 +0,0 @@
desktop:
resolution:
width: 1024
height: 768
allow_resize: true
pixel_depth: 24
gpu:
hw3d: false
drinode: /dev/dri/renderD128
network:
protocol: http
interface: 0.0.0.0
websocket_port: auto
use_ipv4: true
use_ipv6: true
udp:
public_ip: auto
port: auto
stun_server: auto
ssl:
pem_certificate: /etc/ssl/certs/ssl-cert-snakeoil.pem
pem_key: /etc/ssl/private/ssl-cert-snakeoil.key
require_ssl: false
user_session:
new_session_disconnects_existing_exclusive_session: false
concurrent_connections_prompt: false
concurrent_connections_prompt_timeout: 10
idle_timeout: never
keyboard:
remap_keys:
ignore_numlock: false
raw_keyboard: false
pointer:
enabled: true
runtime_configuration:
allow_client_to_override_kasm_server_settings: true
allow_override_standard_vnc_server_settings: true
allow_override_list:
- pointer.enabled
- data_loss_prevention.clipboard.server_to_client.enabled
- data_loss_prevention.clipboard.client_to_server.enabled
- data_loss_prevention.clipboard.server_to_client.primary_clipboard_enabled
logging:
log_writer_name: all
log_dest: logfile
level: 30
security:
brute_force_protection:
blacklist_threshold: 5
blacklist_timeout: 10
data_loss_prevention:
visible_region:
# top: 10
# left: 10
# right: 40
# bottom: 40
concealed_region:
allow_click_down: false
allow_click_release: false
clipboard:
delay_between_operations: none
allow_mimetypes:
- chromium/x-web-custom-data
- text/html
- image/png
server_to_client:
enabled: true
size: unlimited
primary_clipboard_enabled: false
client_to_server:
enabled: true
size: unlimited
keyboard:
enabled: true
rate_limit: unlimited
logging:
level: off
encoding:
max_frame_rate: 60
full_frame_updates: none
rect_encoding_mode:
min_quality: 7
max_quality: 8
consider_lossless_quality: 10
rectangle_compress_threads: auto
video_encoding_mode:
jpeg_quality: -1
webp_quality: -1
max_resolution:
width: 1920
height: 1080
enter_video_encoding_mode:
time_threshold: 5
area_threshold: 45%
exit_video_encoding_mode:
time_threshold: 3
logging:
level: off
scaling_algorithm: progressive_bilinear
compare_framebuffer: auto
zrle_zlib_level: auto
hextile_improved_compression: true
server:
http:
headers:
- Cross-Origin-Embedder-Policy=require-corp
- Cross-Origin-Opener-Policy=same-origin
httpd_directory: /usr/share/kasmvnc/www
advanced:
x_font_path: auto
kasm_password_file: ${HOME}/.kasmpasswd
x_authority_file: auto
auto_shutdown:
no_user_session_timeout: never
active_user_session_timeout: never
inactive_user_session_timeout: never
command_line:
prompt: true

View File

@ -1 +0,0 @@
experimental-features = nix-command flakes

View File

@ -1,73 +0,0 @@
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: git.spirirobotics.com/spiri/spiri-sdk-mavros:master
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

View File

@ -1,16 +0,0 @@
[Unit]
Description=Sets permissions on user home, in case user home is a docker mount
After=network.target
[Service]
Type=oneshot
ExecStart=sh -c "rsync /etc/skel/ /home/spiri -r --update && chown spiri:spiri /home/spiri -R"
User=root
Group=root
Restart=on-failure
RestartSec=3
[Install]
WantedBy=default.target

View File

@ -1,5 +0,0 @@
#!/bin/sh
export QT_X11_NO_MITSHM=1
#Set up the users home folder
xdg-user-dirs-update
exec startlxqt