跳转至

🔧 环境配置

💡 主控计算机已预装所有环境。以下教程专为需要配置新设备时使用。

📋 前置要求

💻 软件环境

  • Ubuntu 22.04 LTS
  • ROS2 Humble

1.1 安装 ROS2 Humble

如已安装可跳过,详细安装步骤请参考 ROS2安装教程

1.2 安装系统依赖

# 更新系统
sudo apt update -y

# 安装 ROS2 依赖包
sudo apt-get install ros-humble-moveit -y
sudo apt-get install ros-humble-gripper-controllers -y
sudo apt-get install ros-humble-position-controllers -y
sudo apt-get install ros-humble-joint-state-broadcaster -y
sudo apt-get install ros-humble-joint-trajectory-controller -y
sudo apt-get install ros-humble-xacro -y
sudo apt-get install ros-humble-hardware-interface -y
sudo apt-get install ros-humble-controller-manager -y
sudo apt-get install ros-humble-moveit-plugins ros-humble-moveit-ros-perception -y
sudo apt-get install ros-humble-pinocchio -y

# 安装 Qt/PySide6 图形界面依赖
sudo apt-get install libxcb-cursor0 libxcb-xinerama0 libxcb-icccm4 libxcb-keysyms1 libxcb-render-util0 -y

# 安装 CAN 和 git
sudo apt-get install can-utils -y
sudo apt-get install git -y

# 安装 vcs 工具
sudo apt-get install python3-vcstool -y

# 安装 Python 依赖
python3 -m pip install python-can -i https://mirrors.tuna.tsinghua.edu.cn/pypi/web/simple
python3 -m pip install pyside6 -i https://mirrors.tuna.tsinghua.edu.cn/pypi/web/simple
python3 -m pip install openarmx_arm_driver -i https://mirrors.tuna.tsinghua.edu.cn/pypi/web/simple
python3 -m pip install casadi -i https://pypi.tuna.tsinghua.edu.cn/simple
python3 -m pip install numpy==1.26.4 -i https://pypi.tuna.tsinghua.edu.cn/simple
# 更新系统
sudo apt update -y

# 安装 ROS2 依赖包
sudo apt-get install ros-humble-moveit -y
sudo apt-get install ros-humble-gripper-controllers -y
sudo apt-get install ros-humble-position-controllers -y
sudo apt-get install ros-humble-joint-state-broadcaster -y
sudo apt-get install ros-humble-joint-trajectory-controller -y
sudo apt-get install ros-humble-xacro -y
sudo apt-get install ros-humble-hardware-interface -y
sudo apt-get install ros-humble-controller-manager -y
sudo apt-get install ros-humble-moveit-plugins ros-humble-moveit-ros-perception -y
sudo apt-get install ros-humble-pinocchio -y

# 安装 Qt/PySide6 图形界面依赖
sudo apt-get install libxcb-cursor0 libxcb-xinerama0 libxcb-icccm4 libxcb-keysyms1 libxcb-render-util0 -y

# 安装 CAN 和 git
sudo apt-get install can-utils -y
sudo apt-get install git -y

# 安装 vcs 工具
sudo apt-get install python3-vcstool -y

# 安装 Python 依赖
python3 -m pip install python-can -i https://mirrors.tuna.tsinghua.edu.cn/pypi/web/simple
python3 -m pip install pyside6 -i https://mirrors.tuna.tsinghua.edu.cn/pypi/web/simple
python3 -m pip install openarmx_arm_driver -i https://mirrors.tuna.tsinghua.edu.cn/pypi/web/simple
python3 -m pip install casadi -i https://pypi.tuna.tsinghua.edu.cn/simple
python3 -m pip install numpy==1.26.4 -i https://pypi.tuna.tsinghua.edu.cn/simple
# 更新系统
sudo apt update -y

