Skip to content

Commit

Permalink
add flight mode display
Browse files Browse the repository at this point in the history
  • Loading branch information
Tyler-Lentz committed May 4, 2024
1 parent b8c3c66 commit ef9525d
Show file tree
Hide file tree
Showing 7 changed files with 91 additions and 21 deletions.
11 changes: 7 additions & 4 deletions deployments/broach-docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,19 @@ services:
#ports:
# - 5000:5000
environment:
- OBC_ADDR=localhost:5010
- OBC_ADDR=192.168.1.51:5010
- ANTENNA_TRACKER_IP=192.168.1.36
- ANTENNA_TRACKER_PORT=4000
- MAV_DEVICE=serial:/dev/ttyUSB0
- MAV_OUTPUT1=udp:192.168.1.2:14551
- MAV_OUTPUT1=udp:192.168.1.3:14551
- MAV_OUTPUT2=udp:192.168.1.7:14551
- MAV_OUTPUT3="tcp:localhost:14551"
- MAV_OUTPUT4=""
- MAV_OUTPUT5=""
- INFLUXDB_BUCKET=mavlink
- INFLUXDB_ORG=TritonUAS
- INFLUXDB_TOKEN=influxdbToken
- INFLUXDB_URI=http://influxdb:8086
- INFLUXDB_URI=http://localhost:8086
- HUB_PATH=/go/src/github.com/tritonuas/gcs
volumes:
- missions:/go/src/github.com/tritonuas/gcs/missions
Expand All @@ -31,12 +31,14 @@ services:

