LingxinMeng 1 rok pred
rodič
commit
958c519c29

+ 20 - 18
aarch64/pji/common/config/c_cloud.go

@@ -70,6 +70,26 @@ var (
 
 // InitCloudConfig 初始化业务配置
 func InitCloudConfig() {
+	// history20240401:朴津机器人额外加一个获取sn码
+	var snCode string
+	for {
+		time.Sleep(time.Duration(2) * time.Second)
+		var command []string
+		command = append(command, "get")
+		command = append(command, "sn")
+		_, snOutput, err := util.ExecuteSync(LocalConfig.RosparamPath, command...)
+		if err != nil {
+			c_log.GlobalLogger.Error("执行获取sn码命令", command, "出错:", err)
+			continue
+		}
+		c_log.GlobalLogger.Error("执行获取sn码命令", command, "成功,结果为:", snOutput)
+		snCode = strings.Replace(strings.Replace(snOutput, " ", "", -1), "\n", "", -1)
+		LocalConfig.SecretKey = snCode
+		LocalConfig.EquipmentNo = "pjibot-" + snCode
+		break
+	}
+	c_log.GlobalLogger.Info("本地机器人sn码为:", snCode)
+
 	c_log.GlobalLogger.Info("初始化OSS配置文件 - 开始。")
 	// 获取文件的目录
 	_ = util.CreateParentDir(LocalConfig.CloudConfigLocalPath)
@@ -156,24 +176,6 @@ func refreshCloudConfig() {
 	util.CreateDir(CloudConfig.BagDataDir)
 	util.CreateDir(CloudConfig.BagCopyDir)
 
-	// history20240401:朴津机器人额外加一个获取sn码
-	var snCode string
-	for {
-		time.Sleep(time.Duration(2) * time.Second)
-		var command []string
-		command = append(command, "get")
-		command = append(command, "sn")
-		_, snOutput, err := util.ExecuteWithEnvSync(RosbagEnvs, "/opt/ros/melodic/bin/rosparam", command...)
-		if err != nil {
-			c_log.GlobalLogger.Error("执行获取sn码命令", command, "出错:", err)
-			continue
-		}
-		snCode = strings.Replace(strings.Replace(snOutput, " ", "", -1), "\n", "", -1)
-		LocalConfig.SecretKey = snCode
-		LocalConfig.EquipmentNo = "pjibot-" + snCode
-		break
-	}
-	c_log.GlobalLogger.Info("本地机器人sn码为:", snCode)
 }
 
 // RefreshCloudConfig 轮询oss上的配置文件更新到本地

+ 1 - 0
aarch64/pji/common/config/c_local.go

@@ -19,6 +19,7 @@ type restartCmd struct {
 
 type localConfig struct {
 	Node                 node       `yaml:"node"`                    // 节点信息
+	RosparamPath         string     `yaml:"rosparam-path"`           // 获取oss配置的url
 	UrlGetOssConfig      string     `yaml:"url-get-oss-config"`      // 获取oss配置的url
 	OssBasePrefix        string     `yaml:"oss-base-prefix"`         // 云端配置文件的位置
 	CloudConfigFilename  string     `yaml:"cloud-config-filename"`   // 云端配置文件名称

+ 1 - 3
aarch64/pji/common/config/yaml/pjibot0-local-config.yaml

@@ -1,9 +1,7 @@
 node:
   name: node1
   ip: 192.168.1.104
-# 数据闭环平台参数
-equipment-no: pjibot0
-secret-key: yG9cGJgdnojlErIYTEcbYqIWuwrJaItezwXLo9wk
+rosparam-path: /opt/ros/melodic/bin/rosparam
 # 获取oss连接信息的接口url
 url-get-oss-config: http://36.110.106.156:18379/oss/config?token=nXonLUcMtGcrQqqKiyygIwyVbvizE0wD
 # 朴津机器人数据前缀

+ 1 - 0
aarch64/pji/common/config/yaml/pjirobot1-local-config.yaml

@@ -1,6 +1,7 @@
 node:
   name: node1
   ip: 192.168.1.104
+rosparam-path: /opt/ros/melodic/bin/rosparam
 # 获取oss连接信息的接口url
 url-get-oss-config: http://36.110.106.156:18379/oss/config?token=nXonLUcMtGcrQqqKiyygIwyVbvizE0wD
 # 朴津机器人数据前缀

+ 1 - 3
aarch64/pji/common/config/yaml/单摄像头-local-config.yaml

@@ -1,9 +1,7 @@
 node:
   name: node1
   ip: 192.168.1.104
-# 数据闭环平台参数
-equipment-no: pjirobot1
-secret-key: ZzI1MocN3M6evTaGuTQALuBXTmUnN5tV2XUwcwXU
+rosparam-path: /opt/ros/melodic/bin/rosparam
 # 获取oss连接信息的接口url
 url-get-oss-config: http://36.110.106.156:18379/oss/config?token=nXonLUcMtGcrQqqKiyygIwyVbvizE0wD
 # 朴津机器人数据前缀

+ 1 - 3
aarch64/pji/common/config/yaml/双摄像头-local-config.yaml

@@ -1,9 +1,7 @@
 node:
   name: node1
   ip: 192.168.1.104
-# 数据闭环平台参数
-equipment-no: pjirobot1
-secret-key: ZzI1MocN3M6evTaGuTQALuBXTmUnN5tV2XUwcwXU
+rosparam-path: /opt/ros/melodic/bin/rosparam
 # 获取oss连接信息的接口url
 url-get-oss-config: http://36.110.106.156:18379/oss/config?token=nXonLUcMtGcrQqqKiyygIwyVbvizE0wD
 # 朴津机器人数据前缀