MrYsLab / FirmataExpress

An enhanced version of StandardFirmata to be used with pymata-express
GNU Affero General Public License v3.0
37 stars 15 forks source link

Robotics Masters Robo HAT MM1 board to boards.h #4

Closed mockbot closed 4 years ago

mockbot commented 4 years ago

Firmata has added new board (added by rallarug from Robotics Masters) https://github.com/firmata/arduino/commit/aa0675ccf919350060c52cacb7af10147846819f

Is this patch possible/neccessary for pymata4 and pymata express ?

MrYsLab commented 4 years ago

I am working on FirmataExpress as we speak to add DHT22 support. I will add this change in the next release as well. I hope to have this available in a few days. Thanks.

MrYsLab commented 4 years ago

Looking at the little documentation that is available for this board, I do not plan on providing direct support within pymata4. I don't know if Firmata can be loaded on this board or not, but currently, it is using Adafurit seesaw and CircuitPython. I tried using CircuitPython for my CircuitPlayground Express extension, and even though I would rather program in python over other languages, the performance was horrible, so I had to create a version of Firmata to work with that board. In addition, the Adafruit libraries, are not always written optimally. For one of my projects, I had to do some coding around what I considered bugs. Also, the IMU they are using is an i2c device, which would mean that support would have to be implemented using the Firmata i2c primitives - usually not a very pleasant job.

If Robotics Masters sent me a board free of charge, I would consider supporting it, perhaps with python_banyan and OneGPIO, but I could not guarantee supporting it or not.

Sorry about the long story, but this board does not seem to be a good canditate for Firmata support. Let me know your thoughts. Thanks.

mockbot commented 4 years ago

we've already tested firmata in arduino mode and it works fine with servos....

Am Mo., 11. Mai 2020 um 16:04 Uhr schrieb Alan Yorinks < notifications@github.com>:

Looking at the little documentation that is available for this board, I do not plan on providing direct support within pymata4. I don't know if Firmata can be loaded on this board or not, but currently, it is using Adafurit seesaw and CircuitPython. I tried using CircuitPython for my CircuitPlayground Express extension, and even though I would rather program in python over other languages, the performance was horrible, so I had to create a version of Firmata to work with that board. In addition, the Adafruit libraries, are not always written optimally. For one of my projects https://mryslab.github.io/bots-in-pieces/banyan-components/cricket-hardware-gateway/2019/08/15/banyan-bot-blue-part7.html, I had to do some coding around what I considered bugs. Also, the IMU they are using is an i2c device, which would mean that support would have to be implemented using the Firmata i2c primitives - usually not a very pleasant job.

If Robotics Masters sent me a board free of charge, I would consider supporting it, perhaps with python_banyan and OneGPIO, but I could not guarantee supporting it or not.

Sorry about the long story, but this board does not seem to be a good canditate for Firmata support. Let me know your thoughts. Thanks.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/MrYsLab/FirmataExpress/issues/4#issuecomment-626721789, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAIRDAGJJ6MVYAY5BV3L6ITRRAAXDANCNFSM4M546R3A .

wallarug commented 4 years ago

Hi @MrYsLab ,

I don't understand all your commentary about CircuitPython. It is not necessary with the Robo HAT MM1 as we ported it across to Arduino successfully.

We already put the board into Firmata's Arduino Branch. I was only introduced to Firmata last week by @mockbot who specifically requested we add support (which we have done). I'm new to this particular ecosystem.

What do you need from me on either the software or hardware docs front to make this happen?

MrYsLab commented 4 years ago

Hi @wallarug Thanks for your input. If you are somewhat unfamiliar with Firmata, let me give a brief explanation. If you already understand Firmata, I apologize, but I just want to make sure that we both have the same view of its strengths and limitations.

Firmata is just a software abstraction of Arduino functionality that allows a client that resides on another computer to communicate with and control the Arduino. This is done through a set of what I call Firmata primitives, which are messages that allow the client program to do things like set a pin mode (analog input, digital output, etc.), and set a pin value. When it comes to i2c, Firmata offers a set of primitives to read and write the i2c device registers but has no direct knowledge of the device it is communicating with. The actual programming is done on the client-side. To illustrate what I mean, here is the programming in Python using Firmata to control and monitor an ADXL345 accelerometer. This is fairly simple. To view the code for a more complex accelerometer, the MMA8452Q, you can view its Firmata programming.

