BrickPi with Tetrix Motor/Servo Controllers working!

FYI, with huge help from Matt Richardson, I was able to run my BrickPi (powered by 6 D batteries) with the WIPI and a webcam AND connected to a Tetrix DC and Servo motor controller and get both DC and servo motors to work under the command of a test C program Matt wrote. Yippee! This means the BrickPi can be used wireless on a Tetrix robot system (like those used in the FIRST Tech Challenge) with a webcam running to perform camera-based functions (like tracking an object and moving the motors in response to that tracking).

Very exciting (for me at least)!

Pictures or it didn’t happen! :slight_smile:

Hey Bill,

Just kidding. But it would be really, really awesome if there’s a way we could add the Tetrix controllers to the Github site for others to try using. And it would be even more awesome if we could have some pictures to share, or a blog post to link to. Is there any way you could share either?

Thanks Bill!

Here’s a picture.

Bottom right:
6D batteries wired up to provide 9V

Bottom center:
RaspberryPi with BrickPi on top (with yellow star sticky note on top)
note the blueLED of the WIPI on the left lit up, and under that is
a Logitech Webcam plugged in which goes to…

Left:
Tetrix Robot with 3 controllers (2 DC Motor and 1 Servo)
the webcam is attached to the robot and aimed down at the BrickPi.
the robot is perched up on a box so that the drive motors don’t drive it
off the table when the code is running. The two drive motors and
the servo (on the arm at the top of the robot out of frame: sorry)
are both driven from the test code and work as expected.

Upper Right:
PC running VNC viewer to the RPi wirelessly through the BrickPi
On the PC you can see the luvcview window showing the webcam images
and two terminals: one to run the luvcview and the other to run
the Tetrix test code (which is still showing debug error messages but
is working fine on the robot)

As you requested, here’s a blog post
http://cheer4ftc.blogspot.com/2013/10/brickpi-with-tetrix-controllers.html

At the bottom of the blogpost is a link with all of the test code zipped up. Feel free to add it to the github repository directly, after you change it, or whatever.

Someone just pointed out that pictures were limited in size. Yours don’t seem to have showed up, but I just allowed an increase in the file size. FYI. Thanks!

It would be really awesome if this could be used in FTC. I believe HiTechnic has a monopoly on this though. Wonder how we could break that monopoly?

Let’s try that picture one more time. If this doesn’t work, you can see a copy at the blogpost mentioned above.

For FTC, you’d need to replace the LegoNXT brick and also interface with their Field Control System software. Then you’d need to make sure that you were reliable enough in a rough-and-tumble 4 robot environment. And this is while the FTC folks are probably busy testing the EV3 for next year. I personally don’t see it happening. But it does make for a great prototyping platform for the off-season for all of the >1000 FTC teams.

Hey Will, just a heads up we altered your C code a bit and pushed it out to Github. It’s standard now with our library! Check to make sure how you like we did the credits; happy to change it around if you like.

We’ll be working it into Python soon as well!

Your credit changes are fine with me.

Did you test your new code?

I thought some preprocessors needed the #ifdefs at the start of a line: I see that some of the #ifdef DEBUGs have been indented. It’s fine with me if that works as long as you’ve tested it.

Also, the both of your test versions (DcMotorTest and ServoMotorTest) have this line:
initTetrixControllerSettings(TETRIX_SENSOR_PORT, 2, 0x02);
This sets up 2 controllers, sets the first one to a DC Motor Controller (LSB=0 in final param) and the second one to a Servo Controller (next LSB=1 in final param). This made sense in my test code where there were multiple controllers and both types of motors were exercised, but it might make less sense in your test code where you’ve split the DC and Servo tests into separate code.

I might humbly suggest that you put the following comment above that line:
// see TetrixControllers.h for usage of initTetrixControllerSettings

You might also consider replacing that line in DcMotorTest with
initTetrixControllerSettings(TETRIX_SENSOR_PORT, 1, 0x0);
(which allows you to run the test with only a single DC Motor Controller)

replacing it in ServoMotorTest with
initTetrixControllerSettings(TETRIX_SENSOR_PORT, 1, 0x1);
(which allows you to run the test with only a single Servo Controller)

and finally creating a DcMotorServoTest version that does both and uses the original
initTetrixControllerSettings(TETRIX_SENSOR_PORT, 2, 0x02);
(which uses a DC Motor controller and a servo controller)

as that would be more useful in showing folks how initTetrixControllerSettings is actually used in setting up various different Tetrix controller configurations.

Just my thoughts, though. Do what you think is best.
Bill

Bill,
Awesome. We will work through these changes. Thanks!

Bill, we just pushed out a newer version yesterday, with the changes you recommended. Again, thanks so much for this!