@@ -7,7 +7,6 @@ from cv_bridge import CvBridge
7
7
from grid_map_msgs .msg import GridMap
8
8
from monoforce .config import Config
9
9
from monoforce .ros import height_map_to_point_cloud_msg , height_map_to_gridmap_msg
10
- from monoforce .utils import normalize , read_yaml
11
10
from monoforce .cloudproc import estimate_heightmap , filter_grid , filter_range
12
11
from monoforce .utils import position
13
12
from ros_numpy import numpify , msgify
@@ -62,6 +61,10 @@ class HeightMapEstimator:
62
61
t0 = time ()
63
62
# convert messages to points
64
63
points = self .msgs_to_points (msgs )
64
+ if points is None :
65
+ rospy .logwarn ('Could not convert messages to points' )
66
+ return
67
+ rospy .logdebug ('Points shape: %s' % str (points .shape ))
65
68
66
69
# estimate height map
67
70
hm = estimate_heightmap (points , d_min = self .cfg .d_min , d_max = self .cfg .d_max ,
@@ -74,13 +77,6 @@ class HeightMapEstimator:
74
77
rospy .logdebug ('Estimated height map shape: %s' % str (height .shape ))
75
78
rospy .logdebug ('HM estimation time: %.3f' % (time () - t0 ))
76
79
77
- # publish image
78
- height_uint8 = np .asarray (255 * normalize (height ), dtype = 'uint8' )
79
- img_msg = self .cv_bridge .cv2_to_imgmsg (height_uint8 , encoding = 'mono8' )
80
- img_msg .header .stamp = msg .header .stamp
81
- img_msg .header .frame_id = msg .header .frame_id
82
- self .hm_img_pub .publish (img_msg )
83
-
84
80
# publish point cloud
85
81
t1 = time ()
86
82
cloud_msg = height_map_to_point_cloud_msg (height , self .cfg .grid_res ,
@@ -118,11 +114,11 @@ class HeightMapEstimator:
118
114
time = msg .header .stamp ,
119
115
timeout = rospy .Duration (0.5 ))
120
116
except (tf2_ros .LookupException , tf2_ros .ConnectivityException , tf2_ros .ExtrapolationException ):
121
- rospy .logwarn ('Could not get transform from %s to %s' % (msg .header .frame_id , self .cfg .robot_frame ))
122
- return
117
+ rospy .logwarn ('Could not get transform from %s to %s' % (msg .header .frame_id , self .robot_frame ))
118
+ return None
119
+
123
120
Tr = numpify (tf .transform ).reshape ((4 , 4 ))
124
121
points = np .matmul (Tr [:3 , :3 ], points .T ).T + Tr [:3 , 3 ]
125
-
126
122
all_points .append (points )
127
123
128
124
all_points = np .concatenate (all_points , axis = 0 )
0 commit comments