Analog, digital, PWM functionality is built into Firmata so those are no problem. I would need to know if MM1 uses anything in addition to i2c, and if so which devices its is using. Also, a copy of the board would be required. What I would provide is a Python library to interface to the MM1. It would probably be better for the user to have a higher-level view of the MM1 than Firmata presents, but the interface would use Firmata to communicate with the MM1. I would also like to provide a Scratch3 extension for the board as well.

Let me know your thoughts and if you wish to proceed.

Thanks again.

wallarug commented 4 years ago

Hey @MrYsLab,

Thank you for your detailed explanation. It was very helpful.

I think this is something we will go through with but I still do not understand why this is becoming such a complex task.

Question: Can we just update the Boards.h file and have a working FirmataExpress running on the board?

Analog, digital, PWM functionality is built into Firmata so those are no problem. I would need to know if MM1 uses anything in addition to i2c, and if so which devices its is using. Also, a copy of the board would be required. What I would provide is a Python library to interface to the MM1. It would probably be better for the user to have a higher-level view of the MM1 than Firmata presents, but the interface would use Firmata to communicate with the MM1. I would also like to provide a Scratch3 extension for the board as well.

In terms of the functionality I would expect is exactly what you have outlined. I would not want to put any extra work on you for making the board do fancy things like interface with the IMU or other sensors. I completely get that they need to be separated and called a higher-level.

Functionality

The board is capable of many other protocols as well, however, the core ones I would like to maybe see Firmata perform are these. I don't know if it can already perform these or if they would need to be added separated (particularly the NeoPixels).

I'm interested in the Scratch3 support. We already have support with MakeCode (by Microsoft) but having Scratch3 would be an interesting addition.

MrYsLab commented 4 years ago

First, I would be willing to provide a Scratch 3 interface for the board. In order to do this, I would need to have access to a board. If this is something you would like me to explore, we can pursue this in email. You can find my email address here, in the links below my avatar. I would most likely be using the Firmata interface on the MM1 for this purpose.

Now let's discuss the rationale for a Firmata API for the MM1. One might prefer to use Firmata because of familiarity with Firmata, and/or the application requires higher performance than can be afforded by using a compiled C language sketch over other embedded language solutions. That being said, from a sales point of view for the MM1, I am not sure if having Firmata available without providing easy access to the full functionality of the board will amount to many additional sales. My experience has been that most potential Firmata users who wish to interface to an i2c device are disappointed to learn how complex programming that i2c device using Firmata often turns out to be.

Where Firmata, and my developing the i2c code for Firmata comes in, is that it should potentially result in the sale of more MM1s. If I provide a Python API that abstracts the MM1 functionality and does not involve a user in having to understand or learn Firmata, then when selecting a board for a project, a typical Python user would more likely consider selecting the MM1 because the hard work is done, as opposed as to understanding the intricacies of implementing i2c code using pymata4 to control the i2c device. The MM1 is programmed once with Firmata and never changes (or at least does not have to be) and the user codes and executes their application remotely on their PC or RPi, having all the debugging capabilities at their fingertips. IMHO, the best of all possible worlds.

wallarug commented 4 years ago

