Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 0 additions & 49 deletions .github/workflows/update-image.yml

This file was deleted.

7 changes: 7 additions & 0 deletions .script/complete/_play-autoaim
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#compdef play-autoaim

_arguments \
'--user[指定远程用户名]:用户名:' \
'--remote[从设备拉取 SDP 到容器]' \
'--no-copy[跳过容器到宿主机的拷贝]'\
'--ip[监视端的 IP 地址]'
22 changes: 22 additions & 0 deletions .script/complete/_set-remote
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#compdef set-remote

_remote_hosts() {
local hosts=(
"169.254.233.233"
"alliance-sentry.local"
"alliance-infantry.local"
"alliance-hero.local"
)

# 从 ~/.ssh/config 提取最近使用的 HostName
if [[ -f ~/.ssh/config ]]; then
local extracted
extracted=(${(f)"$(grep -A1 'Host remote' ~/.ssh/config | grep HostName | awk '{print $2}')"})
hosts+=(${extracted})
fi

compadd -- $hosts
}

_arguments \
'1:远程主机地址:_remote_hosts'
5 changes: 5 additions & 0 deletions .script/foxglove
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#! /bin/bash

source ~/env_setup.bash

ros2 launch foxglove_bridge foxglove_bridge_launch.xml port:=8765
82 changes: 59 additions & 23 deletions .script/play-autoaim
Original file line number Diff line number Diff line change
@@ -1,38 +1,74 @@
#!/bin/sh

if [ "$#" -ne 1 ]; then
echo "用法: $0 <用户名>"
echo "示例: $0 user"
exit 1
fi
set -e

REMOTE_PLAYER="vlc"
MONITOR_USER=""
MONITOR_PLAYER="vlc"
MONITOR_HOST="localhost"

REMOTE_USER="$1"
REMOTE_HOST="localhost"
SDP_PATH="/tmp/auto_aim.sdp"

REMOTE_PATH="/tmp/auto_aim.sdp"
LOCAL_PATH="/tmp/auto_aim.sdp"
USE_REMOTE=false
SKIP_COPY=false

# 参数解析
while [ "$#" -gt 0 ]; do
case "$1" in
--user)
shift
[ -z "$1" ] && echo "❌ --user 参数缺失" && exit 1
MONITOR_USER="$1"
;;
--remote)
USE_REMOTE=true
;;
--no-copy)
SKIP_COPY=true
;;
--ip)
shift
[ -z "$1" ] && echo "❌ --ip 参数缺失" && exit 1
MONITOR_HOST="$1"
;;
*)
echo "未知参数: $1"
echo "用法: $0 --user <用户名> [--remote] [--no-copy]"
exit 1
;;
esac
shift
done

scp remote:${REMOTE_PATH} ${REMOTE_PATH}
if [ $? -ne 0 ]; then
echo "⚠️ 从 remote 拷贝失败。是否继续?(y/n)"
if [ -z "$MONITOR_USER" ]; then
echo "❌ 缺少 --user 参数"
echo "用法: play-autoaim --user <用户名> [--remote] [--no-copy]"
exit 1
fi

if [ "$USE_REMOTE" = true ]; then
scp remote:${SDP_PATH} ${SDP_PATH}
if [ $? -ne 0 ]; then
echo " 从 remote 拷贝失败。是否继续?(y/n)"
read -r answer
case "$answer" in
[Yy]*) echo "继续执行后续操作…" ;;
[Yy]*) echo "继续执行后续操作…" ;;
*)
echo "已取消。"
exit 1
;;
echo "已取消。"
exit 1
;;
esac
fi
fi

scp "${REMOTE_PATH}" "${REMOTE_USER}@${REMOTE_HOST}:${LOCAL_PATH}"
if [ $? -ne 0 ]; then
echo "❌ scp 拷贝失败"
if [ "$SKIP_COPY" = false ]; then
scp "${SDP_PATH}" "${MONITOR_USER}@${MONITOR_HOST}:${SDP_PATH}"
if [ $? -ne 0 ]; then
echo " scp 拷贝失败"
exit 1
fi
echo " 文件已拷贝到宿主机:${SDP_PATH}"
else
echo " 跳过拷贝,直接打开远程 SDP"
fi

echo "✅ 文件已拷贝到宿主机:${LOCAL_PATH}"

ssh -f "${REMOTE_USER}@${REMOTE_HOST}" "DISPLAY=:0 ${REMOTE_PLAYER} '${LOCAL_PATH}'"
ssh -f "${MONITOR_USER}@${MONITOR_HOST}" "DISPLAY=:0 ${MONITOR_PLAYER} '${SDP_PATH}' --network-caching=50"
2 changes: 1 addition & 1 deletion .script/template/env_setup.bash
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/bin/bash

export ROS_LOCALHOST_ONLY=1
export ROS_AUTOMATIC_DISCOVERY_RANGE=LOCALHOST
export RCUTILS_COLORIZED_OUTPUT=1
export RMCS_PATH="/workspaces/RMCS"

Expand Down
8 changes: 6 additions & 2 deletions .script/template/env_setup.zsh
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/bin/bash
#!/bin/zsh

export ROS_AUTOMATIC_DISCOVERY_RANGE=LOCALHOST
export RCUTILS_COLORIZED_OUTPUT=1
export ROS_LOCALHOST_ONLY=1
export RMCS_PATH="/workspaces/RMCS"

source /opt/ros/jazzy/setup.zsh
Expand All @@ -16,3 +16,7 @@ eval "$(register-python-argcomplete ros2)"
eval "$(register-python-argcomplete colcon)"

