NodeJS Libraries


#1

So, my first experiences with BrickPi have been a bit less than ideal. The NodeJS library doesn’t work, most of them are incomplete in terms of sensor support, and all of them are inconsistently implelmented. I’ve looked at the source code for many of the language bindings, and it just seems like software to support this product is an afterthought.

So far, the NXT RGB sensor doesn’t seem to work in either the NodeJS or Python implementations.

I would be happy to clean up the Nodejs language implementation, but there is apparently no documentation of the serial protocol to communicate b/n the Pi and the BrickPi, nor documentation of the sensor-specific data structures.

Anyone?


#3

Hey @rick.bullotta , thanks for your patience. I’m assuming you’re referring to this library here.. This was graciously donated to us by a community member; none of us really have any expertise in NodeJS, but we were grateful for the contribution.

I apologize if our documentation of the software/firmware communication is incomplete. It’s been on our development list for some time and we’ve been working behind the scenes the last few months to improve it. Not an excuse, as we would really like to continue to improve our software.

I can offer two things immediately. We have one other “Dexpert” who loves NodeJS and I can ask him to take a look and see if he can help update things.

It sounds like you’re interested and capable though of working on the NodeJS library and have some background with it. If that’s the case, on Monday can I put you in touch with our engineer Matt? He might not be able to provide precise documentation, but he might be able to help walk you through the soft spots, and answer any questions. It also might be helpful for him to have this conversation, and figure out what looks soft from the outside.

Again, I apologize for the slow response here, and we’re grateful for your willingness to help us cleanup the code.

Thanks! John


#4

Thanks John (and Matt!) - I’m happy to help out. I appreciate the offer! Message me and let me know what I can do to assist. Cheers, Rick


#5

Hi, John/Matt. I spent the weekend comparing the various implementations and I was able to fix some of the bugs in the Nodejs libraries. I also added some new capabilities to them in the process, and updated some of the dependencies/packages that they utilize to more recent versions. I still can’t get the NXT color sensor working, but it doesn’t seem to work in any of the implementations (is it supported for BrickPi?).

In any case, I have the necessary code changes ready to go if you want to take a look.

Cheers,

Rick


#6

Hey Rick, I saw the PR’s go through to the other repo, and I saw that they were accepted. Thank you so much for taking the time to update them for everyone else, we really appreciate the effort, it’s amazing!


#7

Happy to help. Probably worth having another set of eyes take a look to make sure I didn’t introduce any new issues! Also, I wasn’t able to fix the issue with the NXT RGB color sensor - I really don’t know how it works, and it doesn’t appear to be as simple as I2C communications.


#8

I’d also like to talk with you or Matt about the motor encoder readings. I was under the impression that the Lego encoders had a resolution of 360 but I’m getting some odd numbers. Also, the PID function seems to be stopping the motor a bit short.


#9

Great Rick, I know Matt is following this topic right now, I’ll also followup by e-mail. The RGB color sensor is indeed it’s own protocol between the sensor and the BrickPi, but it should be accessible through the serial lines to the Pi.


#10

OK. Happy to help diagnose what’s up. Also want to do a deeper dive into the motor API and clean that up/simplify it a bit. Something seems wrong with the encoder values I’m seeing.


#11

Hi Rick, there have been some recent updates to the BrickPi Python drivers. If you haven’t already done so recently, I recommend that you run the “DI Software Update” on the desktop of Raspbian for Robots to be sure that your drivers are up to date.

The Lego motors do indeed have a resolution of 1 degree (360 per rotation). Prior to the recent drivers update, the values read were relatively unreliable.

The communication between the Raspberry Pi and BrickPi is documented in the firmware source files. The communication header is documented here and the communication data is documented here.


#12

I’m not running your Raspbian distro – running Wheezy tweaked to be compatible with BrickPi.

I was comparing the Node code to what I thought was the latest Python version. Will double check.

Any thoughts on the RGB sensor?


#13

FYI, with the latest Python code, the motors are still misbehaving. How can I update any other drivers given that I’m not using the Raspian for Robots distro?


#14

how is it going here guys? I just bought the BrickPi3 as it seemed it has nodeJS support only to find that the libraries don’t work. NOW I saw this topic which says it’s not really supported, but it was 2 years ago :frowning:

Is there any way to make this work?


Latest version of Raspbian for Robots?
#15

Read the BrickPi3 page It says the languages it supports and NodeJs is not supported. Yes it did say that for the BrickPi+ but not for the BrickPi3. Yes there is a way to make it work, maybe. You need to research if you can use the spice communication protocol with nodejs. Spice is the way the rpi and BrickPi3 communicate, where the BrickPi+ used I2C. So if you can find a way to use spice all you have to do is see what spice commands are sent from the BrickPi3.py module and implement them into nodejs. If that doesn’t work you could look into communicating to python with nodejs. Basically nodejs would run a python command which would then communicate with the BrickPi3. It’s possible but not out of the box.

May I suggest just using python? Its pretty much the standard for the RPi so you’ll get a lot more support. NodeJs just isn’t that popular on the pi.

EDIT
I made a mistake, t BrickPi+ uses serial to communicate. Sorry if I caused any misunderstandings.


#16

Thanks for the clarification. The “BrickPi3 Page” you linked to is a google search.
nodeJS was mentioned as a supported language for BrickPi - BrickPi3 did not had new pages when I ordered so… bad luck for me but I did read everything on here.
I’ll try to make it work myself now.
I can’t find anything called Spice. In your linked Python script you use “SPI” - which makes more sense.So is SPI communication the thing to rebuild in node or am I missing the “Spice” thing? Do you mind linking me to it?


#17

nevermind, it is SPI - made the basics work already. I’m on it :+1:


#18

Oh sorry. Got the two confused. Your right, it uses SPI. If you want detailed info on how the BrickPi3 communicates read the official page:
https://www.dexterindustries.com/BrickPi/brickpi3-technical-design-details/brickpi3-communication-protocol/


#19