MCPcopy Create free account
hub / github.com/botbotrobotics/BotBrain / testMapSubscription

Function testMapSubscription

frontend/src/components/map-view.tsx:304–343  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

302
303 // Test direct subscription to map topic first
304 const testMapSubscription = () => {
305 const mapListener = new ROSLIB.Topic({
306 ros: connection.ros!,
307 name: mapTopic,
308 messageType: 'nav_msgs/OccupancyGrid'
309 });
310
311 console.log(`Testing direct subscription to ${mapTopic}`);
312
313 mapListener.subscribe((message: any) => {
314 console.log('Raw map message received!', {
315 hasInfo: !!message.info,
316 hasData: !!message.data,
317 dataLength: message.data?.length,
318 width: message.info?.width,
319 height: message.info?.height,
320 resolution: message.info?.resolution
321 });
322
323 // If we get data via direct subscription but not via ROS2D,
324 // it might be a ROS2D compatibility issue
325 if (message.info && message.data) {
326 console.warn('Map data received via direct subscription but ROS2D might not be updating');
327 // Try the fallback renderer if we're getting data but ROS2D isn't working
328 setTimeout(() => {
329 if (!gridClientRef.current?.currentGrid) {
330 console.log('ROS2D not working, trying fallback');
331 if (tryFallbackMapRenderingRef.current) {
332 tryFallbackMapRenderingRef.current();
333 }
334 }
335 }, 2000);
336 }
337 });
338
339 // Clean up after 10 seconds
340 setTimeout(() => {
341 mapListener.unsubscribe();
342 }, 10000);
343 };
344
345 testMapSubscription();
346

Callers 1

initializeMapFunction · 0.85

Calls 1

logMethod · 0.80

Tested by

no test coverage detected