update_code.sh 1.5 KB

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