AttributeError: 'NoneType' object has no attribute 'cuda'
fjrdev opened this issue · comments
fjrdev commented
I have adjusted tracking.py so that VoxFusion works on sequential data played from a rosbag:
def spin(self, share_data, kf_buffer):
print("******* tracking process started! *******")
frame_id = 0
rgb = torch.zeros((540, 960, 3))
depth = torch.zeros((540, 960))
k = torch.tensor([[805.110054612012, 0.0, 427.0664954600349],
[0.0, 804.744879684146, 269.1892972689079],
[0.0, 0.0, 1.0]])
data_in = [frame_id, rgb, depth, k]
def pub():
nonlocal frame_id
if frame_id == 0:
self.process_first_frame(kf_buffer, data_in)
else:
#try:
# "*" unzips the np array
current_frame = RGBDFrame(*data_in)
self.do_tracking(share_data, current_frame, kf_buffer)
if self.render_freq > 0 and (frame_id + 1) % self.render_freq == 0:
self.render_debug_images(share_data, current_frame)
#except Exception as e:
# print("error in dataloading: ", e, f"skipping frame {frame_id}")
frame_id += 1
def process(depth_data, image_data):
image_arr = np.frombuffer(image_data.data, dtype=np.uint8).reshape(image_data.height, image_data.width, -1)
data_in[1] = torch.tensor(image_arr)
disparity_arr = np.frombuffer(depth_data.image.data, dtype=np.float32).reshape(depth_data.image.height, depth_data.image.width)
focal_length = 805.110054612012
baseline = 4.858120401781332
f = lambda x: (focal_length * baseline) / x
depth_arr = f(disparity_arr)
print(depth_arr.shape)
data_in[2] = torch.tensor(depth_arr)
pub()
def listener():
rospy.init_node('dense_map', anonymous=True)
depth = message_filters.Subscriber('/stereo/disparity', DisparityImage)
image = message_filters.Subscriber('/stereo/left/image_raw', Image)
ts = message_filters.TimeSynchronizer([depth, image], 10)
ts.registerCallback(process)
print("INIT LISTENER")
rospy.spin()
listener()
share_data.stop_mapping = True
print("******* tracking process died *******")
I´m not sure why, but it does not seem to be able utilize the share_data
attribute correctly, since its of type NoneType in my case. The error AttributeError: 'NoneType' object has no attribute 'cuda'
gets thrown in 102 of tracking.py: decoder = share_data.decoder.cuda()
. Does anyone have an idea what could went wrong here?
Kaktusava commented
Change sleep(5) to sleep(20) in def start(self) in voxslam.py