Using an IMU to control an airplane image #938
Replies: 12 comments
-
Posted at 2017-06-15 by @gfwilliams Nice! Are you thinking you might eventually use it to control a real model aeroplane? |
Beta Was this translation helpful? Give feedback.
-
Posted at 2017-06-15 by ClearMemory041063 Using http Post is a bit slow. I'm working on using web sockets instead. I hope web socket data rates are faster. Model airplane control would be nice. I've seen some examples on the web. But that's another hobby to support. I would like to try recording the heading and linear acceleration and then using integrations to get velocity and position, and plotting the course taken and see how well it would match the actual course. (Walk around the block for instance). This sort of thing could be useful to map a cave or tunnel.Attachments: |
Beta Was this translation helpful? Give feedback.
-
Posted at 2017-06-15 by ClearMemory041063 The HTML POST problemIf you try to post and then process the reply too fast, the header information winds up in the message from the client to the server. Are Websockets faster?To find out I went to the Espruino site to try a Websocket example
This is the HTML code sent to the client. Note the line page += 'ws.onmessage = function (event) { console.log("MSG:"+event.data); };'; Websockets seem to be fasterReworked the HTML file into the attached file flight5a.html to use Websockets. It is incorporated into the server code as a string using the file converter site at BugsThe airplane flies and flies but eventually stops communicating.
The JSON.parse bug has been fixed.The file trycatch.js shows how this was done in the client code. The messages sometime come in garbled and the JSONparse throws an error. The code catches the error and discards the message.
The other bug I have no clue. Helpful suggestions are welcome.Is this project the start of a 3D mouse? Attachments: |
Beta Was this translation helpful? Give feedback.
-
Posted at 2017-06-16 by @gfwilliams
If you just open the Web browser's devtools you should still see a console with those messages?
The websocket disconnect one about server masking? And it doesn't happen immediately? When the parse error occurs, please could you dump |
Beta Was this translation helpful? Give feedback.
-
Posted at 2017-06-16 by ClearMemory041063 I reworked the communications link last night. Removed the timer approach and went to the approach that the client sends a character, the server replies with the JSON string, on receipt by the client, but before the JSON parse, the client sends another character, then does the JSON parse within a try/catch framework. The results run much faster and much longer without errors The port used in the browser is 8000 not 8080. (you can edit it if you like). So the IP address line of the browser reads: Attachments: |
Beta Was this translation helpful? Give feedback.
-
Posted at 2017-06-16 by ClearMemory041063 SuccessCombined two programs with some editing and the resulting program connects to the BNO055 IMU, then is connects to the local WiFi to serve the display page. As you move the BNO055 chip around the airplane on the screen seems to follow. (Just got it working so there are likely some gotchas, but I feel pretty good for now). Attachments: |
Beta Was this translation helpful? Give feedback.
-
Posted at 2017-06-16 by @gfwilliams Great! I guess it's possible that somewhere along the line a buffer got full and dropped some characters? |
Beta Was this translation helpful? Give feedback.
-
Posted at 2017-06-20 by ClearMemory041063 Gotcha 1 Glitches in the data from the BNO055.Examine the pitch values which should be around 180 degrees but on occasion read near 0.
Try using a median filter on the Yaw, Roll and Pitch data.See attached file medianFilter.js and 3Dmouse8b.js
And the output:
3DMouse8c.js reconnects the web interface and uses the median filterThis version eliminates the image radically changing positions on the screen. Other gotchas relating to the position of the screen image and the position of the chip still remain to be resolved.testws7a.js allows one to type yaw=23; roll=45; or pitch=-179 (supply your value) into the left pane of the WebIde and have the position of the airplane change on the web page. Attachments: |
Beta Was this translation helpful? Give feedback.
-
Posted at 2017-06-21 by @gfwilliams Very strange about the pitch - I'd wondered whether pitch only varies between 0 and 180 degrees (so rolls over), but it seems you have around - 180 in there too! Maybe you could try comparing the pitch you have with the raw values? It looks like you're using twos complement, but some devices just use 15 bits + sign for signed values? |
Beta Was this translation helpful? Give feedback.
-
Posted at 2017-06-21 by ClearMemory041063 From the BNO055 datasheet The output data format is based on the following convention regarding the rotation angles Table 3-13: Rotation angle conventions
|
Beta Was this translation helpful? Give feedback.
-
Posted at 2017-06-23 by ClearMemory041063 Found the fix to gotcha 1Recall that glitch1 produces Pitch values that fluctuate for a steady position of the IMU chip.
By changing the way the data are read from the BNO055 the data value flutter issue has been resolved.
The module will be further updated to extend this discovery to other block reads of data. Attachments: |
Beta Was this translation helpful? Give feedback.
-
Posted at 2017-06-24 by ClearMemory041063 3DMouse8adrainB.jsThis version uses the update BNO055.js module from the WebIDE sandbox.
Some sample left pane output:
The BNO055.js module and savCalBNO055.js can be found at: Attachments: |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Posted at 2017-06-15 by ClearMemory041063
Introduction
Having developed an Espruino module for the BNO055 IMU chip, this project will attempt to use the Euler angle of Yaw, Pitch and Roll that the chip provides to position a video rendering of an airplane on the computer screen. It is intended that as the orientation of the BNO055 chip is changed that the airplane image on the screen will follow.
http://forum.espruino.com/conversations/305928/
Implementation
The progress so far serves a webpage that display the airplane and HTMP post commands obtain updated Euler angles that the PICO increments. Integration with the BNO055, will follow in a few days.
A PICO with an ESP8266 attached by a shim is the platform. The BNO055 IMU chip is also connected to the PICO.
The attached files
Flight4.html contains the web page that will display the airplane, but it is set to simulate the changes of the Euler angles. If opened in a browser, it demonstrates the airplane in motion.
Flight4a.html is similar to flight4.html but is set to use HTML Post messages to the server to obtain the Euler angles.
Jnet.js is the Web credentials file that you will need to edit and place in the WebIDE projects module subdirectory. Edit the ssid and pw for your local wifi network.
ServePage3a.js contains the server code. It connects to the WiFi using jnet.js credentials.
It displays the IP address that you will use to access via a browser.
Once a browser connects you will see:
Screenshot1.jpg shows a screenshot of the webpage.
Future work
Attachments:
Beta Was this translation helpful? Give feedback.
All reactions