update_code.sh 1.8 KB

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