Node.js Module

Hey guys,

I've been having a great time fiddling around with some of these boards that I'm putting on a robot intended as a demo for our upcoming Cache Valley Raspberry Jam.

Most of my previous robots on the Pi have relied heavily on Node.js so as to be able to easily integrate with some Angular.js front-end control frameworks I've built. I must confess I have but intermediate skills with Python, whilst I have a vast array of experience with many other languages.

I wonder if anybody here is aware of any Node.js modules that have been written for the PicoBorg, XLoBorg, or the PicoBorg Reverse? My search thus far has yielded nothing.

--Cody E.

piborg's picture

The only Node.js module I have seen for our boards was for LedBorg.

There are some general Raspberry Pi modules for Node.js which might help you.
While these are not specifically for any PiBorg bits, they can be used to operate the boards you are talking about.

i2c.js

https://www.npmjs.org/package/i2c
Can be used to talk to both XLoBorg and PicoBorg Reverse.
The standard Python examples use the Python I2C libraries.
For PicoBorg Reverse the Arduino example using I2C may be simpler to translate than the Python:
https://www.piborg.org/downloads/picoborgrev/PicoBorgRevArduino.zip

pi-gpio.js

https://www.npmjs.org/package/pi-gpio
Can be used to control the PicoBorg.
The GPIO pins you want to control are:
GPIO 4 → Motor 1
GPIO 18 → Motor 2
GPIO 8 → Motor 3
GPIO 7 → Motor 4

Thanks a lot.

I'm quite familiar with both of those modules, as well as various other GPIO modules. I had anticipated translating your Python libraries to create my own module if the work had not previously been done. I suppose I have next week planned out -- something to do while waiting for my TriBorg to arrive. ;)

Thanks for the tip to look at the Arduino code, thats a great idea!

--Cody E.

Well I got a start on it today. I think I made some pretty good progress in translating the Arduino library over to a Node.js module.

Here is the Github repo where I'm working on the PicoBorg Reverse: https://github.com/cerekson/picoborgrev

I definitely always welcome another set of eyes on the code. There isn't a lot of functionality there yet, it's mostly just the module structure. But there is enough to get an idea of how it's going to work and be used.

--Cody E.

Hey guys,

I wonder if someone can explain to my why it is that in all of your code the labeling of your motors seems backwards?

For example, COMMAND_SET_A_REV is used in the function SetMotor2(), while COMMAND_SET_B_REV is used in SetMotor1(). So far as I can tell this convention exists across the board in all of the PiBorg-written code for the PicoBorg Reverse (Python and Arduino.)

While it is a trivial thing in practice, the lack of logic bothers my sensibilities. So before I swap those around in my node.js edition, I'd like to know if there is a reason for it.

Thanks!

--Cody E.

piborg's picture

The truth is that the code was written before the boards were finished.

When we tested the code it turned out that the motor driven by the 'A' commands was in fact labelled motor 2 on the final PCB, not motor 1 like intended.

Rather then changing the code on both devices (the on board PIC uses the same constant names), we decided it was easier just to swap around Motor1 and Motor2 in the library code.

This is why the Motor2 functions tend to be defined before the Motor1 versions in the library as well.

Apologies for any confusion ^_^

Ok, so there is a reason. :) It's good to know, appreciate it! No confusion really, more curiosity than anything. Now I know, I'll follow suit.

Well, except for the "encoder" functions, it's more or less done. I don't have any 3-wire motors on hand to test with, so I'll work on those later.

I'd sure appreciate it if anybody would be willing to give this a test!

https://github.com/cerekson/picoborgrev

I'm turning my attentions to the XLoBorg right now. I just found this existing node module that I'm hoping will provide some shortcuts or at least some completed math for me!

hi,
Here's a npm module for XLoBorg:
https://www.npmjs.com/package/xloborg

piborg's picture

Awesome ^_^

I have re-posted the link on the XLoBorg forum so people looking for XLoBorg bits are more likely to find it:
https://www.piborg.org/node/1776

Subscribe to Comments for "Node.js Module"