Importing BrickPi.py

Hi,

I am in the process of testing and making EV3 work with my BrickPi Starter Kit and ran into an issue.
Actually I´m not sure if it´s one or more issues.

  • I have run the motor tests successfully

  • Testing the touch sensor (“LEGO-Touch_Sensor_Test.py”) I get the result “1” no matter if the sensor is pressed or not. I know the sensor is working and have tried with multiple ports.

  • Running “EV3-Firmware_Check.py” I get the following error: NameError: name ‘RETURN_VERSION’ is not defined.

  • Running for example “Switch-Motor.py” found on this forum under projects, I get the following error: NameError: name ‘TYPE_SENSOR_EV3_TOUCH_DEBOUNCE’ is not defined.

So, I found my BrickPi.py-file was not up to date.

  • I cloned the entire BrickPi_Python folder from Github to my BrickPi Desktop. But still get the same results.
  • Entering the LXTerminal and the BrickPi_Python directory running “git pull” I get the response “Already up-to-date.”

So, I suppose something is wrong related to importing the BrickPi.py-file into the programs.(?)
I´m not sure what to do next; can You help fix this, please?
(I´m trying not to spam You with screen shots and attachments, but please just let me know if I can send You anything useful.)

BR.,
Jakob

Hello Jakob,

from my limited knowledge on the topic, I can say, that if you have EV3 sensor, you should test using EV3 - Touch sensor test.py, not standard for NXT.

Have you installed the BrickPi module as global module?

sudo apt-get install python-setuptools
sudo python setup.py install

Hi Kerhold,

Thank you very much for your reply.
Of course You´re right about running the EV3-tests. Thanks.
When doing so I get the error saying the name is not defined (…TOUCH_0 and …TOUCH_DEBOUNCE.) which I guess points to the BrickPi.py import issue or installation as you mention.

I have not installed the BrickPi module. It´s like it came in the BrickPi Starter Kit.

  • Will I need to do that for my updated files in “BrickPi_Python” to have effect?
  • And will I need to uninstall something first or can I just run the commands you posted and do it on top of what´s already on the original Starter Kit?

Thanks Again!
/
Jakob

Hello Jakob,

not sure about DI image, because I’m working on my standard Raspbian, but I will check that, since I have it on another SD. Although I tried it some time ago and it worked quite ok.
What version of Raspbian for Robots you use? In other words, what is the date on the sticker?
There is newest version from February I believe.
It’s very likely, that you are using older version without support for EV3 and maybe the global module, which is installed doesn’t have those defined.

You can try one more thing though. Copy BrickPi.py file to examples folder or just symlink it.
I’m not sure what order is using Import - will it first look in local directory or in global, depends probably on environment path settings.

If that fail, I recommend to just flash new version of Raspbian for Robots on your SD card.

JokobFS, Kerhold,
The BrickPi.py firmware that works with the EV3 sensor is in the directory “EV3BETA”. To use that firmware with the EV3 sensors in the current image, make the following commands in the command line:

cd ~/Desktop/BrickPi_Python/
cp BrickPi.py Sensor_Examples/

This should copy the latest version of BrickPi.py into the /Sensor_Examples directory. If you run any of the EV3 examples they should (hopefully) work.

I’ll update this in the image in the next few days.