BrickPi documentation

Hi, I couldn’t find any documentation for the BrickPi, do you guys have a file containing all of the commands I could use? I am currently using the BrickPi for a project and I am trying to create a guidance system for a couple of robots utilizing an overhead camera to track them. Just in case you have any ideas or helpful tips please give me a shout as I am a bit of a programming novice and I could use all the help I could get.

Cheers, Duncan

Hey Duncan! A few quick pointers on programming the BrickPi:

We have an overview of how to setup your BrickPi here: http://www.dexterindustries.com/brickpi-tutorials-documentation/
There are a few quick tricks to programming here: http://www.dexterindustries.com/BrickPi/program-it/

I would recommend that you use Python, it’s the most widely documented language for the BrickPi. We have our repository of python programming examples here: https://github.com/DexterInd/BrickPi_Python/tree/master/Sensor_Examples
This set of examples should show you how to use any one of the sensors yo’re interested in.

As for an overhead camera; are you trying to control the robot remotely? How are you processing the overhead camera information?

Best, John

Hi John,

Thanks for the help, however I was looking for something more like a list of the python commands for the brick pi and descriptions of what they do. Having said that I did find the motor test file last week and it was pretty helpful although for some reason the motors would only respond to the commands properly if I entered ‘BrickPiUpdateValues()’ twice.

I am using open CV for Python to locate my robots and I am hopefully going to be using coloured circles on top of the robots to find there exact location and to distinguish them. The computer attached to the overhead camera is then hopefully going to be able to tell the robot to move small objects around the room without any human interactions.

Cheers, Duncan

1 Like

Hey Duncan,
Do you have an example? We don’t have such a thing yet, but we could develop a list as you describe.
John

I have an example. I am currently writing a Java API for the BrickPi. Yes I know there is already BrickPi for Java but that version does not work for me or my studends. What I would like to know is when people are connecting to the BrickPi using the serial bus, if there is a BrickPi module at the end. Are there special serial commands to access the current firmware version of other handy things to gain access to. See it as a ping idea.

Hi again! We don’t have an outline of this yet. However, you do need to initialize the BrickPi. If you look at the BrickPi.py file and an example file (https://github.com/DexterInd/BrickPi_Python/tree/master/Sensor_Examples), you can see the calls that are made to setup the BrickPi, and then the calls that are made to move the sensors.

Yes but when you look at the code… I am not able to decode it easy. There is no documentation what the BrickPI expects and why (there are a lot of magic numbers for instance). The Java BrickPi version in Github does not work, so I try to fix that. Any idea where to find more information expect that the code is the documentation?

Hey mstorm,

Are you looking at this repository: https://github.com/DexterInd/BrickPiJava

Or another Java implementation?

Hey John,
That is the one, I understand now why it was not working and using the python implemenation in combination with the c-version I have reverse engineer it. It is running now.

This is great to hear! What did you have to fix to get it to run?

It is not 100% fixed yet. When you pull it from the repo, there is a maven build file that takes the Pi4J 0.0.5 version from central. This API is the community edition but not the hacked version that I found in the repo. There is the difference. With the hacked version of Pi4J it runs since it can handle a heigher baud rate (50000). The community edition does not allow this baud rate. The solution is to find what has been hacked in that version and try to implement that hack in the snapshot version of 1.0.1 of Pi4J. When the hack is contributed and accepted by pi4j than it will work out of the box when the Pi4J dependency is upgraded. The other problem is the serial interface, there are some threading problems between the current implementation in the repo with the serial interface, still debugging.

The other problem is that the Java version is far behind of the python version. A lot of sensors are not supported yet ;-). I have rewritten the BrickPi for Java so it is more object oriented. The API is 100% decoupled from the BrickPI current hardware platform so it allows developers to add future hardware platforms. I have created a flexible service provider for it. The API and SPI is not compatible with the current version in the repo. I saw that nobody is active in the last 2 years on the current Java Repo, is Java not active here?

The steps I will take is:

  1. to reverse engineer the PI4J hack and hopefully the are accepting the patch.
  2. Upgrade the Repo here when the Pi4J has release with the patch so that version works.

Sensor port 5 is also not supported, and I need this for my robot. I hope to implement this also in the next month.

Hi mtstorm,

I’m also using Java with BrickPi and Pi 2 & 3 for a hobby project. I haven’t used the netbeans projects, since I prefer eclipse. So far I haven’t tried to use the motors or sensors from Java, since my focus is on Computer vision for robots. My fork of the BrickPiJava is here https://github.com/woolfel/BrickPiJava

Hey guys, have either of you used the ev3dev Java for the BrickPi? I just linked it on our brickpi page, but i haven’t tried it (https://github.com/ev3dev-lang-java/ev3dev-lang-java)

Also, Woolfel, we would love a pull request if you have one!

Hi John,

Let me clean the stuff up first before I make a pull request. It’s a bit messy at the moment ;p

I was waiting until I had time to clean things up and make it more presentable. I should have some time tonight to do that and will try to make a pull request.

Hi all,
Both repo’s are bit out of date. They all use the hacked version 0.0.5 but this is not 100% compatible with the brickpi. I try to figure out what is changed in that hacked version. If somebody has a clue, please post, that will be a huge timesaver. I would like to use the led’s on the board to have a visual feedback if the board is activated or not. GPIO_27 is not in 0.0.5, wrong PI…

@Woolfel, sensors and motors are not great supported for Java as with the Py version. I wish to change that :slight_smile:

There I think it’s a risk since upgrading is not yet possible until this hack is fixed.

Yet a stupid question but does anybody know how to contact ergouser or can somebody ask ergouser about this hack?

@mtstorm - I plan to start working with the motors from Java in a week or two, so I can help debug and fix it.

@mtstorm - I was comparing the source in BrickPiJava versus what’s up on the official pi4j github. The one that’s in BrickPiJava/lib/pi4j-core-0.0.5.jar has this for loading native libs

static {
    // Load the platform library
    NativeLibraryLoader.load("pi4j", "libpi4j.so");
}

Where as the current pi4j has this

static {
    // Load the platform library
    NativeLibraryLoader.load("libpi4j.so");
}

At first I was having issues with the serial port not initializing, so I unjarred pi4j-core-0.0.5 and copied libpi4j.so to /usr/lib/jni/ folder. that got past the serial port error, but the motor doesn’t run on Raspberry Pi 3 for me. Tomorrow I will try the Pi 2 B and Pi 1 B+

Sorry for the delay. Thanks for you input. I will try to get the newer version of Pi4J and look in to the native library. I use model B+. Have you any luck already. I will keep you posted.