FunPythonEC / uPy-rosserial

An implementation of rosserial for uPy.
MIT License
19 stars 4 forks source link

Can be used on Raspberry Pi Pico (RP2040) ? #2

Open barban-dev opened 3 years ago

barban-dev commented 3 years ago

Thank you so much for your lib: I was wondering if it can be used on Raspberry Pi Pico (RP2040) with MicroPython. Has anyone already tried ? Best regards

sasilva1998 commented 3 years ago

To be compatible it needs to have the corresponding modules, including threading, machine, struct and uioat least, otherwise it won't work.

Sadly I don't have a raspberry pico to test it. If you make it compatible, feel comfortable to make a pull request.

kneave commented 6 months ago

I've been working to migrate my robot to use an RP2040 based board, the Pimoroni Yukon. There are two lines that need to be changed for it to work at a basic level, I've not got the whole thing working with other message types than the ColorMsg example yet though.

Lines 17 and 63 in core.py: if sys.platform == "esp32":

need to be changed to: if (sys.platform == "esp32") or (sys.platform == "rp2"):

The RP2040 uses the same _thread library as the ESP32 it seems. Once I've got my robot up and running I'll raise a PR for this, I want to make sure I've found more of the quirks before submitting but thought this may be useful if anyone stumbles across it in the mean time.

kneave commented 6 months ago

I've sadly given up on this, I need something to work quickly and there are a few too many incompatibilities that I've no idea to fix.

So having given up to write my own thing I hit a bunch of problems I realised this has already solved, rather than figuring out how to solve them in my code I've revisited this and got it working. It seems I actually had it working before but just misunderstood how the MD5 hash generation worked.

It sounds obvious but the Msg files need to match exactly, as the msg files included as examples didn't have comments I manually removed the comments from mine as I mistakenly believed comments were ignored. A bad assumption on my part! I haven't got more complex messages working yet, like anything with a header, but slowly working through it all.

kneave commented 6 months ago

Another update in case anyone ends up here and hits a similar problem. It turns out the ROS message generator does ignore comments for md5 generation but the message generator here doesn't, not yet anyhow...

Just make sure you manually remove comments before uploading to your MCU and you should be fine.