update_code.sh 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  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 /usr/lib/systemd/system/
  48. echo -e "\n"
  49. echo -e "${green}>>> 全部代码都已编译配置完成,下面开始使用小车...${normal}"
  50. echo -e "\n"
  51. echo -e "${green}>>> 输入以下命令启动小车${normal}"
  52. echo -e "\n"
  53. echo -e "${green} roslaunch robot_bringup robot_bringup.launch${normal}"
  54. echo -e "\n"
  55. echo -e "${green}>>> 输入以下命令遥控小车${normal}"
  56. echo -e "\n"
  57. echo -e "${green} rosrun control_robot control_robot.py${normal}"
  58. echo -e "\n"
  59. echo -e "${green}>>> 输入以下命令打开摄像头${normal}"
  60. echo -e "\n"
  61. echo -e "${green} rqt_image_view${normal}"
  62. echo -e "\n"
  63. exit 0