1
0

setup_env.sh 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. #!/bin/bash
  2. # Copyright: 2016-2018 ROS小课堂 www.corvin.cn
  3. # Author: corvin
  4. # Description:该脚本是为了安装一些必要软件包,这样才能正常运行软件包中的
  5. # 各个实例代码.该脚本只需要执行一次即可.
  6. # History:
  7. # 20181220:Initial this bash file.
  8. # 20190102:在安装upgrade时,增加一个判断,必须等命令执行成功才继续往下运行.
  9. red="\e[31m"
  10. normal="\e[0m"
  11. CURRENT_PATH=$(dirname $(readlink -f "$0"))
  12. STDR_WS_PATH=${CURRENT_PATH%scripts}
  13. # first install necessary packages
  14. sudo apt update
  15. while [ $? -ne 0 ]
  16. do
  17. echo -e "${red}Can't update source list, will retry...${noraml}\n"
  18. sleep 10
  19. sudo apt update
  20. done
  21. sudo apt -y upgrade
  22. while [ $? -ne 0 ]
  23. do
  24. echo -e "${red}Can't install upgrade packages, will retry...${noraml}\n"
  25. sleep 10
  26. sudo apt -y upgrade
  27. done
  28. sudo apt install -y ros-$ROS_DISTRO-move-base ros-$ROS_DISTRO-amcl
  29. sudo apt install -y ros-$ROS_DISTRO-dwa-local-planner ros-$ROS_DISTRO-global-planner
  30. sudo apt install -y ros-$ROS_DISTRO-gmapping ros-$ROS_DISTRO-hector-mapping
  31. sudo apt install -y ros-$ROS_DISTRO-costmap-2d ros-$ROS_DISTRO-hector-nav-msgs
  32. sudo apt install -y ros-$ROS_DISTRO-map-server ros-$ROS_DISTRO-nav-core
  33. sudo apt-get -y autoremove
  34. # second catkin_make worksapce
  35. cd $STDR_WS_PATH
  36. catkin_make
  37. # third set workspace env to .bashrc
  38. source devel/setup.bash
  39. echo "#config stdr_ws env by corvin" >>~/.bashrc
  40. echo "source ${STDR_WS_PATH}devel/setup.bash" >> ~/.bashrc
  41. exit 0