Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion src/app/dashboard/api/route.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
const hosts = ['192.168.0.2', '192.168.0.3', '192.168.0.55']; // Add more hosts here as needed
import { BASE_AP_IP, ROVER_AP_IP, ROVER_IP } from '@/constants';

const hosts = [BASE_AP_IP, ROVER_AP_IP, ROVER_IP];

const ping = require('ping');

Expand Down
3 changes: 2 additions & 1 deletion src/components/ConnectionStatusDisplay.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@
import React, { useState, useEffect } from 'react';
import Cookies from 'js-cookie';
import { useROS } from '@/ros/ROSContext';
import { ROVER_IP } from '@/constants';

const ConnectionStatusDisplay: React.FC = () => {
const { connectionStatus, connect, disconnect } = useROS();
const [url, setUrl] = useState('ws://localhost:9090');
const [url, setUrl] = useState(`ws://${ROVER_IP}:9090`);

// Load url from cookie on mount
useEffect(() => {
Expand Down
5 changes: 0 additions & 5 deletions src/components/ContainerCard.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
import React, { useEffect, useRef, useState } from 'react';
import { useEnvContext } from 'next-runtime-env';



export interface ContainerOption {
key: string;
Expand Down Expand Up @@ -32,8 +29,6 @@ const ContainerCard: React.FC<ContainerCardProps> = ({
const [eventMsg, setEventMsg] = useState<string | null>(externalEventMsg);
const socketRef = useRef<WebSocket | null>(null);
const logBoxRef = useRef<HTMLPreElement>(null);
const { NEXT_PUBLIC_LAUNCHSERVER } = useEnvContext();
const apiBase = NEXT_PUBLIC_LAUNCHSERVER || 'localhost:8080';

Comment thread
ConnorNeed marked this conversation as resolved.
// Sync status and clear logs/eventMsg when container ID changes (new container after restart)
useEffect(() => {
Expand Down
3 changes: 2 additions & 1 deletion src/components/ContainerList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import React, { useEffect, useState, useRef } from 'react';
import ContainerCard, { ContainerOption } from './ContainerCard';
import SetResetPanel from './SetResetPanel';
import toast from "react-hot-toast";
import { ROVER_IP } from '@/constants';


const dockersToPull = [
Expand All @@ -11,7 +12,7 @@ const dockersToPull = [
'cprtsoftware/container-launcher:latest',
];

const DEFAULT_API_BASE = 'http://localhost:8080';
const DEFAULT_API_BASE = `http://${ROVER_IP}:8080`;

const ContainerList: React.FC = () => {
const [options, setOptions] = useState<ContainerOption[]>([]);
Expand Down
6 changes: 2 additions & 4 deletions src/components/panels/MapView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ import BreadcrumbTrail from '../BreadCrumbTrail';
import WaypointCreatorWindow from '../WaypointCreatorWindow';
import MapInteractionHandler from '../MapInteractionHandler';
import MapCompass from '../MapCompass';
import { useEnvContext } from 'next-runtime-env';
import { useROS } from '@/ros/ROSContext';
import ROSLIB from 'roslib';
import { TILING_SERVER } from '@/constants';

const DEFAULT_MAP_CENTER: LatLngTuple = [38.405884, -110.791719];

Expand Down Expand Up @@ -50,8 +50,6 @@ const MapView: React.FC<MapViewProps> = ({offline}) => {
const [antennaLoc, setAntennaLoc] = useState<LatLngTuple>(DEFAULT_MAP_CENTER);
const [antennaHead, setAntennaHead] = useState<number>(0);
const { waypoints } = useWaypoints();
const { NEXT_PUBLIC_TILE_SERVER } = useEnvContext();
const tileServer = NEXT_PUBLIC_TILE_SERVER || "localhost:80";

useEffect(() => {
if (!ros) return;
Expand Down Expand Up @@ -112,7 +110,7 @@ const MapView: React.FC<MapViewProps> = ({offline}) => {
>
<TileLayer
maxZoom = {22}
url={offline? `http://${tileServer}/{z}/{x}/{y}.png` : "https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png"}
url={offline? `http://${TILING_SERVER}/{z}/{x}/{y}.png` : "https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png"}
attribution="&copy; Maptiler server"
/>
<MapInteractionHandler />
Expand Down
4 changes: 3 additions & 1 deletion src/components/panels/MosaicDashboard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ import PDBRailsPanel from './PDBRails';
import ArmControlPanel from './ArmControlPanel';
import WebRTCClient from './WebRTCClient';

import { ROVER_IP } from '@/constants';

type TileType =
| 'mapView'
| 'rosMonitor'
Expand Down Expand Up @@ -439,7 +441,7 @@ const MosaicDashboard: React.FC = () => {
return(
<MosaicWindow {...windowProps}>
<WebRTCClient
config={{ signalingUrl: `ws://192.168.0.55:8444` }}
config={{ signalingUrl: `ws://${ROVER_IP}:8444` }}
/>
</MosaicWindow>
);
Expand Down
9 changes: 9 additions & 0 deletions src/constants.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
// src/constants.ts

export const ROVER_IP = '192.168.0.55';
export const BASE_AP_IP = '192.168.0.2';
export const ROVER_AP_IP = '192.168.0.3';
export const RPI_IP = '192.168.0.25';
export const BASE_IP = '192.168.0.20';
export const TILING_SERVER_PORT = 80;
export const TILING_SERVER = `${BASE_IP}:${TILING_SERVER_PORT}`;
9 changes: 0 additions & 9 deletions start.sh
Original file line number Diff line number Diff line change
@@ -1,13 +1,5 @@
#!/bin/bash

LOCAL_IP=""
while [ -z "$LOCAL_IP" ]; do
LOCAL_IP=$(ip addr show enP8p1s0 | grep -oP '(?<=inet )([0-9\.]+)' || hostname -I | awk '{print $1}')
sleep 1
done
LOCAL_IP="192.168.0.20"
TILING_SERVER_PORT=80
echo "Local IP address: $LOCAL_IP"

if docker ps -a --format '{{.Names}}' | grep -wq "tiling-server-container"; then
echo "Tiling container exists, removing..."
Expand All @@ -21,6 +13,5 @@ docker run --rm --name tiling-server-container -d \

docker run --rm --name cprt-webserver \
-p 3000:3000 \
-e NEXT_PUBLIC_TILE_SERVER="$LOCAL_IP:$TILING_SERVER_PORT" \
cprtsoftware/web-ui:latest

Loading