rospy can not receive custom message
I customized the following two messsages and found that the rospy callback function test_cb
did not work.
Point3D.msg
float32[3] point3D
PosedImage.msg
float64 timestamp
geometry_msgs/Pose pose
sensor_msgs/Image image
sensor_msgs/CameraInfo camera
Point3D[] listPoint3D
Here is the code of the subscriber node:
def test_cb(msg):
print("Get")
rospy.Subscriber("/VO/key_posed_image", PosedImage, test_cd)
rospy.loginfo("test save_data, start...")
rospy.spin()
However, the cpp version of test_cb
works well.
If I removed the listPoint3D
in PosedImage
, then the rospy callback function can also work well.
So, I wonder why the Point3D[]
would make rospy fail to receive PosedImage.msg
.
Really appreciate any hints or help.
Asked by gcc97 on 2022-09-07 10:02:19 UTC
Comments
Probably,
float32[3]
is the culprit. The fixed-size array was introduced mainly in ROS 2. A workaround should be changing the Point3D.msg to as shown below:Asked by ravijoshi on 2022-09-07 23:06:49 UTC