update_code.sh 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. #!/bin/bash
  2. # Copyright: 2016-2022 www.corvin.cn
  3. # Description: 用来更新panda代码,保持代码与服务器上最新代码同步.
  4. # 首先将本地所做修改给还原,然后更新代码后,直接编译所有代码.
  5. # Author: corvin
  6. # History:
  7. # 20200717:init this code.
  8. # 20200724:在命令执行完后增加判断命令执行是否成功.
  9. # 20210518:在更新服务器代码前,先将本地修改撤销.
  10. # 20220901:增加编译oled显示屏代码的脚本命令.
  11. #定义各种终端中字符使用的颜色
  12. green="\e[32;1m"
  13. red="\e[31m"
  14. normal="\e[0m"
  15. echo -e "\n"
  16. echo -e "${green}>>> 1: 开始从服务器更新代码${normal}"
  17. git reset --hard origin/master
  18. git pull origin master
  19. if [ $? -eq 0 ];then
  20. echo -e "${green}更新代码完成,准备编译代码...${normal}"
  21. else
  22. echo -e "${red}从服务器更新代码时,发生错误,检查网络连接${normal}"
  23. exit -1
  24. fi
  25. echo -e "\n"
  26. sleep 3
  27. echo -e "${green}>>> 2: 开始编译代码${normal}"
  28. rm -rf ~/.ros/log/
  29. catkin_make
  30. if [ $? -eq 0 ];then
  31. source ~/panda_ws/devel/setup.bash
  32. echo -e "${green}>>> 编译ROS代码完成,现在编译oled屏幕代码...${normal}"
  33. else
  34. echo -e "${red}编译代码发生错误,请检查代码${normal}"
  35. exit -2
  36. fi
  37. echo -e "\n"
  38. touch ~/.bat
  39. cd src/oled_screen/build/
  40. rm -rf *
  41. cmake ..
  42. make
  43. cd ../
  44. echo -e "\n"
  45. echo -e "${green}>>> 需要输入密码配置oled屏幕启动服务...${normal}"
  46. sudo cp *.service /usr/lib/systemd/system/
  47. echo -e "\n"
  48. echo -e "${green}>>> 全部代码都已编译配置完成,下面开始使用小车...${normal}"
  49. echo -e "\n"
  50. echo -e "${green}>>> 输入以下命令启动小车${normal}"
  51. echo -e "\n"
  52. echo -e "${green} roslaunch robot_bringup robot_bringup.launch${normal}"
  53. echo -e "\n"
  54. echo -e "${green}>>> 输入以下命令遥控小车${normal}"
  55. echo -e "\n"
  56. echo -e "${green} rosrun control_robot control_robot.py${normal}"
  57. echo -e "\n"
  58. echo -e "${green}>>> 输入以下命令打开摄像头${normal}"
  59. echo -e "\n"
  60. echo -e "${green} rqt_image_view${normal}"
  61. echo -e "\n"
  62. exit 0