# 安装 ROS2 依赖包
sudo apt-get install ros-humble-moveit -y
sudo apt-get install ros-humble-gripper-controllers -y
sudo apt-get install ros-humble-position-controllers -y
sudo apt-get install ros-humble-joint-state-broadcaster -y
sudo apt-get install ros-humble-joint-trajectory-controller -y
sudo apt-get install ros-humble-xacro -y
sudo apt-get install ros-humble-hardware-interface -y
sudo apt-get install ros-humble-controller-manager -y
sudo apt-get install ros-humble-moveit-plugins ros-humble-moveit-ros-perception -y
sudo apt-get install ros-humble-pinocchio -y

# 安装 Qt/PySide6 图形界面依赖
sudo apt-get install libxcb-cursor0 libxcb-xinerama0 libxcb-icccm4 libxcb-keysyms1 libxcb-render-util0 -y

# 安装 CAN 和 git
sudo apt-get install can-utils -y
sudo apt-get install git -y

sudo apt install libfuse2

# 安装 vcs 工具
sudo apt-get install python3-vcstool -y

# 安装 Python 依赖
python3 -m pip install python-can -i https://mirrors.tuna.tsinghua.edu.cn/pypi/web/simple
python3 -m pip install pyside6 -i https://mirrors.tuna.tsinghua.edu.cn/pypi/web/simple
python3 -m pip install openarmx_arm_driver -i https://mirrors.tuna.tsinghua.edu.cn/pypi/web/simple
python3 -m pip install websockets -i https://pypi.tuna.tsinghua.edu.cn/simple
python3 -m pip install casadi -i https://pypi.tuna.tsinghua.edu.cn/simple
python3 -m pip install numpy==1.26.4 -i https://pypi.tuna.tsinghua.edu.cn/simple

# 配置当前用户,用于运行外骨骼上位机,配置完毕后需重启才能生效
sudo usermod -a -G dialout $USER  

# 附权
sudo chmod +x 'Qnbot HMI Control-1.2.2.AppImage'

1.3 安装 CAN 驱动(如已安装可跳过)

注意:如果使用同构遥操,请安装 PCAN 驱动;如果不使用同构遥操,请安装 KCAN 驱动。

PCAN 驱动安装

先下载 PCAN 驱动压缩包,再执行以下命令: PCAN 驱动压缩包

# 解压缩
tar -xzvf peak-linux-driver-8.20.0.tar.gz -C ~

# 安装PCAN
cd ~/peak-linux-driver-8.20.0
sudo apt update
sudo apt install -y libpopt-dev 
sudo apt install gcc-12 g++-12 -y 
sudo sed -i 's/-ftrivial-auto-var-init=zero//g' /lib/modules/$(uname -r)/build/Makefile 
make clean 
make all 
sudo make install 

# 开启PCAN
sudo modprobe peak_usb

此时插上 CAN 盒,使用 ip link show 即可看到 can0can1 等通道。接下来配置 PCAN 开机自启动。

## 开机启动PCAN
sudo sed -i 's/^blacklist peak_usb$/#blacklist peak_usb/' /etc/modprobe.d/blacklist-peak.conf 
echo "peak_usb" | sudo tee -a /etc/modules 
sudo depmod -a 

KCAN 驱动安装

可参考 KCAN 驱动安装

1.4 构建工作空间

# 创建工作空间
cd
mkdir -p ~/openarmx_ws/src
cd ~/openarmx_ws/src

拉取代码

# 克隆
git clone https://github.com/openarmx/openarmx_ros2.git
# 拉取完整的选项包
vcs import < openarmx_ros2/openarmx.repos

安装 openarmx_can

# amd 架构
cd openarmx_ros2
sudo dpkg -i openarmx-can_1.0.0_amd64.deb

# arm架构
cd openarmx_ros2
sudo dpkg -i openarmx-can_1.0.0_arm64.deb

编译

# 编译工作空间
cd ~/openarmx_ws
colcon build
配置环境变量(为后续方便使用设置,如不需要可跳过)

# 配置环境变量(pro max 版本专用)
echo "alias sc='source install/local_setup.bash'" >> ~/.bashrc
echo "alias cb='colcon build --packages-select'" >> ~/.bashrc
source ~/.bashrc