update_code.sh 1.8 KB

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