bluenviron/goroslib

Always missing the first message

StephenChou0119 opened this issue · 1 comments

background

  1. use https://github.com/aler9/goroslib/blob/main/examples/subscriber/main.go for subscriber
  2. use https://github.com/aler9/goroslib/blob/main/examples/publisher/main.go for publisher
  3. test on ros kinetic & melodic
  4. go version: go version go1.16.2 linux/amd64
  5. os version:16.04.1-Ubuntu
  6. kernel version 4.15.0-142-generic
  7. goroslib version: github.com/aler9/goroslib@v0.0.0-20210508173954-2107caea48ac

problem description

always missing th first message
pub:
Outgoing: &{Package:0 Header:{Package:0 Seq:0 Stamp:0001-01-01 00:00:00 +0000 UTC FrameId:} Orientation:{Package:0 X:0 Y:0 Z:0 W:0} OrientationCovariance:[0 0 0 0 0 0 0 0 0] AngularVelocity:{Package:0 X:23.5 Y:22.1 Z:-7.5} AngularVelocityCovariance:[0 0 0 0 0 0 0 0 0] LinearAcceleration:{Package:0 X:0 Y:0 Z:0} LinearAccelerationCovariance:[0 0 0 0 0 0 0 0 0]}
Outgoing: &{Package:0 Header:{Package:0 Seq:1 Stamp:0001-01-01 00:00:00 +0000 UTC FrameId:} Orientation:{Package:0 X:0 Y:0 Z:0 W:0} OrientationCovariance:[0 0 0 0 0 0 0 0 0] AngularVelocity:{Package:0 X:23.5 Y:22.1 Z:-7.5} AngularVelocityCovariance:[0 0 0 0 0 0 0 0 0] LinearAcceleration:{Package:0 X:0 Y:0 Z:0} LinearAccelerationCovariance:[0 0 0 0 0 0 0 0 0]}
Outgoing: &{Package:0 Header:{Package:0 Seq:2 Stamp:0001-01-01 00:00:00 +0000 UTC FrameId:} Orientation:{Package:0 X:0 Y:0 Z:0 W:0} OrientationCovariance:[0 0 0 0 0 0 0 0 0] AngularVelocity:{Package:0 X:23.5 Y:22.1 Z:-7.5} AngularVelocityCovariance:[0 0 0 0 0 0 0 0 0] LinearAcceleration:{Package:0 X:0 Y:0 Z:0} LinearAccelerationCovariance:[0 0 0 0 0 0 0 0 0]}
Outgoing: &{Package:0 Header:{Package:0 Seq:3 Stamp:0001-01-01 00:00:00 +0000 UTC FrameId:} Orientation:{Package:0 X:0 Y:0 Z:0 W:0} OrientationCovariance:[0 0 0 0 0 0 0 0 0] AngularVelocity:{Package:0 X:23.5 Y:22.1 Z:-7.5} AngularVelocityCovariance:[0 0 0 0 0 0 0 0 0] LinearAcceleration:{Package:0 X:0 Y:0 Z:0} LinearAccelerationCovariance:[0 0 0 0 0 0 0 0 0]}
Outgoing: &{Package:0 Header:{Package:0 Seq:4 Stamp:0001-01-01 00:00:00 +0000 UTC FrameId:} Orientation:{Package:0 X:0 Y:0 Z:0 W:0} OrientationCovariance:[0 0 0 0 0 0 0 0 0] AngularVelocity:{Package:0 X:23.5 Y:22.1 Z:-7.5} AngularVelocityCovariance:[0 0 0 0 0 0 0 0 0] LinearAcceleration:{Package:0 X:0 Y:0 Z:0} LinearAccelerationCovariance:[0 0 0 0 0 0 0 0 0]}
Outgoing: &{Package:0 Header:{Package:0 Seq:5 Stamp:0001-01-01 00:00:00 +0000 UTC FrameId:} Orientation:{Package:0 X:0 Y:0 Z:0 W:0} OrientationCovariance:[0 0 0 0 0 0 0 0 0] AngularVelocity:{Package:0 X:23.5 Y:22.1 Z:-7.5} AngularVelocityCovariance:[0 0 0 0 0 0 0 0 0] LinearAcceleration:{Package:0 X:0 Y:0 Z:0} LinearAccelerationCovariance:[0 0 0 0 0 0 0 0 0]}
sub:
Incoming: &{Package:0 Header:{Package:0 Seq:1 Stamp:0001-01-01 00:00:00 +0000 UTC FrameId:} Orientation:{Package:0 X:0 Y:0 Z:0 W:0} OrientationCovariance:[0 0 0 0 0 0 0 0 0] AngularVelocity:{Package:0 X:23.5 Y:22.1 Z:-7.5} AngularVelocityCovariance:[0 0 0 0 0 0 0 0 0] LinearAcceleration:{Package:0 X:0 Y:0 Z:0} LinearAccelerationCovariance:[0 0 0 0 0 0 0 0 0]}
Incoming: &{Package:0 Header:{Package:0 Seq:2 Stamp:0001-01-01 00:00:00 +0000 UTC FrameId:} Orientation:{Package:0 X:0 Y:0 Z:0 W:0} OrientationCovariance:[0 0 0 0 0 0 0 0 0] AngularVelocity:{Package:0 X:23.5 Y:22.1 Z:-7.5} AngularVelocityCovariance:[0 0 0 0 0 0 0 0 0] LinearAcceleration:{Package:0 X:0 Y:0 Z:0} LinearAccelerationCovariance:[0 0 0 0 0 0 0 0 0]}
Incoming: &{Package:0 Header:{Package:0 Seq:3 Stamp:0001-01-01 00:00:00 +0000 UTC FrameId:} Orientation:{Package:0 X:0 Y:0 Z:0 W:0} OrientationCovariance:[0 0 0 0 0 0 0 0 0] AngularVelocity:{Package:0 X:23.5 Y:22.1 Z:-7.5} AngularVelocityCovariance:[0 0 0 0 0 0 0 0 0] LinearAcceleration:{Package:0 X:0 Y:0 Z:0} LinearAccelerationCovariance:[0 0 0 0 0 0 0 0 0]}
Incoming: &{Package:0 Header:{Package:0 Seq:4 Stamp:0001-01-01 00:00:00 +0000 UTC FrameId:} Orientation:{Package:0 X:0 Y:0 Z:0 W:0} OrientationCovariance:[0 0 0 0 0 0 0 0 0] AngularVelocity:{Package:0 X:23.5 Y:22.1 Z:-7.5} AngularVelocityCovariance:[0 0 0 0 0 0 0 0 0] LinearAcceleration:{Package:0 X:0 Y:0 Z:0} LinearAccelerationCovariance:[0 0 0 0 0 0 0 0 0]}
Incoming: &{Package:0 Header:{Package:0 Seq:5 Stamp:0001-01-01 00:00:00 +0000 UTC FrameId:} Orientation:{Package:0 X:0 Y:0 Z:0 W:0} OrientationCovariance:[0 0 0 0 0 0 0 0 0] AngularVelocity:{Package:0 X:23.5 Y:22.1 Z:-7.5} AngularVelocityCovariance:[0 0 0 0 0 0 0 0 0] LinearAcceleration:{Package:0 X:0 Y:0 Z:0} LinearAccelerationCovariance:[0 0 0 0 0 0 0 0 0]}

aler9 commented

Hello, the problem here is that the subscriber connects to the publisher after the publisher has already sent its first message; to send this first message to the subscriber, regardless of the timing of the connection, use the Latch flag in the Publisher configuration:

	pub, err := goroslib.NewPublisher(goroslib.PublisherConf{
		Node:  n,
		Topic: "test_topic",
		Msg:   &sensor_msgs.Imu{},
		Latch: true,
	})
	if err != nil {
		panic(err)
	}