({ className = '' }: MapViewNav2Props)
| 27 | } |
| 28 | |
| 29 | export default function MapViewNav2({ className = '' }: MapViewNav2Props) { |
| 30 | const { connection } = useRobotConnection(); |
| 31 | const { t } = useLanguage(); |
| 32 | const { dispatch: notificationDispatch } = useNotifications(); |
| 33 | const canvasRef = useRef<HTMLCanvasElement>(null); |
| 34 | const containerRef = useRef<HTMLDivElement>(null); |
| 35 | const animationFrameRef = useRef<number | undefined>(undefined); |
| 36 | const mapTopic = '/map'; |
| 37 | const { occupancyGrid, isLoading, error } = useOccupancyGrid({ topicName: mapTopic }); |
| 38 | |
| 39 | // Get robot position in map frame |
| 40 | const robotPose = useMapPose(); |
| 41 | |
| 42 | // Get navigation plan |
| 43 | const { navPlan } = useRosNavPlan('/plan'); |
| 44 | const [showNavPlan, setShowNavPlan] = useState(false); |
| 45 | |
| 46 | // Local costmap overlay |
| 47 | const [showLocalCostmap, setShowLocalCostmap] = useState(false); |
| 48 | const { occupancyGrid: localCostmap } = useOccupancyGrid({ |
| 49 | topicName: '/local_costmap/costmap', |
| 50 | enabled: showLocalCostmap, |
| 51 | throttleMs: 0 // No throttling for real-time updates |
| 52 | }); |
| 53 | const localCostmapRef = useRef(localCostmap); |
| 54 | const costmapImageCacheRef = useRef<ImageData | null>(null); |
| 55 | const costmapDataHashRef = useRef<string>(''); |
| 56 | |
| 57 | // Navigation waypoints functionality |
| 58 | const { |
| 59 | navigateThroughWaypoints, |
| 60 | cancelNavigation, |
| 61 | isNavigating, |
| 62 | currentWaypointIndex, |
| 63 | navigationError, |
| 64 | isConnected: nav2Connected |
| 65 | } = useNav2Waypoints(); |
| 66 | |
| 67 | // Active mission context for displaying mission waypoints on map |
| 68 | const { |
| 69 | missionWaypoints, |
| 70 | currentWaypointIndex: missionWaypointIndex, |
| 71 | isMissionActive |
| 72 | } = useActiveMission(); |
| 73 | |
| 74 | // Navigation targets context for AR overlay |
| 75 | const { setSingleGoal } = useNavigationTargets(); |
| 76 | |
| 77 | const [isWaypointMode, setIsWaypointMode] = useState(false); |
| 78 | const [waypoint, setWaypoint] = useState<Waypoint | null>(null); |
| 79 | const [isDraggingWaypoint, setIsDraggingWaypoint] = useState(false); |
| 80 | const [tempWaypoint, setTempWaypoint] = useState<Waypoint | null>(null); |
| 81 | const [hasNavigationStarted, setHasNavigationStarted] = useState(false); |
| 82 | const [isStopping, setIsStopping] = useState(false); |
| 83 | |
| 84 | // Set Home mode state |
| 85 | const [isSetHomeMode, setIsSetHomeMode] = useState(false); |
| 86 | const [isDraggingHome, setIsDraggingHome] = useState(false); |
nothing calls this directly
no test coverage detected