streaming data from pc to hub via bluetooth #2235
-
|
I found this tutorial and after a lot of reading and googling I think I atleast mostly understand what it is doing. The project I am working on is a pen plotter. I have gcode files that a script I wrote is stripping down to X, Y, Z coordinates which I intend to send to the hub which will then perform run_target functions. Depending on the complexity of the art in the files there may be >2000 instructions (telling it to draw a square will have ~8 instructions) in the gcode file (a small portion of which will be "filtered out" by my script for being irrelevant or redundant etc) I guess my uncertainty that remains is mostly to do with the pybricks code in the example, I'm not clear on why they include the following lines also, the example code only reads in 3 bytes. I expect each instruction to be more than that let alone the entire data stream. I can't find any other example code re how to structure the read. I assume I need to loop over it one command at a time until it reaches the end, but I can't quite wrap my head around it. This project is probably a little too advanced for me with this bluetooth stuff, I have only ever written very basic python scripts before and that was mostly 5-6 years ago. I tried to bypass the bluetooth side of things and I wrote a script that wrote out pybricks code, but only the simplest of my art files (with the least instructions) could be run by it, everything else exceeded the filesize limit on the hub. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
From your post, if you have 2000 instructions that are 3 bytes each you should be able to include them in your program. For inspiration, this seems to work with static data in the script. So another way to approach this could be to write a Python script (on computer, not robot) that converts your artwork into a Python file that you can import in your robot script for execution.
Can you share a snippet of what it produced? Instead of generating lengthy lists of commands, you could perhaps include coordinates or coordinate strings.
This so you can check |
Beta Was this translation helpful? Give feedback.
From your post, if you have 2000 instructions that are 3 bytes each you should be able to include them in your program. For inspiration, this seems to work with static data in the script. So another way to approach this could be to write a Python script (on computer, not robot) that converts your artwork into a Python file that you can import in your robot script for execution.
Can you share a snippet of what it p…