export RMCS_ROBOT_TYPE=""

fpath=(${RMCS_PATH}/.script/complete $fpath)
autoload -Uz compinit
compinit
29 changes: 21 additions & 8 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -88,19 +88,25 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
openssh-client \
lsb-release software-properties-common gnupg sudo \
python3-colorama python3-dpkt && \
wget -O ./llvm-snapshot.gpg.key https://apt.llvm.org/llvm-snapshot.gpg.key && \
apt-key add ./llvm-snapshot.gpg.key && \
rm ./llvm-snapshot.gpg.key && \
echo "deb https://apt.llvm.org/noble/ llvm-toolchain-noble main" > /etc/apt/sources.list.d/llvm-apt.list && \
apt-get update && \
version=`apt-cache search clangd- | grep clangd- | awk -F' ' '{print $1}' | sort -V | tail -1 | cut -d- -f2` && \
apt-get install -y --no-install-recommends clangd-$version && \
update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-14 50 && \
update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-14 50 && \
update-alternatives --install /usr/bin/clangd clangd /usr/bin/clangd-$version 50 && \
apt-get autoremove -y && apt-get clean && \
rm -rf /var/lib/apt/lists/* /tmp/*

# Install latest stable llvm-toolchain
RUN mkdir -p /etc/apt/keyrings && \
wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key | gpg -o /etc/apt/keyrings/llvm-snapshot.gpg --dearmor && \
echo "deb [signed-by=/etc/apt/keyrings/llvm-snapshot.gpg] https://mirrors.tuna.tsinghua.edu.cn/llvm-apt/noble/ llvm-toolchain-noble-22 main" \
| tee /etc/apt/sources.list.d/llvm.list && \
apt-get update && \
apt-get install -y --no-install-recommends clang-22 clangd-22 clang-format-22 lldb-22 && \
update-alternatives --install /usr/bin/clang clang /usr/bin/clang-22 100 && \
update-alternatives --install /usr/bin/clang++ clang++ /usr/bin/clang++-22 100 && \
update-alternatives --install /usr/bin/clangd clangd /usr/bin/clangd-22 100 && \
update-alternatives --install /usr/bin/clang-format clang-format /usr/bin/clang-format-22 100 && \
update-alternatives --install /usr/bin/lldb lldb /usr/bin/lldb-22 100 && \
apt-get autoremove -y && apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/*

# Generate/load ssh key and setup unison
RUN --mount=type=bind,target=/tmp/.ssh,source=.ssh,readonly=false \
cd /home/ubuntu && mkdir -p .ssh && \
Expand All @@ -117,6 +123,11 @@ RUN curl -LO https://github.com/neovim/neovim/releases/latest/download/nvim-linu
tar -C /opt -xzf nvim-linux-x86_64.tar.gz && \
rm nvim-linux-x86_64.tar.gz

# Install latest stable cmake for user ubuntu
RUN wget https://github.com/kitware/cmake/releases/download/v4.2.3/cmake-4.2.3-linux-x86_64.sh -O install.sh && \
mkdir -p /opt/cmake/ && bash install.sh --skip-license --prefix=/opt/cmake/ --exclude-subdir && \
rm install.sh

# Change user
RUN chsh -s /bin/zsh ubuntu && \
echo "ubuntu ALL=(ALL:ALL) NOPASSWD:ALL" >> /etc/sudoers
Expand All @@ -130,12 +141,14 @@ RUN sh -c "$(wget https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools
sed -i 's/ZSH_THEME=\"[a-z0-9\-]*\"/ZSH_THEME="af-magic"/g' ~/.zshrc && \
echo 'source ~/env_setup.zsh' >> ~/.zshrc && \
echo 'export PATH="${PATH}:/opt/nvim-linux-x86_64/bin"' >> ~/.zshrc && \
# echo 'export PATH="${PATH}:/opt/cmake/bin"' >> ~/.zshrc && \
echo 'export PATH="${PATH}:${RMCS_PATH}/.script"' >> ~/.zshrc

# Copy environment setup scripts
COPY --chown=1000:1000 .script/template/env_setup.bash env_setup.bash
COPY --chown=1000:1000 .script/template/env_setup.zsh env_setup.zsh


# Runtime container, will automatically launch the main program
FROM rmcs-base AS rmcs-runtime

Expand Down
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# RMCS
RoboMaster Control System based on ROS2.

快速开始: [quick-start](https://github.com/Alliance-Algorithm/RMCS/wiki/Quick-Start)

## Development

### Pre-requirements:
Expand Down
13 changes: 3 additions & 10 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,23 +1,16 @@
services:
rmcs-develop:
image: qzhhhi/rmcs-develop:latest
user: "${CONTAINER_USER}"
privileged: true
command: >
bash -c "
sudo chown -R ${CONTAINER_USER}:${CONTAINER_USER} ${CONTAINER_HOME}/.config
exec bash
"
user: "1000:1000"
volumes:
- /dev:/dev:bind
- /tmp/.X11-unix:/tmp/.X11-unix:bind
- /run/user/1000/wayland-0:/run/user/1000/wayland-0
- /run/user/1000/wayland-0:/run/user/1000/wayland-0:bind
- ${HOST_NVIM_DIR}:${CONTAINER_HOME}/.config/nvim/:bind
- .:/workspaces/RMCS:bind
environment:
- DISPLAY=${DISPLAY}
- WAYLAND_DISPLAY=${WAYLAND_DISPLAY}
network_mode: host
tty: true
stdin_open: true

stdin_open: true
1 change: 1 addition & 0 deletions ip.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
169.254.233.233
Loading