update_code.sh 1.6 KB

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