Commit 02c050d6 authored by Léo-Paul Géneau's avatar Léo-Paul Géneau 👾

software/js-drone: stop using callbacks

Subscribing to MavLink messages through callbacks can cause queue overflow if
MavLink messages are send too often. Therefore informations are now pulled
instead of updated through message subscription.
parent 3b45a8ff
......@@ -83,7 +83,7 @@ CMAKE_CFLAGS=-I${tinyxml2:location}/include
recipe = slapos.recipe.cmmi
configure-command = true
url = https://lab.nexedi.com/nexedi/mavsdk-wrapper/-/archive/update_set_target_coordinates/mavsdk-wrapper-update_set_target_coordinates.tar.gz
md5sum = 4e5d53ca3c12f6019048a2e3b6351fe2
md5sum = aced1bbc97c1ead062c0ce508b7b9a4d
environment =
CPLUS_INCLUDE_PATH=${autopilot-wrapper-header:location}:${mavsdk:location}/include:${mavsdk:location}/include/mavsdk
LDFLAGS=-L${mavsdk:location}/lib -Wl,-rpath=${mavsdk:location}/lib
......@@ -54,6 +54,7 @@ DLL_PUBLIC float getYaw(void);
DLL_PUBLIC float getSpeed(void);
DLL_PUBLIC float getClimbRate(void);
DLL_PUBLIC int healthAllOk(void);
DLL_PUBLIC int updateLogAndProjection(void);
#ifdef __cplusplus
}
#endif
......
......@@ -10,7 +10,7 @@ parts = qjs-wrapper
recipe = slapos.recipe.cmmi
configure-command = true
url = https://lab.nexedi.com/nexedi/qjs-wrapper/-/archive/update_settarget/qjs-wrapper-update_settarget.tar.gz
md5sum = 7f69d896b3e27962ae26c5c7888f07bc
md5sum = 4e4814806c7e893cb9c176dc9f430b5b
environment =
C_INCLUDE_PATH=include:${open62541:location}/include:${open62541:location}/deps:${open62541:location}/src/pubsub:${quickjs:location}/include:${autopilot-wrapper-header:location}
LDFLAGS=-L${open62541:location}/lib -Wl,-rpath=${open62541:location}/lib -L${mavsdk-wrapper:location}/lib -Wl,-rpath=${mavsdk-wrapper:location}/lib
......@@ -14,4 +14,4 @@
# not need these here).
[autopilot-wrapper-header]
filename = autopilot_wrapper.h
md5sum = facfc36f1ed4672d78f4e345800f02a6
md5sum = 037878cef0233a5769c890651561df4d
......@@ -42,4 +42,4 @@ md5sum = 0d51149929f3cbcaac966b815bb1fb0b
[worker]
_update_hash_filename_ = drone-scripts/worker.js.jinja
md5sum = 6e2a44716c44728e9441145fe0c2a829
md5sum = 29dd9fa7326dee0cce06adb76c7c59c2
/*jslint nomen: true, indent: 2, maxerr: 3, maxlen: 80 */
/*global console, getAltitude, getAltitudeRel, getInitialAltitude, getLatitude,
getLongitude, getYaw, execUserScript, initPubsub, loiter, setAirspeed,
setMessage, setTargetCoordinates, std, triggerParachute, Drone, Worker*/
setMessage, setTargetCoordinates, std, triggerParachute,
updateLogAndProjection Drone, Worker*/
import {
Drone,
triggerParachute,
......@@ -18,7 +19,8 @@ import {
loiter,
setAirspeed,
setMessage,
setTargetCoordinates
setTargetCoordinates,
updateLogAndProjection
} from {{ json_module.dumps(qjs_wrapper) }};
import {
SIGTERM,
......@@ -50,6 +52,7 @@ import { evalScript, fdopen, loadFile, open } from "std";
gwsocket_w_pipe_fd,
handleWebSocketMessage,
last_message_timestamp = 0,
last_log_timestamp = 0,
parent = Worker.parent,
peer_dict = {},
user_me = {
......@@ -247,6 +250,12 @@ import { evalScript, fdopen, loadFile, open } from "std";
if (user_me.hasOwnProperty("onUpdate")) {
user_me.onUpdate(evt.data.timestamp);
}
if (evt.data.timestamp - last_log_timestamp >= 1000) {
updateLogAndProjection();
last_log_timestamp = evt.data.timestamp;
}
parent.postMessage({type: "updated"});
break;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment