用过 Autoware 的用户,估计没少吃环境配置和项目编译的苦吧?来来来,不要没苦硬吃了~
当前脚本适配的镜像:
镜像下载地址:
https://file.aidlux.com/files?folder_id=57c4dc73
切记,需要先将你的开发板刷上这个版本的镜像!刷机方法参考官网教程~
脚本正文:
#!/bin/bash
CUR_DIR=$(cd $(dirname $0)/../..; pwd)
cd $CUR_DIR
echo "工作目录:$CUR_DIR"
echo "-------------------------------公共函数定义---------------------------------------"
fun_fix_ros2_source(){
if [ -f /etc/apt/sources.list.d/ros2.sources ]; then
sudo sed -i 's#http://packages.ros.org/ros2/ubuntu#https://mirrors.tuna.tsinghua.edu.cn/ros2/ubuntu#g' /etc/apt/sources.list.d/ros2.sources
sudo sed -i 's/^Types: deb deb-src$/Types: deb/' /etc/apt/sources.list.d/ros2.sources
sudo grep -q '^Architectures: amd64$' /etc/apt/sources.list.d/ros2.sources || sudo sed -i '/^Types: deb$/a Architectures: arm64' /etc/apt/sources.list.d/ros2.sources
fi
}
echo "******************************设置hostname************************************"
sudo hostnamectl set-hostname tomatoros-x1-qcs8550
grep -q "127.0.1.1[[:space:]]*$(hostname)" /etc/hosts || echo "127.0.1.1 $(hostname)" | sudo tee -a /etc/hosts > /dev/null 2>&1
sudo sed -i '/^127\.0\.1\.1[[:space:]]*kalama$/d' /etc/hosts
head -10 /etc/hosts
echo "******************************设置默认编码UTF8************************************"
fun_fix_ros2_source
sudo apt clean && sudo apt update && sudo apt install -y locales
sudo locale-gen en_US en_US.UTF-8
sudo update-locale LC_ALL=en_US.UTF-8 LANG=en_US.UTF-8
export LANG=en_US.UTF-8
locale
echo "******************************安装依赖工具****************************************"
sudo apt -y install \
curl \
terminator \
software-properties-common
echo "******************************安装 universe 源*********************************"
sudo add-apt-repository universe -y
echo "******************************安装 ros2-apt-source****************************"
if ! [ -f /tmp/ros2-apt-source.deb ]; then
# download remote
#export ROS_APT_SOURCE_VERSION=$(curl -s https://api.github.com/repos/ros-infrastructure/ros-apt-source/releases/latest | grep -F "tag_name" | awk -F\" '{print $4}')
#export ROS2_APT_SOURCE_URL="https://github.com/ros-infrastructure/ros-apt-source/releases/download/${ROS_APT_SOURCE_VERSION}/ros2-apt-source_${ROS_APT_SOURCE_VERSION}.$(. /etc/os-release && echo ${UBUNTU_CODENAME:-${VERSION_CODENAME}})_all.deb"
#curl -L -o /tmp/ros2-apt-source.deb $ROS2_APT_SOURCE_URL
# download local
cp $CUR_DIR/tomato-ros/common/ros2-apt-source.deb /tmp/ros2-apt-source.deb
fi
if [ -f /tmp/ros2-apt-source.deb ]; then
sudo dpkg -i /tmp/ros2-apt-source.deb
fi
echo "******************************配置 ros2 国内加速镜像********************************"
fun_fix_ros2_source
head -10 /etc/apt/sources.list.d/ros2.sources
echo "******************************安装 ros2 基础工具**********************************"
sudo apt install -y \
ros-humble-desktop \
ros-humble-ros-base \
ros-humble-rmw-cyclonedds-cpp \
ros-dev-tools \
python3-flask
echo "******************************安装rosdepc工具***********************************"
sudo pip install rosdepc
sudo rosdepc init
rosdepc update
#echo "******************************安装rosdep依赖************************************"
#sudo apt remove -y $(apt list --installed | grep lanelet2 | awk -F '/' '{print $1}')
#sudo apt remove -y $(apt list --installed | grep autoware | awk -F '/' '{print $1}')
#sudo apt install -y $(cat $CUR_DIR/tomato-ros/common/ros-humble-deps.txt)
echo "******************************初始化默认工作目录*************************************"
mkdir -p $HOME/tomato-ros/config \
$HOME/tomato-ros/calibration \
$HOME/tomato-ros/desktop \
$HOME/autoware_map \
$HOME/autoware_data \
$HOME/autoware_tomato \
$CUR_DIR/src
echo "******************************配置 cyclonedds*********************************"
cat > $HOME/tomato-ros/config/cyclonedds.xml << 'EOF'
<?xml version="1.0" encoding="UTF-8" ?>
<CycloneDDS xmlns="https://cdds.io/config" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="https://cdds.io/config https://raw.githubusercontent.com/eclipse-cyclonedds/cyclonedds/master/etc/cyclonedds.xsd">
<Domain Id="any">
<General>
<Interfaces>
<NetworkInterface autodetermine="false" name="eth0" priority="default" multicast="default" />
</Interfaces>
<AllowMulticast>default</AllowMulticast>
<MaxMessageSize>65500B</MaxMessageSize>
</General>
<Internal>
<SocketReceiveBufferSize min="10MB"/>
<Watermarks>
<WhcHigh>500kB</WhcHigh>
</Watermarks>
</Internal>
</Domain>
</CycloneDDS>
EOF
export RMW_IMPLEMENTATION=rmw_cyclonedds_cpp
export CYCLONEDDS_URI="file://${HOME}/tomato-ros/config/cyclonedds.xml"
grep -qxF 'export RMW_IMPLEMENTATION=rmw_cyclonedds_cpp' ~/.bashrc || echo 'export RMW_IMPLEMENTATION=rmw_cyclonedds_cpp' >> ~/.bashrc
grep -qxF 'export CYCLONEDDS_URI=file:///home/aidlux/tomato-ros/config/cyclonedds.xml' ~/.bashrc || echo "export CYCLONEDDS_URI=${CYCLONEDDS_URI}" >> ~/.bashrc
tail -10 $HOME/.bashrc
echo "******************************启用组播******************************************"
sudo ip link set lo multicast on
if ! [ -f /etc/systemd/system/multicast-lo.service ]; then
sudo tee /etc/systemd/system/multicast-lo.service > /dev/null << 'EOF'
[Unit]
Description=Enable Multicast on Loopback
[Service]
Type=oneshot
ExecStart=/usr/sbin/ip link set lo multicast on
[Install]
WantedBy=multi-user.target
EOF
fi
sudo systemctl daemon-reload
sudo systemctl enable multicast-lo.service
sudo systemctl start multicast-lo.service
echo "******************************调整系统网络设置**************************************"
sudo sysctl -w net.core.rmem_max=2147483647
sudo sysctl -w net.ipv4.ipfrag_time=3
sudo sysctl -w net.ipv4.ipfrag_high_thresh=134217728
sysctl net.core.rmem_max net.ipv4.ipfrag_time net.ipv4.ipfrag_high_thresh
if ! [ -f /etc/sysctl.d/10-cyclone-max.conf ]; then
sudo tee /etc/sysctl.d/10-cyclone-max.conf > /dev/null << 'EOF'
net.core.rmem_max=2147483647
net.ipv4.ipfrag_time=3
net.ipv4.ipfrag_high_thresh=134217728
EOF
fi
echo "******************************配置ROS_DOMAIN_ID*******************************"
grep -qxF 'export ROS_DOMAIN_ID=3' ~/.bashrc || echo 'export ROS_DOMAIN_ID=3' >> ~/.bashrc
echo "******************************彩色日志输*****************************************"
grep -qxF 'export GTEST_COLOR=1' ~/.bashrc || echo 'export GTEST_COLOR=1' >> ~/.bashrc
grep -qxF 'export RCUTILS_COLORIZED_OUTPUT=1' ~/.bashrc || echo 'export RCUTILS_COLORIZED_OUTPUT=1' >> ~/.bashrc
grep -qxF 'export RCUTILS_CONSOLE_OUTPUT_FORMAT="[{severity} {time}] [{name}]: {message} ({function_name}() at {file_name}:{line_number})"' ~/.bashrc || echo 'export RCUTILS_CONSOLE_OUTPUT_FORMAT="[{severity} {time}] [{name}]: {message} ({function_name}() at {file_name}:{line_number})"' >> ~/.bashrc
echo "******************************导入ROS环境***************************************"
grep -qxF '[ -f /opt/ros/humble/setup.bash ] && source /opt/ros/humble/setup.bash' ~/.bashrc || echo '[ -f /opt/ros/humble/setup.bash ] && source /opt/ros/humble/setup.bash' >> ~/.bashrc
grep -qxF '[ -f /home/aidlux/autoware_tomato/setup.bash ] && source /home/aidlux/autoware_tomato/setup.bash' ~/.bashrc || echo '[ -f /home/aidlux/autoware_tomato/setup.bash ] && source /home/aidlux/autoware_tomato/setup.bash' >> ~/.bashrc
tail -15 $HOME/.bashrc
source $HOME/.bashrc
echo "******************************测试ROS环境***************************************"
which ros2
ros2
ros2 topic list
echo "******************************git通用配置***************************************"
git config --global credential.helper store
git config --global user.name "tomatoros"
git config --global user.email "smartros@foxmail.com"
echo "******************************配置交换空间****************************************"
# Remove the current swapfile
sudo swapoff /swapfile
sudo rm /swapfile
# Create a new swapfile
sudo fallocate -l 32G /swapfile
sudo chmod 600 /swapfile
sudo mkswap /swapfile
sudo swapon /swapfile
free -h
ls -lhs /swapfile
echo "******************************下载autoware_data*******************************"
if ! [ -f /tmp/autoware_data.zip ]; then
curl -L -o /tmp/autoware_data.zip http://192.168.10.158/p/autoware_deps/autoware_data.zip
unzip /tmp/autoware_data.zip -d $HOME
fi
echo "******************************下载autoware_data*******************************"
if ! [ -f /tmp/autoware_map.zip ]; then
curl -L -o /tmp/autoware_map.zip http://192.168.10.158/p/autoware_deps/autoware_map.zip
unzip /tmp/autoware_map.zip -d $HOME
fi
echo "******************************下载egm2008-1***********************************"
if ! [ -f /usr/share/GeographicLib/geoids/egm2008-1.pgm ]; then
curl -L -o /tmp/egm2008-1.zip http://192.168.10.158/p/autoware_deps/pkg/egm2008-1.zip
sudo unzip /tmp/egm2008-1.zip -d /usr/share/GeographicLib
fi
echo "******************************项目源码导入****************************************"
vcs import src < $CUR_DIR/autoware-repos/autoware.repos
echo "******************************项目依赖安装****************************************"
#rosdepc update
rosdepc install -r -y --from-paths src --ignore-src --rosdistro $ROS_DISTRO
echo "******************************开发环境 artifacts******************************"
echo "skip"
echo "******************************开发环境 build_tools******************************"
sudo apt-get install -y ccache
grep -qxF 'export CCACHE_DIR="/var/tmp/ccache"' ~/.bashrc || echo 'export CCACHE_DIR="/var/tmp/ccache"' >> ~/.bashrc
grep -qxF 'export CC="/usr/lib/ccache/gcc"' ~/.bashrc || echo 'export CC="/usr/lib/ccache/gcc"' >> ~/.bashrc
grep -qxF 'export CXX="/usr/lib/ccache/g++"' ~/.bashrc || echo 'export CXX="/usr/lib/ccache/g++"' >> ~/.bashrc
mkdir -p /var/tmp/ccache
sudo chown aidlux:aidlux /var/tmp/ccache
echo "******************************开发环境 cuda******************************"
echo "skip"
echo "******************************开发环境 dev_tools******************************"
source $CUR_DIR/amd64.env
sudo sudo apt install -y \
python3-pip \
golang \
ros-${rosdistro}-plotjuggler-ros \
git-lfs
apt-mark hold ros-humble-plotjuggler-ros
git lfs install
pip3 install pre-commit
pip3 install clang-format==${pre_commit_clang_format_version}
echo "******************************开发环境 docker_engine******************************"
echo "skip"
echo "******************************开发环境 gdown******************************"
pip3 install gdown setuptools==69.0.3
echo "******************************开发环境 geographiclib******************************"
sudo apt install -y geographiclib-tools
sudo geographiclib-get-geoids egm2008-1
echo "******************************开发环境 kisak_mesa******************************"
# # Update the package list and install software-properties-common
# sudo apt-get update
# sudo apt-get install -y software-properties-common
# # Add the Kisak Mesa PPA
# sudo add-apt-repository -y ppa:kisak/kisak-mesa
# # Update the package list after adding the new repository
# sudo apt-get update
# # Install Mesa libraries
# sudo apt-get install -y \
# libegl-mesa0 \
# libegl1-mesa-dev \
# libgbm-dev \
# libgbm1 \
# libgl1-mesa-dev \
# libgl1-mesa-dri \
# libglapi-mesa \
# libglx-mesa0
echo "******************************开发环境 nvidia_container_toolkit******************************"
echo "skip"
echo "******************************开发环境 pacmod******************************"
source ./amd64.env
sudo apt install -y apt-transport-https
sudo sh -c 'echo "deb [trusted=yes] https://s3.amazonaws.com/autonomoustuff-repo/ $(lsb_release -sc) main" > /etc/apt/sources.list.d/autonomoustuff-public.list'
sudo apt update
sudo apt install -y ros-${rosdistro}-pacmod3
echo "******************************开发环境 qt5ct_setup******************************"
echo "skip"
echo "******************************开发环境 rmw_implementation******************************"
echo "skip"
echo "******************************开发环境 ros2******************************"
echo "skip"
echo "******************************开发环境 ros2_dev_tools******************************"
sudo apt update && sudo apt install -y \
python3-colcon-mixin \
python3-flake8-docstrings \
python3-pip \
python3-pytest-cov \
ros-dev-tools \
python3-flake8-blind-except \
python3-flake8-builtins \
python3-flake8-class-newline \
python3-flake8-comprehensions \
python3-flake8-deprecated \
python3-flake8-import-order \
python3-flake8-quotes \
python3-pytest-repeat \
python3-pytest-rerunfailures
echo "******************************开发环境 telegraf******************************"
echo "skip"
echo "******************************开发环境 tensorrt******************************"
echo "skip"
echo "******************************项目环境初始化****************************************"
#./setup-dev-env.sh --no-nvidia --data-dir $HOME/autoware_data
# sudo apt purge rviz_default_plugins
# sudo apt purge rviz2
# sudo apt purge autoware_map_msgs
# sudo apt purge autoware_internal_planning_msgs
# sudo apt purge autoware_planning_msgs
# sudo apt purge autoware_lanelet2_extension
# --allow-overriding \
# autoware_internal_planning_msgs \
# autoware_lanelet2_extension \
# autoware_map_msgs \
# autoware_planning_msgs \
# rviz2 rviz_default_plugins
echo "******************************移除冗余包*****************************************"
sudo apt autoremove -y
rm -rf $CUR_DIR/build $CUR_DIR/log $HOME/autoware_tomato
echo "****************************************************************************"
echo "successful"