influxdb:
image: influxdb:2.0-alpine
network_mode: "host"
ports:
- 8086:8086
volumes:
- influxdb_data:/var/lib/influxdb
grafana:
image: grafana/grafana:7.5.5
network_mode: "host"
ports:
- 3000:3000
environment:
Expand All @@ -57,14 +59,15 @@ services:
depends_on:
- influxdb
image: influxdb:2.0-alpine
network_mode: "host"
entrypoint: >
influx setup
--bucket mavlink
--org TritonUAS
--token influxdbToken
--username tritons
--password tritonuas
--host http://influxdb:8086
--host http://localhost:8086
--force
restart: on-failure:20
dozzle:
Expand Down
30 changes: 23 additions & 7 deletions deployments/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ services:
- OUT1=--out=tcpin:127.0.0.1:14552
# gcs
- OUT2=--out=tcpin:127.0.0.1:14551
- OUT3=
# qgroundcontrol
- OUT3=--out=tcpin:127.0.0.1:14553
- OUT4=
- OUT5=
- OUT6=
Expand Down Expand Up @@ -87,15 +88,30 @@ services:
--force
restart: on-failure:20
sitl:
image: tritonuas/plane.rascal
image: radarku/ardupilot-sitl
network_mode: "host"
# platform: linux/amd64
tty: true
# ports:
# - 5760:5760
environment:
- "SITL_HOME=38.31542593549111,-76.55062632801757,8,0"
- SITL_SPEEDUP=1
volumes:
- sitl:/app/logs
- VEHICLE=ArduPlane
- MODEL=quadplane
- LAT=38.31542593549111
- LON=-76.55062632801757
- ALT=8
- DIR=180
- SPEEDUP=2
# sitl:
# image: tritonuas/plane.rascal
# network_mode: "host"
# # ports:
# # - 5760:5760
# environment:
# - "SITL_HOME=38.31542593549111,-76.55062632801757,8,0"
# - SITL_SPEEDUP=1
# volumes:
# - sitl:/app/logs
dozzle:
container_name: dozzle
image: amir20/dozzle:latest
Expand All @@ -106,5 +122,5 @@ services:
volumes:
grafana_data:
missions:
sitl:
# sitl:
influxdb_data:
7 changes: 4 additions & 3 deletions houston/src/pages/Control.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,6 @@ function Control({settings, planeCoordinates}:{settings: SettingsConfig, planeCo
FEET_TO_METERS(settings.minAltitudeAGL_feet) + FEET_TO_METERS(settings.groundAltitude_feet),
FEET_TO_METERS(settings.maxAltitudeAGL_feet) + FEET_TO_METERS(settings.groundAltitude_feet),
];
console.log(altitudeMSLThreshold);

const motorBatteryThreshold: Threshold = [
settings.minVoltsPerCell,
Expand Down Expand Up @@ -279,6 +278,8 @@ function Control({settings, planeCoordinates}:{settings: SettingsConfig, planeCo

const [superSecret, setSuperSecret] = useState(false);

const [flightMode, setFlightMode] = useState("???");

useEffect(() => {
const interval = setInterval(() => pullTelemetry(
settings,
Expand All @@ -290,15 +291,15 @@ function Control({settings, planeCoordinates}:{settings: SettingsConfig, planeCo
setMotorBattery,
setPixhawkBattery,
setESCtemperature,
setSuperSecret
setSuperSecret,
setFlightMode
), 1000);

return () => {
clearInterval(interval);
}
}, [settings]);

const flightMode = '';
const flightModeColor = { backgroundColor: 'var(--warning-text)' };

const handleClick = (setter: Dispatch<SetStateAction<Parameter>>) => {
Expand Down
16 changes: 13 additions & 3 deletions houston/src/pages/Drop.tsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
import { ChangeEvent, useState } from "react"
import { BottleDropIndex, BottleSwap } from "../protos/obc.pb";

import video from "../assets/IAMTHEANGRYPUMPKIN.mp4"

/**
* Page that lets the user perform a manual drop
* @returns manual drop page
*/
function Drop() {
const [bottle, setBottle] = useState<BottleDropIndex>(BottleDropIndex.A);
const [playing, setPlaying] = useState<boolean>(false);

const handleChange = (event: ChangeEvent<HTMLInputElement>) => {
const value = event.target.value;
Expand Down Expand Up @@ -37,13 +38,21 @@ function Drop() {
const body = {
index: bottle
} as BottleSwap;

const video = document.getElementById('pumpkin') as HTMLVideoElement;
video.play();
setPlaying(true);

fetch("/api/plane/dodropnow", {
method: "POST",
body: JSON.stringify(body)
})
.then(resp => resp.text())
.then(resp => alert(resp))
.then(resp => {
console.log(resp)
video.play();
setPlaying(true);
})
}

return(
Expand All @@ -53,9 +62,10 @@ function Drop() {
<input type="number" onChange={handleChange} value={bottle} />
<input type="button" value={`Drop Bottle ${bottle}`} onClick={handleDropClick}/>
</form>
<video src={video} id="pumpkin" style={{display: (!playing) ? "none" : ""}}></video>
</>

);
}

export default Drop;
export default Drop;
3 changes: 0 additions & 3 deletions houston/src/pages/Input.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,6 @@ function FormTable(
setMapData(mapData => {
if (data !== undefined) {
const temp = (data.slice(0, i).concat(data.slice(i+1)));
console.log(temp);
return new Map(mapData.set(mapMode, temp));
} else {
return mapData; // should never happen
Expand Down Expand Up @@ -547,8 +546,6 @@ function Input() {
Waypoints: mapDataToGpsCoords(MapMode.Waypoint),
};

console.log(mission);

fetch("/api/mission", {
method: "POST",
headers: {
Expand Down
43 changes: 43 additions & 0 deletions houston/src/utilities/pull_telemetry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import { SettingsConfig } from "./settings";
* @param setPixhawkBatteryVal state setter
* @param setESCtemperatureVal state setter
* @param setSuperSecret state setter
* @param setFlightMode state setter
*/
export function pullTelemetry(
settings: SettingsConfig,
Expand All @@ -27,6 +28,7 @@ export function pullTelemetry(
setPixhawkBatteryVal: Dispatch<SetStateAction<Parameter>>,
setESCtemperatureVal: Dispatch<SetStateAction<Parameter>>,
setSuperSecret: Dispatch<SetStateAction<boolean>>,
setFlightMode: Dispatch<SetStateAction<string>>,
) {
fetch('/api/plane/telemetry?id=74&field=groundspeed,airspeed,heading')
.then(resp => resp.json())
Expand Down Expand Up @@ -67,6 +69,47 @@ export function pullTelemetry(
.catch(_ => {
setESCtemperatureVal(param => param.getErrorValue());
})
fetch('/api/plane/telemetry?id=0')
.then(resp => resp.json())
.then(json => {
// some respectable individual can come in later on and refactor this into
// its own function if they so desire...
// reference: https://mavlink.io/en/messages/common.html#MAV_MODE_FLAG
const SAFETY_ARMED: number = 128;
const MANUAL_INPUT_ENABLED: number = 64;
const HIL_ENABLED: number = 32;
const STABILIZE_ENABLED: number = 16;
const GUIDED_ENABLED: number = 8;
const AUTO_ENABLED: number = 4;
// MAV_MODE_FLAG_TEST_ENABLED = 2
// MAV_MODE_FLAG_CUSTOM_MODE_ENABLED = 1

const base_mode = Number(json["base_mode"])
if ((base_mode & SAFETY_ARMED) != SAFETY_ARMED) {
setFlightMode("Unarmed");
} else {
// we know the system is armed

// i dont really know how all of these options combine together.
// i.e. is stablize / HIL also on while we are in auto?
// so i have ordered them from in an order I feel makes sense, reporting
// the most important bits first (manual, auto) then the other ones
// im less sure about how they will be set exactly
if ((base_mode & MANUAL_INPUT_ENABLED) == MANUAL_INPUT_ENABLED) {
setFlightMode("Manual");
} else if ((base_mode & AUTO_ENABLED) == AUTO_ENABLED) {
setFlightMode("Auto");
} else if ((base_mode & STABILIZE_ENABLED) == STABILIZE_ENABLED) {
setFlightMode("Stablize");
} else if ((base_mode & HIL_ENABLED) == HIL_ENABLED) {
setFlightMode("HIL");
} else if ((base_mode & GUIDED_ENABLED) == GUIDED_ENABLED) {
setFlightMode("Guided"); // i think this will always be on if we are in auto?
} else {
setFlightMode("Armed"); // idk if this ever actually happens
}
}
})
fetch('/api/plane/voltage')
.then(resp => resp.json())
.then(json => {
Expand Down
2 changes: 1 addition & 1 deletion internal/mavlink/eventframe_handlers.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ func (c *Client) writeMsgToInfluxDB(evt *gomavlib.EventFrame, node *gomavlib.Nod

data["type"] = msg.Type
data["autopilot"] = msg.Autopilot
data["base_mode"] = msg.BaseMode
data["base_mode"] = (uint32)(msg.BaseMode)
data["custom_mode"] = msg.CustomMode
data["system_status"] = msg.SystemStatus
data["mavlink_version"] = msg.MavlinkVersion
Expand Down

0 comments on commit ef9525d

Please sign in to comment.