Ask Your Question

aseembits93's profile - activity

2019-03-05 14:51:32 -0500 marked best answer Synchronize amcl_pose with image?

Hi, So I am trying to collect synchronized pairs of /amcl_pose and /image_rect_color on the Fetch robot. Here's the code I'm running.

#!/usr/bin/env python2
# amcl_listener
from copy import deepcopy
import rospy

from math import sin, cos


from geometry_msgs.msg import PoseWithCovarianceStamped as Pose
from sensor_msgs.msg import Image
import cv2
import pdb as pdb


class amcl_listener(object):
    def __init__(self):
            # Create a node
        rospy.init_node("amcl_listener")
        self.amcl_list = []
        self.image_list = []
        # Make sure sim time is working
        while not rospy.Time.now():
            pass
        self.img_sub = rospy.Subscriber(
            '/head_camera/rgb/image_rect_color', Image, self.cb_image)
        self.amcl_sub = rospy.Subscriber(
            '/amcl_pose', Pose, self.cb_amcl)
        self.curimg = None
        self.amcl_pose = None
        while not rospy.is_shutdown():
            pass


    def cb_image(self, msg):
        self.curimg = msg
        print "got image at ", rospy.Time.now()
    def cb_amcl(self, msg):
        self.amcl_pose = msg
        print "got amcl at ", rospy.Time.now()

    if __name__ == "__main__":
        start = amcl_listener()

Here comes the problem, The difference between the time the first image message arrives and the first amcl pose message arrives is close to 2 seconds according to rospy.Time.now(). I tried to compare header stamps but they are also problematic. Any help would be appreciated!

2019-03-05 14:50:38 -0500 received badge  Famous Question (source)
2018-04-09 04:52:23 -0500 received badge  Notable Question (source)
2018-01-23 19:56:46 -0500 commented answer Synchronize amcl_pose with image?

Hi @PeteBlackerThe3rd! I have tried this thing. It doesn't work in my case. I think it works for messages with a similar

2018-01-23 19:27:55 -0500 received badge  Popular Question (source)
2018-01-22 20:13:18 -0500 asked a question Synchronize amcl_pose with image?

Synchronize amcl_pose with image? Hi, So I am trying to collect synchronized pairs of /amcl_pose and /image_rect_color o