@@ -126,6 +126,9 @@ def get_reading(self) -> GEMVehicleReading:
126126
127127 def subscribe_sensor (self , name , callback , type = None ):
128128 if name == 'gnss' :
129+ topic = self .ros_sensor_topics ['gps' ]
130+ if type is not None and (type is not GNSSReading and type is not NavSatFix ):
131+ raise ValueError ("Gazebo GEM e2 only supports NavSatFix/GNSSReading for GNSS" )
129132 # Fuse IMU orientation with GNSS position
130133 def gnss_callback_wrapper (gps_msg : NavSatFix ):
131134 if self .imu_data is None :
@@ -182,65 +185,50 @@ def gnss_callback_wrapper(gps_msg: NavSatFix):
182185
183186 callback (reading )
184187
185- self .gnss_sub = rospy .Subscriber (
186- '/gps/fix' , NavSatFix , gnss_callback_wrapper )
188+ self .gnss_sub = rospy .Subscriber (topic , NavSatFix , gnss_callback_wrapper )
187189
188190 elif name == 'top_lidar' :
189- topic = '/velodyne_points' # Standard LiDAR topic from Gazebo
191+ topic = self . ros_sensor_topics [ name ]
190192 if type is not None and (type is not PointCloud2 and type is not np .ndarray ):
191- raise ValueError (
192- "GEMGazeboInterface only supports PointCloud2 or numpy array for top lidar" )
193+ raise ValueError ("GEMGazeboInterface only supports PointCloud2 or numpy array for top lidar" )
193194 if type is None or type is PointCloud2 :
194- self .top_lidar_sub = rospy .Subscriber (
195- topic , PointCloud2 , callback )
195+ self .top_lidar_sub = rospy .Subscriber (topic , PointCloud2 , callback )
196196 else :
197197 def callback_with_numpy (msg : PointCloud2 ):
198- points = conversions .ros_PointCloud2_to_numpy (
199- msg , want_rgb = False )
198+ points = conversions .ros_PointCloud2_to_numpy (msg , want_rgb = False )
200199 callback (points )
201- self .top_lidar_sub = rospy .Subscriber (
202- topic , PointCloud2 , callback_with_numpy )
200+ self .top_lidar_sub = rospy .Subscriber (topic , PointCloud2 , callback_with_numpy )
203201
204202 elif name == 'imu' :
205- topic = '/imu' # Standard IMU topic from Gazebo
203+ topic = self . ros_sensor_topics [ name ]
206204 if type is not None and type is not Imu :
207- raise ValueError (
208- "GEMGazeboInterface only supports Imu for IMU data" )
205+ raise ValueError ("GEMGazeboInterface only supports Imu for IMU data" )
209206 self .imu_sub = rospy .Subscriber (topic , Imu , callback )
210207
211208 elif name == 'front_camera' :
212- # Assume standard ROS camera topics from Gazebo
213- default_topic = '/front_single_camera/image_raw'
214- topic = self .ros_sensor_topics .get (name , default_topic )
209+ topic = self .ros_sensor_topics [name ]
215210 if type is not None and (type is not Image and type is not cv2 .Mat ):
216- raise ValueError (
217- "GEMGazeboInterface only supports Image or OpenCV for front camera" )
211+ raise ValueError ("GEMGazeboInterface only supports Image or OpenCV for front camera" )
218212 if type is None or type is Image :
219- self .front_camera_sub = rospy .Subscriber (
220- topic , Image , callback )
213+ self .front_camera_sub = rospy .Subscriber (topic , Image , callback )
221214 else :
222215 def callback_with_cv2 (msg : Image ):
223- cv_image = conversions .ros_Image_to_cv2 (
224- msg , desired_encoding = "bgr8" )
216+ cv_image = conversions .ros_Image_to_cv2 (msg , desired_encoding = "bgr8" )
225217 callback (cv_image )
226- self .front_camera_sub = rospy .Subscriber (
227- topic , Image , callback_with_cv2 )
228-
218+ self .front_camera_sub = rospy .Subscriber (topic , Image , callback_with_cv2 )
219+ # Front depth sensor has not been added to gazebo yet.
220+ # This code is placeholder until we add front depth sensor.
229221 elif name == 'front_depth' :
230- default_topic = '/front_single_camera/depth/image_raw'
231- topic = self .ros_sensor_topics .get (name , default_topic )
222+ topic = self .ros_sensor_topics [name ]
232223 if type is not None and (type is not Image and type is not cv2 .Mat ):
233- raise ValueError (
234- "GEMGazeboInterface only supports Image or OpenCV for front depth" )
224+ raise ValueError ("GEMGazeboInterface only supports Image or OpenCV for front depth" )
235225 if type is None or type is Image :
236226 self .front_depth_sub = rospy .Subscriber (topic , Image , callback )
237227 else :
238228 def callback_with_cv2 (msg : Image ):
239- cv_image = conversions .ros_Image_to_cv2 (
240- msg , desired_encoding = "passthrough" )
229+ cv_image = conversions .ros_Image_to_cv2 (msg , desired_encoding = "passthrough" )
241230 callback (cv_image )
242- self .front_depth_sub = rospy .Subscriber (
243- topic , Image , callback_with_cv2 )
231+ self .front_depth_sub = rospy .Subscriber (topic , Image , callback_with_cv2 )
244232
245233 def hardware_faults (self ) -> List [str ]:
246234 # In simulation, we don't have real hardware faults
0 commit comments