From 168bd90515303aa8fa95acc44b7d3bad16487d9c Mon Sep 17 00:00:00 2001 From: Pierre Tilak Date: Mon, 3 Jul 2023 15:05:27 +0200 Subject: [PATCH 1/2] Fix RPY --- api/parsers/ulgparser.py | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/api/parsers/ulgparser.py b/api/parsers/ulgparser.py index cb5551a..40de1bf 100644 --- a/api/parsers/ulgparser.py +++ b/api/parsers/ulgparser.py @@ -16,21 +16,19 @@ def euler_from_quaternion(self, w, x, y, z): angles = {} #roll(x-axis rotation) - sinr_cosp = 2 * (w * x + y * z); - cosr_cosp = 1 - 2 * (x * x + y * y); - angles['roll'] = math.atan2(sinr_cosp, cosr_cosp); + sinr_cosp = 2 * (w * x + y * z) + cosr_cosp = 1 - 2 * (x * x + y * y) + angles['roll'] = math.atan2(sinr_cosp, cosr_cosp) #pitch (y-axis rotation) - sinp = 2 * (w * y - z * x); - if (abs(sinp) >= 1): - angles['pitch'] = math.copysign(math.pi / 2, sinp); # use 90 degrees if out of range - else: - angles['pitch'] = math.asin(sinp); + sinp = math.sqrt(1+2*(w*y - x*z)) + cosp = math.sqrt(1-2*(w*y - x*z)) + angles['pitch'] = 2*math.atan2(sinp,cosp) - math.pi/2 # yaw (z-axis rotation) - siny_cosp = 2 * (w * z + x * y); - cosy_cosp = 1 - 2 * (y * y + z * z); - angles['yaw'] = math.atan2(siny_cosp, cosy_cosp); + siny_cosp = 2 * (w * z + x * y) + cosy_cosp = 1 - 2 * (y * y + z * z) + angles['yaw'] = math.atan2(siny_cosp, cosy_cosp) return angles From a0131265147f5a8a3d8f8300e432cfcfe3694889 Mon Sep 17 00:00:00 2001 From: Pierre Tilak Date: Tue, 4 Jul 2023 15:43:23 +0200 Subject: [PATCH 2/2] Improve zoom and timestamp units - Timestamp should only use exponential units if the max value is greater than 1e5 - Remove some auto-range signals (still need to remove the one connected to the rubbish bin) --- src/components/Graph.js | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/src/components/Graph.js b/src/components/Graph.js index e97ac5b..c683414 100644 --- a/src/components/Graph.js +++ b/src/components/Graph.js @@ -10,6 +10,7 @@ function Graph({ id, initialKeys, updateKeys, removeGraph }) { const [selectedOptions, setSelectedOptions] = useState([]); const [inputValue, setInputValue] = useState(""); const [data, setData] = useState([]); + const [exponentData, setExponentData] = useState("none"); useEffect(() => { getInitialData(); @@ -21,10 +22,16 @@ function Graph({ id, initialKeys, updateKeys, removeGraph }) { }, []); useEffect(() => { - setTimeout(function () { - plotData.autoRange(); - }, 200); // eslint-disable-next-line + const max_x = Math.max(...data.map(xarray=>{ + return xarray.x[xarray.x.length-1]; + })); + if(max_x>1e5){ + setExponentData("e"); + } + else{ + setExponentData("none"); + } }, [data]); const getInitialData = async () => { @@ -133,9 +140,6 @@ function Graph({ id, initialKeys, updateKeys, removeGraph }) { } select.style.maxHeight = "36px"; - setTimeout(function () { - plotData.autoRange(); - }, 200); }; const stretchSelect = () => { @@ -203,7 +207,7 @@ function Graph({ id, initialKeys, updateKeys, removeGraph }) { spikecolor: "#000", spikemode: "across+marker", spikethickness: 1, - exponentformat: "e", + exponentformat: exponentData, }, yaxis: { exponentformat: "e",