@MrYsLab , That sounds really cool. Having a static firmware would be a good replacement for SeeSaw (which currently doesn't work).

I was not looking at this from a sales point of view but all your points are completely valid. It would be great to incorporate all the features you mentioned into pymata4 so that new users do not have to know the low level stuff. And I hope that would lead to more sales as a result.

I am mainly trying to make @mockbot happy at this point 😄 . He is the one driving what features to incorporate and include for Firmata+Robo HAT. He bought a Robo HAT and is working on ROS development with the Robo HAT MM1.

Happy to send you a board to play with all these features you mentioned and support you anyway I can on the software front. I have been writing low-level i2c drivers for the IMU on the board for 1 year now.

I'll drop you an email.

Thank you for all your support thus far on this and clarifying all points.

MrYsLab commented 4 years ago

This was integrated with version 1.0.2 of FirmataExpress available through the Manage Libraries feature of the Arduino IDE.

wallarug commented 4 years ago

@mockbot if you have some time on the weekend, can you give it a run and let us know what does and doesn't work?

MrYsLab commented 4 years ago

I was not sure how to install the MM1 as a board-type in the Arduino IDE, so for board-type, I picked the Arduino M0 just to see if FirmataExpress would compile. The current version of FirmataExpress assumes one is using an AVR board and as a result does not compile. I removed those dependencies and it compiles without an issue for the M0. There are only 2 lines that needed to be commented out.

Probably the simplest thing to do to avoid having to have the user deal with managing a bunch of ifdefs in the code is to simply have a custom version of FirmataExpress specifically tuned to the MM1.

I cannot actually run anything until I have a board in hand. FirmataExpress has been very stable, so unless there is some hardware compatibility issue lurking, I am not anticipating any major issues on the Arduino side of things. The pymata4 client should be able to run the digital in/out/PWM and analog-in commands pretty much out of the box.

wallarug commented 4 years ago

Hey @MrYsLab ,

You need to install the board file first. Guide on how to do this is here: https://github.com/robotics-masters/mm1-hat-arduino

Otherwise it will break. The M0 will not compile it correctly because the Robo HAT is using a M4 processor.

What I put into FirmataExpress is the same as FirmataStandard.

Board is on it's way - expected time of 14 to 21 days. @mockbot already has a board.

MrYsLab commented 4 years ago

@mockbot If you are testing with FirmataExpress, here is a link to a copy of a modified FirmataExpress.ino that will compile for the MM1.

sunilsomarajan commented 3 years ago

when I compile firmataexpress after adding the Robohat mm1 board definition, I get these errors

Arduino: 1.8.13 (Windows Store 1.8.42.0) (Windows 10), Board: "Robo HAT MM1 (SAMD51), Enabled, 120 MHz (standard), Small (-Os) (standard), Arduino, Off"

sketch\FirmataExpress.ino.cpp.o: In function `analogWriteCallback(unsigned char, int)':

D:\Documents\Arduino\libraries\FirmataExpress\examples\FirmataExpress/FirmataExpress.ino:481: undefined reference to `Servo::write(int)'

sketch\FirmataExpress.ino.cpp.o: In function `attachServo(unsigned char, int, int)':

D:\Documents\Arduino\libraries\FirmataExpress\examples\FirmataExpress/FirmataExpress.ino:214: undefined reference to `Servo::attach(int, int, int)'

D:\Documents\Arduino\libraries\FirmataExpress\examples\FirmataExpress/FirmataExpress.ino:216: undefined reference to `Servo::attach(int)'

sketch\FirmataExpress.ino.cpp.o: In function `detachServo(unsigned char)':

D:\Documents\Arduino\libraries\FirmataExpress\examples\FirmataExpress/FirmataExpress.ino:225: undefined reference to `Servo::detach()'

sketch\FirmataExpress.ino.cpp.o: In function `setPinModeCallback(unsigned char, int)':

D:\Documents\Arduino\libraries\FirmataExpress\examples\FirmataExpress/FirmataExpress.ino:354: undefined reference to `Servo::attached()'

D:\Documents\Arduino\libraries\FirmataExpress\examples\FirmataExpress/FirmataExpress.ino:419: undefined reference to `Servo::attached()'

sketch\FirmataExpress.ino.cpp.o: In function `__static_initialization_and_destruction_0':

D:\Documents\Arduino\libraries\FirmataExpress\examples\FirmataExpress/FirmataExpress.ino:128: undefined reference to `Servo::Servo()'

sketch\FirmataExpress.ino.cpp.o: In function `sysexCallback(unsigned char, unsigned char, unsigned char*)':

D:\Documents\Arduino\libraries\FirmataExpress\examples\FirmataExpress/FirmataExpress.ino:712: undefined reference to `Servo::attached()'

collect2.exe: error: ld returned 1 exit status

exit status 1

Error compiling for board Robo HAT MM1 (SAMD51).

This report would have more information with "Show verbose output during compilation" option enabled in File -> Preferences.

MrYsLab commented 3 years ago

@sunilsomarajan Did you install the samd boards into the Arduino IDE and select the Arduino M0 board?

To install,, go to Tools > "Board:" > "Boards Manager". Search for "SAMD". Look for "Arduino SAMD Boards (32-bits ARM Cortex M0+)" and click the "Install" button. Then select the Arduino M0 before compiling.

Please let me know if you are still having problems.