Skip to content

Commit f92232e

Browse files
- Created set_stream_rate endpoint
- Added emitter to drone connection slice - Added emitter implementation in emitter.js - Added button to developer tab that calls emitter
1 parent 4b4e2d8 commit f92232e

5 files changed

Lines changed: 63 additions & 20 deletions

File tree

gcs/data/default_settings.json

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -115,99 +115,99 @@
115115
},
116116
"Developer": {
117117
"MAV_DATA_STREAM_ALL": {
118-
"default": 5,
118+
"default": 1,
119119
"type": "number",
120120
"range": [
121121
0,
122-
100000
122+
150
123123
],
124124
"display": "MAV_DATA_STREAM_ALL",
125125
"suffix": "Hz",
126126
"group": "Data stream rates"
127127
},
128128
"MAV_DATA_STREAM_RAW_SENSORS": {
129-
"default": 5,
129+
"default": 1,
130130
"type": "number",
131131
"range": [
132132
0,
133-
100000
133+
150
134134
],
135135
"display": "MAV_DATA_STREAM_RAW_SENSORS",
136136
"suffix": "Hz",
137137
"group": "Data stream rates"
138138
},
139139
"MAV_DATA_STREAM_EXTENDED_STATUS": {
140-
"default": 5,
140+
"default": 1,
141141
"type": "number",
142142
"range": [
143143
0,
144-
100000
144+
150
145145
],
146146
"display": "MAV_DATA_STREAM_EXTENDED_STATUS",
147147
"suffix": "Hz",
148148
"group": "Data stream rates"
149149
},
150150
"MAV_DATA_STREAM_RC_CHANNELS": {
151-
"default": 5,
151+
"default": 1,
152152
"type": "number",
153153
"range": [
154154
0,
155-
100000
155+
150
156156
],
157157
"display": "MAV_DATA_STREAM_RC_CHANNELS",
158158
"suffix": "Hz",
159159
"group": "Data stream rates"
160160
},
161161
"MAV_DATA_STREAM_RAW_CONTROLLER": {
162-
"default": 5,
162+
"default": 1,
163163
"type": "number",
164164
"range": [
165165
0,
166-
100000
166+
150
167167
],
168168
"display": "MAV_DATA_STREAM_RAW_CONTROLLER",
169169
"suffix": "Hz",
170170
"group": "Data stream rates"
171171
},
172172
"MAV_DATA_STREAM_POSITION": {
173-
"default": 5,
173+
"default": 1,
174174
"type": "number",
175175
"range": [
176176
0,
177-
100000
177+
150
178178
],
179179
"display": "MAV_DATA_STREAM_POSITION",
180180
"suffix": "Hz",
181181
"group": "Data stream rates"
182182
},
183183
"MAV_DATA_STREAM_EXTRA1": {
184-
"default": 5,
184+
"default": 4,
185185
"type": "number",
186186
"range": [
187187
0,
188-
100000
188+
150
189189
],
190190
"display": "MAV_DATA_STREAM_EXTRA1",
191191
"suffix": "Hz",
192192
"group": "Data stream rates"
193193
},
194194
"MAV_DATA_STREAM_EXTRA2": {
195-
"default": 5,
195+
"default": 3,
196196
"type": "number",
197197
"range": [
198198
0,
199-
100000
199+
150
200200
],
201201
"display": "MAV_DATA_STREAM_EXTRA2",
202202
"suffix": "Hz",
203203
"group": "Data stream rates"
204204
},
205205
"MAV_DATA_STREAM_EXTRA3": {
206-
"default": 5,
206+
"default": 1,
207207
"type": "number",
208208
"range": [
209209
0,
210-
100000
210+
150
211211
],
212212
"display": "MAV_DATA_STREAM_EXTRA3",
213213
"suffix": "Hz",

gcs/src/components/settingsModal.jsx

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,23 @@ import {
3131
redColor,
3232
showLoadingNotification,
3333
} from "../helpers/notification"
34+
import { useDispatch } from "react-redux"
35+
import { emitSetStreamRates } from "../redux/slices/droneConnectionSlice"
3436

3537
const octokit = new Octokit({})
3638

39+
const STREAM_MAP = {
40+
MAV_DATA_STREAM_ALL: 0,
41+
MAV_DATA_STREAM_RAW_SENSORS: 1,
42+
MAV_DATA_STREAM_EXTENDED_STATUS: 2,
43+
MAV_DATA_STREAM_RC_CHANNELS: 3,
44+
MAV_DATA_STREAM_RAW_CONTROLLER: 4 ,
45+
MAV_DATA_STREAM_POSITION: 6,
46+
MAV_DATA_STREAM_EXTRA1: 10,
47+
MAV_DATA_STREAM_EXTRA2: 11,
48+
MAV_DATA_STREAM_EXTRA3: 12
49+
}
50+
3751
const isValidNumber = (num, range) => {
3852
return (
3953
num &&
@@ -199,7 +213,7 @@ function ReleaseCheckRow() {
199213

200214
function SetRatesRow() {
201215
const { getSetting } = useSettings()
202-
216+
const dispatch = useDispatch()
203217

204218
const onClick = () => {
205219
const MAV_DATA_STREAM_ALL = getSetting("Developer.MAV_DATA_STREAM_ALL")
@@ -212,7 +226,11 @@ function SetRatesRow() {
212226
const MAV_DATA_STREAM_EXTRA2 = getSetting("Developer.MAV_DATA_STREAM_EXTRA2")
213227
const MAV_DATA_STREAM_EXTRA3 = getSetting("Developer.MAV_DATA_STREAM_EXTRA3")
214228

215-
console.log(MAV_DATA_STREAM_ALL)
229+
230+
for (const [name, value] of Object.entries(STREAM_MAP)) {
231+
let rate = getSetting(`Developer.${name}`)
232+
dispatch(emitSetStreamRates({stream: value, rate: rate}))
233+
}
216234
}
217235

218236
return (

gcs/src/redux/middleware/emitters.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ import {
3737
emitSetCurrentFlightMode,
3838
emitSetLoiterRadius,
3939
emitSetState,
40+
emitSetStreamRates,
4041
emitStartForwarding,
4142
emitStopForwarding,
4243
emitTakeoff,
@@ -210,6 +211,14 @@ export function handleEmitters(socket, store, action) {
210211
newFlightMode: action.payload.newFlightMode,
211212
}),
212213
},
214+
{
215+
emitter: emitSetStreamRates,
216+
callback: () =>
217+
socket.socket.emit("set_stream_rate", {
218+
stream: action.payload.stream,
219+
rate: action.payload.rate
220+
})
221+
},
213222

214223
{
215224
emitter: emitStartSimulation,

gcs/src/redux/slices/droneConnectionSlice.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,7 @@ const droneConnectionSlice = createSlice({
188188
emitTakeoff: () => {},
189189
emitLand: () => {},
190190
emitSetCurrentFlightMode: () => {},
191+
emitSetStreamRates: () => {}
191192
},
192193
selectors: {
193194
selectConnecting: (state) => state.connecting,
@@ -263,6 +264,7 @@ export const {
263264
emitTakeoff,
264265
emitLand,
265266
emitSetCurrentFlightMode,
267+
emitSetStreamRates
266268
} = droneConnectionSlice.actions
267269
export const {
268270
selectConnecting,

radio/app/endpoints/states.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,11 @@ class SetStateType(TypedDict):
1313
state: str
1414

1515

16+
class SetStreamRateType(TypedDict):
17+
stream: int
18+
rate: int
19+
20+
1621
GLOBAL_MESSAGE_LISTENERS = ["HEARTBEAT", "STATUSTEXT", "GLOBAL_POSITION_INT", "VFR_HUD"]
1722

1823
STATES_MESSAGE_LISTENERS = {
@@ -113,3 +118,12 @@ def set_state(data: SetStateType) -> None:
113118

114119
for message in STATES_MESSAGE_LISTENERS["config.servo"]:
115120
droneStatus.drone.addMessageListener(message, sendMessage)
121+
122+
123+
@socketio.on("set_stream_rate")
124+
def set_stream_rate(data: SetStreamRateType):
125+
if not droneStatus.drone:
126+
return
127+
128+
print("Setting data stream rate")
129+
droneStatus.drone.sendDataStreamRequestMessage(data["stream"], data["rate"])

0 commit comments

Comments
 (0)