瀏覽代碼

更新update_code.sh脚本,更新编译代码更稳定

corvin 4 年之前
父節點
當前提交
10ca8ceb06
共有 1 個文件被更改,包括 22 次插入3 次删除
  1. 22 3
      update_code.sh

+ 22 - 3
update_code.sh

@@ -6,7 +6,9 @@
 #  更新好代码后,直接编译所有代码.
 # History:
 #  20200717:init this code.
+#  20200724:在命令执行完后增加判断命令执行是否成功.
 
+#定义各种终端中字符使用的颜色
 green="\e[32;1m"
 red="\e[31m"
 normal="\e[0m"
@@ -14,13 +16,30 @@ normal="\e[0m"
 echo -e "\n"
 echo -e "${green}>>> 1: 开始从服务器更新代码${normal}"
 git pull origin master
-echo -e "${green}更新代码完成,准备编译代码${normal}"
+if [ $? -eq 0 ];then
+    echo -e "${green}更新代码完成,准备编译代码${normal}"
+else
+    echo -e "${red}从服务器更新代码时,发送错误,检查网络连接${normal}"
+    exit -1
+fi
 echo -e "\n"
 
 sleep 3
-echo -e "${green}>>> 2:开始编译代码${normal}"
+echo -e "${green}>>> 2: 开始编译代码${normal}"
 catkin_make
-echo -e "${green}编译代码完成,现在可以运行代码${normal}"
+if [ $? -eq 0 ];then
+    echo -e "${green}编译代码完成,现在可以运行代码${normal}"
+else
+    echo -e "${red}编译代码发生错误,请检查代码${normal}"
+    exit -2
+fi
+echo -e "\n"
+
+source devel/setup.bash
+
+echo -e "${green}>>> 3: 输入以下命令启动小车${normal}"
+echo -e "\n"
+echo -e "${green}roslaunch robot_bringup robot_bringup.launch${normal}"
 echo -e "\n"
 
 exit 0