LingxinMeng 6 mēneši atpakaļ
vecāks
revīzija
3e46dae529

+ 1 - 1
aarch64/pjisuv/slave/package/service/move_bag.go

@@ -10,7 +10,7 @@ import (
 	"time"
 )
 
-// RunTimeWindowProducerQueue 将时间窗口内的包全部move出去,并等待当前时间窗口结束触发上传
+// 将时间窗口内的包全部move出去,并等待当前时间窗口结束触发上传
 func RunTimeWindowProducerQueue() {
 	c_log.GlobalLogger.Info("生产者队列 - 启动")
 	for { // 必须串行排队处理

+ 34 - 0
test/goroslib_subscriber_test.go

@@ -0,0 +1,34 @@
+package test
+
+import (
+	"cicv-data-closedloop/pjisuv_msgs"
+	"github.com/bluenviron/goroslib/v2"
+	"log"
+	"testing"
+)
+
+func TestGoroslibSubscriber(t *testing.T) {
+	// create a node and connect to the master
+	n, err := goroslib.NewNode(goroslib.NodeConf{
+		Name:          "goroslib_sub",
+		MasterAddress: "127.0.0.1:11311",
+	})
+	if err != nil {
+		panic(err)
+	}
+	defer n.Close()
+
+	// create a subscriber
+	sub, err := goroslib.NewSubscriber(goroslib.SubscriberConf{
+		Node:  n,
+		Topic: "/cicv_location",
+		Callback: func(msg *pjisuv_msgs.PerceptionLocalization) {
+			log.Printf("Incoming: %+v\n", msg)
+		},
+	})
+	if err != nil {
+		panic(err)
+	}
+	defer sub.Close()
+
+}

+ 42 - 44
test/rosbag_write_test.go

@@ -14,35 +14,6 @@ import (
 
 func TestWriteRosBag(t *testing.T) {
 
-	// create a node and connect to the master
-	n, err := goroslib.NewNode(goroslib.NodeConf{
-		Name:          "goroslib_sub",
-		MasterAddress: "127.0.0.1:11311",
-	})
-	if err != nil {
-		panic(err)
-	}
-	defer n.Close()
-
-	// create a subscriber
-	sub, err := goroslib.NewSubscriber(goroslib.SubscriberConf{
-		Node:  n,
-		Topic: "test_topic",
-		Callback: func(msg *pjisuv_msgs.PerceptionLocalization) {
-			log.Printf("Incoming: %+v\n", msg)
-		},
-	})
-	if err != nil {
-		panic(err)
-	}
-	defer sub.Close()
-
-	// // wait for CTRL-C
-	// c := make(chan os.Signal, 1)
-	// signal.Notify(c, os.Interrupt)
-	// <-c
-	// ------------------------------------------------------------------------------------
-
 	// 指定文件路径
 	filePath := "C:\\Users\\mlxengingin\\Desktop\\1118\\my-bag.bag"
 
@@ -68,8 +39,8 @@ func TestWriteRosBag(t *testing.T) {
 		Data: rosbag.ConnectionHeader{
 			Topic:             "/cicv_location",
 			Type:              "perception_msgs/PerceptionLocalization",
-			MD5Sum:            "abc",
-			MessageDefinition: []byte{0x01, 0x02, 0x03},
+			MD5Sum:            "b871ae769d4b537baab00d1c75ff3891",
+			MessageDefinition: []byte("定位信息"),
 
 			//// optional fields
 			//CallerID: &callerID,
@@ -79,20 +50,47 @@ func TestWriteRosBag(t *testing.T) {
 	if err != nil {
 		panic(err)
 	}
+	// -------------------------------------------------------------------------------------
 
-	for i := 0; i < 10000; i++ {
-		nowInt := time.Now().Unix()
-		data := pjisuv_msgs.PerceptionLocalization{}
-		err = writer.WriteMessage(&rosbag.Message{
-			Conn: 1,
-			Time: uint64(nowInt),
-			Data: []byte(data),
-		})
-		if err != nil {
-			panic(err)
-		}
-		t.Log("当前时间", uint64(nowInt))
-		t.Log("保存数据", data)
+	// create a node and connect to the master
+	n, err := goroslib.NewNode(goroslib.NodeConf{
+		Name:          "goroslib_sub",
+		MasterAddress: "127.0.0.1:11311",
+	})
+	if err != nil {
+		panic(err)
 	}
+	defer n.Close()
+
+	// create a subscriber
+	sub, err := goroslib.NewSubscriber(goroslib.SubscriberConf{
+		Node:  n,
+		Topic: "/cicv_location",
+		Callback: func(msg *pjisuv_msgs.PerceptionLocalization) {
+			log.Printf("Incoming: %+v\n", msg)
+			nowInt := time.Now().Unix()
+			data := pjisuv_msgs.PerceptionLocalization{}
+			err = writer.WriteMessage(&rosbag.Message{
+				Conn: 1,
+				Time: uint64(nowInt),
+				Data: []byte(msg),
+			})
+			if err != nil {
+				panic(err)
+			}
+			t.Log("当前时间", uint64(nowInt))
+			t.Log("保存数据", data)
+		},
+	})
+	if err != nil {
+		panic(err)
+	}
+	defer sub.Close()
+
+	// // wait for CTRL-C
+	// c := make(chan os.Signal, 1)
+	// signal.Notify(c, os.Interrupt)
+	// <-c
+	// ------------------------------------------------------------------------------------
 
 }