For monitoring telemetry and remote rocket setup.
- Required Tools:
- Git
- Node.js
- npm
- Docker
- Mosquitto
# Clone your project repository
git clone http://nakujaproject/n4-basestation
cd n4-basestation
# Switch to specific branch if needed
git checkout -b <branch-name>
# Install project dependencies
npm install
Install Docker on your computer.
-
If you are using Windows, please follow steps for installing Docker Desktop on Windows.
-
If you are using macOS, please be sure to follow the steps outlined in Docker Docs for how to install Docker Desktop for Mac
-
If you are using Linux, please be sure to follow the steps outlined in Docker Docs for how to install Docker Engine and Docker Desktop for linux
-
Create a docker group
#!/bin/bash sudo groupadd docker
-
Add your user to the
docker
group.#!/bin/bash sudo usermod -aG docker $USER
-
Log out and log back in so that your group membership is re-evaluated.
-
Verify that you can run
docker
commands withoutsudo
. -
For more information follow this link
Then install TileServer-GL in order to serve the map.
docker pull maptiler/tileserver-gl
Now download the vector tiles in form of MBTiles file from the OpenMapTiles Downloads and save it in your current directory. Go to Kenya's map to get the relevant mbtiles file.
Example using a mbtiles file
docker run --rm -it -v $(pwd):/data -p 8080:8080 maptiler/tileserver-gl --file osm-2020-02-10-v3.11_africa_kenya.mbtiles
[in your browser, visit http://[server ip]:8080]
# MQTT Configuration
VITE_MQTT_HOST="localhost"
VITE_WS_PORT=1783
# Video Configuration
VITE_VIDEO_URL = "192.168.X.X:XXXX"
# Run vite development server
npm run dev
# Start Docker if not started
docker run --rm -it -v $(pwd):/data -p 8080:8080 maptiler/tileserver-gl --file osm-2020-02-10-v3.11_africa_kenya.mbtiles
# Start Mosquitto service
mosquitto -c mosquitto.conf
# Access Services
# React App: http://localhost:5173
# MapTiler: http://localhost:8080
- Verify Docker services are running
- Check environment configurations
- Ensure network ports are available
- Confirm Node.js versions
# Resolve npm install dependency conflicts
npm install --force
# If map is not rendering restart docker
MQTT topic structure, data formats, and configuration details used. The system uses MQTT for bi-directional communication between the flight computer and ground station.
Create a .env
file in the root directory with the following variables:
# MQTT Configuration
VITE_MQTT_HOST=localhost # WebSocket URL for MQTT broker
VITE_WS_PORT=1783 # WebSocket port for MQTT
# API Configuration
VITE_STREAM_URL=http://ip-addr:port # Video stream server URL
Service | Specified Port | Description |
---|---|---|
MQTT WebSocket | 1783 | MQTT broker WebSocket port for dashboard communication |
MQTT TCP | 1882 | MQTT broker TCP port for wifi device connections |
Video Stream | XXXX | RTSP stream server port |
Dashboard | 5173 | Development server port (when running npm run dev ) |
Dashboard | 80 | Production server port (when running built version) |
- Protocol: MQTT over WebSocket
- Default Port: Define in environment variable
VITE_WS_PORT
- Host: Define in environment variable
VITE_MQTT_HOST
- Client ID Format:
dashboard-[random-hex]
- Keep Alive Interval: 3600 seconds
The dashboard subscribes to the following topics:
n4/telemetry
- Main telemetry data from the flight computern4/logs
- System logs and status messages.
The dashboard publishes to:
n4/commands
- Control commands to the flight computer. To arm or disarm.
{
"state": number, // Flight state (0-6)
"operation_mode": number, // 0: Safe, 1: Armed
"gps_data": {
"latitude": number,
"longitude": number,
"gps_altitude": number
},
"alt_data": {
"pressure": number,
"temperature": number,
"AGL": number, // Altitude above ground level
"velocity": number
},
"acc_data": {
"ax": number, // Acceleration X-axis
"ay": number, // Acceleration Y-axis
"az": number // Acceleration Z-axis
},
"chute_state": {
"pyro1_state": number, // Drogue parachute state
"pyro2_state": number // Main parachute state
},
"battery_voltage": number
}
{
"level": string, // "INFO", "ERROR", "WARN", "DEBUG".
"message": string, // Log message content
"source": string // "Flight Computer" or "Base Station" or other source identifier
}
{
"command": string // "ARM" or "DISARM"
}
The system recognizes the following flight states:
- 0: Pre-Flight
- 1: Powered Flight
- 2: Apogee
- 3: Drogue Deployed
- 4: Main Deployed
- 5: Rocket Descent
- 6: Post Flight
- Base station connection status is monitored continuously
- Flight computer data staleness is checked every 500ms
- Connection is marked as "No Recent Data" if no telemetry is received for > 5 seconds
- The dashboard expects an RTSP stream to be available at the URL specified in
VITE_STREAM_URL
- The video component will automatically attempt to connect to this stream
- Ensure the RTSP server is properly configured and accessible from the dashboard's network
- Connection failures are logged with timestamps
- Parsing errors for incoming messages are captured and reported
- Command transmission failures are logged and reported to the user
- Data staleness is monitored and reported in the UI
// Connect to MQTT broker
const client = new MQTT.Client(
mqtt_host,
ws_port,
`dashboard-${Math.random().toString(16).slice(2, 8)}`
);
// Configure connection
client.connect({
onSuccess: () => {
client.subscribe(["n4/telemetry", "n4/logs"]);
},
keepAliveInterval: 3600
});
// Send command example
const message = new MQTT.Message(
JSON.stringify({
command: "ARM"
})
);
message.destinationName = "n4/commands";
client.send(message);