Closed germal closed 3 years ago
printing the ros_numpy array just after the pointcloud assignment
array=rosnp.point_cloud2.pointcloud2_to_xyz_array(self.cloud_msg,False)
I discovered that it has only 2 dimensions and the second axis has indeed only 3 elements , as the error states . Finally I found out that the realsense pointcloud topic I was using wasn't suitable for the ros_numpy array , so I used the depth_registered pointcloud and now my script works .
Regards
I found that the right pointcloud is the depth_registered/points
solved
Hello I have found the following code that assign to a rgb image the related pointcloud of the object detected ( the topic /camera/depth/points) . I have the error
if math.isnan(array[path_points[i][j][0]][path_points[i][j][1]][0]) or \ IndexError: index 124 is out of bounds for axis 0 with size 3
related to the following ros_numpy array
Could you please help me to debug ? Thanks a lot
!/usr/bin/env python3
import os, sys import numpy as np import math import statistics import matplotlib.pyplot as plt from matplotlib.path import Path
import rospy import ros_numpy as rosnp
from sensor_msgs.msg import PointCloud2 from std_msgs.msg import String
from yolact_ros_msgs.msg import Detections from yolact_ros_msgs.msg import Detection from yolact_ros_msgs.msg import Box from yolact_ros_msgs.msg import Mask from yolact_ros_msgs.msg import Mask_Depth, Mask_Coordinates
import skimage.data
Debug printing whole array
np.set_printoptions(threshold=sys.maxsize)
class MaskTo3D(object):
if name=="main": a=MaskTo3D() while not rospy.is_shutdown(): a.rate.sleep()
Thanks