update_code.sh 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  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 checkout master
  19. git pull origin master
  20. if [ $? -eq 0 ];then
  21. echo -e "${green}更新代码完成,准备编译代码...${normal}"
  22. else
  23. echo -e "${red}从服务器更新代码时,发生错误,检查网络连接${normal}"
  24. exit -1
  25. fi
  26. echo -e "\n"
  27. sleep 3
  28. echo -e "${green}>>> 2: 开始编译代码${normal}"
  29. rm -rf ~/.ros/log/
  30. catkin_make
  31. if [ $? -eq 0 ];then
  32. source /home/corvin/panda_ws/devel/setup.bash
  33. echo -e "${green}>>> 编译ROS代码完成,现在编译oled屏幕代码...${normal}"
  34. else
  35. echo -e "${red}编译代码发生错误,请检查代码${normal}"
  36. exit -2
  37. fi
  38. echo -e "\n"
  39. touch ~/.bat
  40. cd /home/corvin/panda_ws/src/oled_screen/build/
  41. rm -rf *
  42. cmake ..
  43. make
  44. cd ../
  45. echo -e "\n"
  46. echo -e "${green}>>> 需要输入密码配置oled屏幕启动服务...${normal}"
  47. sudo cp *.service /lib/systemd/system/
  48. sudo chmod 644 /lib/systemd/system/oled_startup*.service
  49. sudo systemctl daemon-reload
  50. sudo systemctl enable oled_startup_sh.service
  51. echo -e "\n"
  52. echo -e "${green}>>> 全部代码都已编译配置完成,下面开始使用小车...${normal}"
  53. echo -e "\n"
  54. echo -e "${green}>>> 输入以下命令启动小车${normal}"
  55. echo -e "\n"
  56. echo -e "${green} roslaunch robot_bringup robot_bringup.launch${normal}"
  57. echo -e "\n"
  58. echo -e "${green}>>> 输入以下命令遥控小车${normal}"
  59. echo -e "\n"
  60. echo -e "${green} rosrun control_robot control_robot.py${normal}"
  61. echo -e "\n"
  62. echo -e "${green}>>> 输入以下命令打开摄像头${normal}"
  63. echo -e "\n"
  64. echo -e "${green} rqt_image_view${normal}"
  65. echo -e "\n"
  66. exit 0