update_code.sh 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. #!/bin/bash
  2. # Copyright: 2016-2022 www.corvin.cn
  3. # Description: 用来更新代码,保持代码与服务器上最新代码同步.
  4. # 首先将本地所做修改给还原,然后更新代码后,直接编译所有代码.
  5. # Author: corvin
  6. # History:
  7. # 20220808:init this code.
  8. #定义各种终端中字符使用的颜色
  9. green="\e[32;1m"
  10. red="\e[31m"
  11. normal="\e[0m"
  12. echo -e "\n"
  13. echo -e "${green}>>> 1: 开始从服务器更新代码${normal}"
  14. git reset --hard origin/master
  15. git pull origin master
  16. if [ $? -eq 0 ];then
  17. echo -e "${green}更新代码完成,准备编译代码...${normal}"
  18. else
  19. echo -e "${red}从服务器更新代码时,发生错误,检查网络连接${normal}"
  20. exit -1
  21. fi
  22. echo -e "\n"
  23. sleep 3
  24. echo -e "${green}>>> 2: 开始编译代码${normal}"
  25. catkin_make
  26. if [ $? -eq 0 ];then
  27. echo -e "${green}编译代码完成,现在可以启动代码...${normal}"
  28. else
  29. echo -e "${red}编译代码发生错误,请检查代码${normal}"
  30. exit -2
  31. fi
  32. echo -e "\n"
  33. source devel/setup.bash
  34. echo -e "${green}>>> 输入以下命令启动小车${normal}"
  35. echo -e "\n"
  36. echo -e "${green} roslaunch robot_bringup robot_bringup.launch${normal}"
  37. echo -e "\n"
  38. echo -e "${green}>>> 输入以下命令遥控小车${normal}"
  39. echo -e "\n"
  40. echo -e "${green} rosrun teleop_twist_keyboard teleop_twist_keyboard.py${normal}"
  41. echo -e "\n"