Closed tombue closed 11 years ago
Hi @tombue! Welcome to github and to openFrameworks development.
Can you go into more details about what you are attempting to do? Are you trying to make a Pi talk to an Arduino or something else. It would also help if you made a gist (https://gist.github.com/) with what your code is doing.
Hi Dan
Thanks for the wellcoming.
I'm trying to get analog readings from a Arduino connected to the Pi via USB and use these inputs to control a graphic environment based on a particle system. The code is based on various OF-examples, and coded in Xcode. The programme and setup works on the mac and Arduino, but ported (and compiled) on the Pi, it throws an exception (poco). I should mention, that an earlier version of the graphic part without the Arduino code worked well on the Pi.
Heres the Arduino parts of the code: (while posting it, I realized that I within the code have setup a non pwm pin to output a such. Will check that, however it was again not a problem on the mac.
in setup: ard.connect("/dev/ttyACM0", 57600); ofAddListener(ard.EInitialized, this, &testApp::setupArduino); bSetupArduino = false;
in update: updateArduino();
in: void testApp::setupArduino(const int & version) {
ofRemoveListener(ard.EInitialized, this, &testApp::setupArduino);
bSetupArduino = true;
// set pin A0,1,2 to analog input, 13 to output
ard.sendAnalogPinReporting(0, ARD_ANALOG);
ard.sendAnalogPinReporting(1, ARD_ANALOG);
ard.sendAnalogPinReporting(2, ARD_ANALOG);
ard.sendDigitalPinMode(13, ARD_OUTPUT);
ofAddListener(ard.EAnalogPinChanged, this, &testApp::analogPinChanged);
}
in: void testApp::updateArduino(){
ard.update();
// do not send anything until the arduino has been set up
if (bSetupArduino) {
// fade the led connected to pin D11 - Realizing here that I have changed that to pin 13, which doesn't do pwm. Will check that.
ard.sendPwm(13, (int)(128 + 128 * sin(ofGetElapsedTimef()))); // pwm...
}
} and finally in: void testApp::analogPinChanged(const int & pinNum) { // do something with the analog input. here we're simply going to print the pin number and // value to the screen each time it changes // potValue = "analog pin: " + ofToString(pinNum) + " = " + ofToString(ard.getAnalog(pinNum));
if (pinNum == 0){ // door sensor
if(ard.getAnalog(pinNum)>800){
if (lastSensor != 1){
lastSensor = 1;
// now logs to the file
ofLog() << "Sensor: " << lastSensor << " at: " << ofGetTimestampString() ;
}
// Door sensor closing
// reset and start
} else {
lastSensor = 0;
ofLog() << "Sensor: " << lastSensor << " at: " << ofGetTimestampString() ;
}
}
if (pinNum == 1){ // toilet sensor
if(ard.getAnalog(pinNum)>800){
if (lastSensor != 2){
lastSensor = 2;
// now logs to the file
ofLog() << "Sensor: " << lastSensor << " at: " << ofGetTimestampString() ;
}
if((ofGetElapsedTimeMillis()-lastBugTime)>500 && p.size()<300){ // delay before new bugs are created AND limit the number of bugs
p.push_back(demoParticle());
p.back().reset();
lastBugTime = ofGetElapsedTimeMillis();
}
} else {
lastSensor = 0;
ofLog() << "Sensor: " << lastSensor << " at: " << ofGetTimestampString() ;
}
}
if (pinNum == 2){ // sink sensor
if(ard.getAnalog(pinNum)>800){
if (lastSensor != 3){
lastSensor = 3;
// now logs to the file
ofLog() << "Sensor: " << lastSensor << " at: " << ofGetTimestampString() ;
}
if (soapRadius<ofGetScreenWidth()){ // only expand the soap circle if it covers the screen
soapRadius += 0.7; // set how fast the soap circle expands
}
} else {
lastSensor = 0;
ofLog() << "Sensor: " << lastSensor << " at: " << ofGetTimestampString();
}
}
}
Hope this helps.
I'll try to replicate a simple setup with an Arduino and Rpi.
Exciting stuff! Keep the thread posted as I have a few students here attempting the same stuff.
@tombue are you using the RPI master-raspberrypi or develop-raspberrypi branch? I'd recommend using the develop-raspberrypi branch as it is much further along. We have a few more issues to fix before we move the latest develop over to master.
If you want to try everything with the develop-raspberrypi branch, on the command line (in you raspberry pi openFrameworks directory), change branches like this:
$ git checkout develop-raspberrypi
If you have made changes and the checkout throws errors, you can "stash" your changes and reapply them like this:
$ git stash
$ git checkout develop-raspberrypi
$ git stash pop
@bakercp Yes, I'm using the master, but will try out the develop rightaway and get back. Thanks.
@bakercp Sorry, my mistake. Apparently the Pi knows better: "Already on 'develop-raspberrypi'".
I tried commenting out the following lines and now the programme runs without exceptions:
In setup: // ofAddListener(ard.EInitialized, this, &testApp::setupArduino); // bSetupArduino = false;
In void testApp::setupArduino(const int & version)
// remove listener because we don't need it anymore
// ofRemoveListener(ard.EInitialized, this, &testApp::setupArduino);
// it is now safe to send commands to the Arduino
// bSetupArduino = true;
In void testApp::updateArduino()
// do not send anything until the arduino has been set up
// if (bSetupArduino) { // fade the led connected to pin D11 ard.sendPwm(11, (int)(128 + 128 * sin(ofGetElapsedTimef()))); // pwm... //
... and then just do direct readings by commands in setup.
However, I still do not get any readings from the Arduino. I get a -1 value when reading A0.
Hi @tombue, sorry for the delay getting back to you. I am going to be in the art/tech lab tomorrow and will test this out. CB
On Friday, November 30, 2012, tombue wrote:
I tried commenting out the following lines and now the programme runs without exceptions:
In setup: // ofAddListener(ard.EInitialized, this, &testApp::setupArduino); // bSetupArduino = false;
In void testApp::setupArduino(const int & version)
// remove listener because we don't need it anymore
// ofRemoveListener(ard.EInitialized, this, &testApp::setupArduino);
// it is now safe to send commands to the Arduino
// bSetupArduino = true;
In void testApp::updateArduino()
// do not send anything until the arduino has been set up
// if (bSetupArduino) { // fade the led connected to pin D11 ard.sendPwm(11, (int)(128 + 128 * sin(ofGetElapsedTimef()))); // pwm... //
... and then just do direct readings by commands in setup.
However, I still do not get any readings from the Arduino. I get a -1 value when reading A0.
— Reply to this email directly or view it on GitHubhttps://github.com/openFrameworks-RaspberryPi/openFrameworks/issues/58#issuecomment-10883365.
@bakercp 'Closed' - does that mean that you got it to work in the lab?
@tombue Yes that is what it means. You should probably do a pull on the develop branch and see if it works for you.
Argh, actually it was an accident. I updated ofSerial, but I haven't tested the firmata example. Doing that now ...
Thanks @dan-eachscape and @bakercp - both posts helped ;-)
@tombue I'm getting the same poco exceptions and doing some tests on Poco. We were having some issues with Poco in some other areas and I'm making sure our compiled libs are matching the headers, etc. Stay tuned ...
@tombue just to confirm -- your first issue is a problem with custom Poco events throughout our build. I'm recompiling the poco libs as I didn't link to the raspberry pi pthreads, etc the first time I built them. This could also solve another thread-related issue when using GLES2 and mouse events ... more soon.
@tombue just a small update here ... I believe that the fact that Poco events are broken is why the firmata example is not working. Have you confirmed that ofSerial
works by itself with a simple arduino example that just dumps Serial.write(analogRead(map(A0,0,1024,0,255));
? I can read Serial data coming in from the Arduino without a problem (but just directly accessing the /dev/ttyACM*
device), but I haven't tested it with ofSerial
yet. Can you confirm that simple serial communication works directly with ofSerial
? Thx!
hi @tombue, I just conformed that both ofSerial
and ofArduino
are working with updated poco libs. It was indeed a thread + poco events problem. @arturoc just got his RPI and is uploading fixed libs now which would be the easiest fix. Theoretically, you should be able to pull and relink/build your project. If that doesn't work, I can also confirm that using the system poco libs (via apt-get) also works. It just requires a small platform config change.
hi @bakercp , sorry for the 'radio-silence', had other non-related problems to deal with. Looks great, I'll try it out. Thanks!
@bakercp , I have tried pull, rebuild of (getting an error on 'portaudio.h missing', getting the poco libs, rebuilding my project (getting an error on gstpad.h).
I basically must be doing something wrong in the pull/upgrade/[insert several other newbie-revealing words here] process. It would be a great help if you could spell out the process for me - or should I simply try reinstalling everything?
@tombue try running
sudo apt-get install portaudio19-dev
this is a recent add - probably after you already ran the install_dependencies script
@jvcleave thanks. OF now built without problems - succes!
The project however now misses the 'ofAppRaspberryPiWindow.h' file.
try duplicating your project and replacing the project's main.cpp and makefiles with the ones from devApps/raspberrypi_hello_world
you need to recompile the openFrameworks project from the ~/openframeworks/libs/openFrameworksCompiled/project/ by typing make
On Wed, Dec 5, 2012 at 8:33 AM, tombue notifications@github.com wrote:
@jvcleave https://github.com/jvcleave thanks. OF now built without problems - succes!
The project however now misses the 'ofAppRaspberryPiWindow.h' file.
— Reply to this email directly or view it on GitHubhttps://github.com/openFrameworks-RaspberryPi/openFrameworks/issues/58#issuecomment-11041324.
"I believe in science. Unlike mathematical theorems, scientific results can't be proved. They can only be tested again and again, until only a fool would not believe them.
I cannot prove that electrons exist, but I believe fervently in their existence. And if you don't believe in them, I have a high voltage cattle prod I'm willing to apply as an argument on their behalf. Electrons speak for themselves."
-- Seth Lloyd: Quantum Mechanical Engineer, MIT
/.
also ofAppRaspberryPiWindow.h doesn't exist anymore, you can remove the include
@danthemellowman thanks, did that. Good to know it was the right to do it. @jvcleave and @arturoc thanks, that solved the compilation-issue.
However, still not able to get readings. Only getting -1 on analogread. @bakercp what is the basic example you have working? Just to find out if it is a bug in my code or setup. And the "It just requires a small platform config change.", if you have time, could you point me in that direction? Thank you all for a good first github/learning experience.
Hey, check them out here:
https://www.dropbox.com/sh/sniu50axdegq81f/cB7iLH2QUZ
The serialExampleSimple has the very simple Arduino code at the top of the testApp.cpp
file -- looks like this:
// Arduino Sketch
// Hook a single potentiometer to the A0 input.
void setup() {
Serial.begin(56700);
}
void loop() {
Serial.write(analogRead(A0) >> 2); // stuff 10 bits into 8
delay(100);
}
The firmata Example uses the StandardFirmata, which is in the latest Arduino IDE examples.
@bakercp have tried the firmata example, it builds and runs but never receives anything from the arduino. I have now made a shiny new installation of raspbian and of-dev branch on another SD-card. However, when here the raspberrypi_hello_world won't build, saying its missing the configure.core.make and configure.project.fags.make files.
The error: pi@raspberrypi ~/openFrameworks/apps/devApps/raspberrypi_hello_world $ make makefile:12: ../../../libs/openFrameworksCompiled/project/makefileCommon/configure.core.make: No such file or directory makefile:15: ../../../libs/openFrameworksCompiled/project/makefileCommon/configure.project.flags.make: No such file or directory make: *\ No rule to make target `../../../libs/openFrameworksCompiled/project/makefileCommon/configure.project.flags.make'. Stop.
I have the same 'make' issue on the dev branch like @tombue
You need to use the updated makefiles they are found in /apps/devApps makefile_example. Just copy the Makefile and config.make. I tried botj arduino examples over the weekend with my uno and leonardo and ran into issues with both. Im going to be looking at those thursday night to find the issues. On Dec 12, 2012 9:03 AM, "ryatkins" notifications@github.com wrote:
I have the same 'make' issue on the dev branch like @tombuehttps://github.com/tombue
— Reply to this email directly or view it on GitHubhttps://github.com/openFrameworks-RaspberryPi/openFrameworks/issues/58#issuecomment-11289721.
Hi all, could you try out the https://github.com/openFrameworks-RaspberryPi/openFrameworks/tree/makefile-cleanup banch? I have been doing a lot of work in there to try to clean up the makefile system and make it more streamlined.
git checkout makefile-cleanup
Hi @bakercp Just tried that, but got: /openFrameworks/apps/devApps/raspberrypi_hello_world $ make make: *\ No targets specified and no makefile found. Stop.
Hi @tombue -- the makefile was removed from the demo on the raspberrypi_hello_world app (eventually the PG will be responsible for placing it there). For the moment, you can copy this one:
$(OF_ROOT)/scripts/linux/template/linuxarmv6l/Makefile
into any of your projects. The "best" default makefiles currently live in that templates folder on the makefile-cleanup
branch.
config.make
is also optional on the makefile-cleanup
branch (i.e. you don't need to copy it to your project directory unless you need to make project specific changes).
CB
@bakercp Thanks and sorry if I should have realized this from somewhere else on the git(?), still learning to navigate here.
@bakercp The strange thing is, is says:
Makefile:2: /libs/openFrameworksCompiled/project/makefileCommon/Makefile.examples: No such file or directory make: *\ No rule to make target `/libs/openFrameworksCompiled/project/makefileCommon/Makefile.examples'. Stop.
But when I check the dir it is there: ~/openFrameworks/libs/openFrameworksCompiled/project/makefileCommon $ ls compile.core.make config.make Makefile.armv6l Makefile.platform.utility compile.project.make Makefile.android Makefile.examples Makefile.rpi
@tombue make sure you have the right makefiles, check the makefile_example app in (OF_ROOT)/apps/devApps/makefile_example. You can tell the difference if you are using old makefile
instead of the newer Makefile
You are right about one thing, one of the failures of github is the lack of good notifications, unless you are allowed to push to a repo, then you get too many. Like I didn't know that branch existed until I did a fetch the other day. I would say one thing you could do, if you are new to github and git completely, is get yourself a nice client like SourceTree to keep up with all the work. If you look at it and read the howto you should be able to keep up with everything from your regular computer.
But we should setup some miniblog or something on the openFrameworks site or someplace else for the work we are doing with the RaspberryPi.
Also please continue to ask a question, no question is too stupid. I'm happy to be a rubber duck or answer any questions to the best of my abilities.
also note that we have an IRC channel on freenode #openFrameworks
@danthemellowman Thanks so much - you guys are definitely getting a big hug in the thank you-section of our semester project report. And I will look into SourceTree.
In this case I am using the new Makefile (it seems), but it fail to have the definition of the root. after adding
ifndef OF_ROOT OF_ROOT=../../.. endif
at the top of the file, it compiles fine (well, with an error on my use of ofSoundPlayer, but that's probably an internal error in my head while coding).
@tombue thanks for your patience on this -- we're still in the very fast and furious stage with a lot changing from day to day (which makes it especially hard to track for newer users!). A lot of the frustrations are coming from the makefile system still being in flux (which is why I'm working on the makefile-cleanup
branch). I'm hoping to get everything merged in and working more smoothly by this weekend. Hang in there and please don't hesitate to ask as many questions as needed. It helps us all figure out where the holes are. Cheers!
@bakercp No problem, I have a lot of respect for the enormous work you guys are doing, and happy to learn from it too.
A question: Is ofSoundPlayer the way to go for playing soundfiles? I have it working fine in the mac-version of my project, but it fails to compile when I try to incorporate it on the pi.
(all of this assumes you are using the makefile-cleanup
branch)
sudo apt-get install libgstreamer0.10-dev libgstreamer-plugins-base0.10-dev gstreamer0.10-nice gstreamer0.10-tools gstreamer0.10-plugins-good gstreamer0.10-plugins-bad gstreamer0.10-plugins-ugly gstreamer0.10-alsa libavcodec-dev libavformat-dev libavutil-dev libswscale-dev libasound2-dev libxmu-dev libxxf86vm-dev g++ libgl1-mesa-dev libglu1-mesa-dev libraw1394-dev libudev-dev libdrm-dev gstreamer0.10-ffmpeg libglew-dev libopenal-dev libsndfile-dev libfreeimage-dev libcairo2-dev libgtk2.0-dev libjack-jackd2-dev python-lxml python-argparse portaudio19-dev alsa-utils
libs/openFrameworksCompiled/project/
directory and running make clean
and make CleanDebug
, but just in case, I'd recommend manually making sure that libraries libs/openFrameworksCompiled/lib/linuxarmv6l/libopenFrameworks.a
and libs/openFrameworksCompiled/lib/linuxarmv6l/libopenFrameworksDebug.a
are deleted. You should also make sure that the libs/openFrameworksCompiled/project/obj
directory is completely deleted and (by some change if you find an obj directory here libs/openFrameworksCompiled/project/linuxarmv6l/obj
make sure that it is also deleted.libs/openFrameworksCompiled/project/
and run make
to build a fresh openFrameworks lib.scripts/linux/template/linuxarmv6l/Makefile
to the example's project folder and run make
.If you have problems, compare your directory:
libs/openFrameworksCompiled/project/linuxarmv6l
to https://github.com/openFrameworks-RaspberryPi/openFrameworks/tree/makefile-cleanup/libs/openFrameworksCompiled/project/linuxarmv6l
and
libs/openFrameworksCompiled/project/makefileCommon
to https://github.com/openFrameworks-RaspberryPi/openFrameworks/tree/makefile-cleanup/libs/openFrameworksCompiled/project/makefileCommon
Keep us posted!
http://www.raspberrypi-spy.co.uk/2012/06/raspberry-pi-speakers-analog-sound-test/
Once you have those tests confirmed, then you should test the sound examples
examples/sound/soundPlayerExample/
Be advised that audioInputExample
won't work without a USB audio input device like this (or similar) http://www.amazon.com/dp/B001MSS6CS/
@tombue one more thing -- once you get this audio and arduino stuff working (which I'm sure you will soon!), would you be so kind as to write a step-by-step guide for each on the wiki? https://github.com/openFrameworks-RaspberryPi/openFrameworks/wiki? I think it will be very helpful to other folks starting up.
Great - compiling right now. I have been able to play sound (mp3-files) with mplayer from the terminal, but will follow the test, and looking forward to trying out the examples.
I'll be happy to do the wiki, however right now (due to a deadline-issue) I have paused on the Arduino, and instead implemented the wiringPi c-library to use the gpio-pins for input from sensors (processed by the arduino and just converted to highs and low - now beautiful, but working). But will look into both arduino and soundguide.
I'm running into the same issues as before with the ofSoundPlayer I'm gerpping the codebase to make sure we are linking in portaudio from the system libs.
On Wed, Dec 12, 2012 at 8:57 PM, tombue notifications@github.com wrote:
Great - compiling right now. I have been able to play sound (mp3-files) with mplayer from the terminal, but will follow the test, and looking forward to trying out the examples.
I'll be happy to do the wiki, however right now (due to a deadline-issue) I have paused on the Arduino, and instead implemented the wiringPi c-library to use the gpio-pins for input from sensors (processed by the arduino and just converted to highs and low - now beautiful, but working). But will look into both arduino and soundguide.
— Reply to this email directly or view it on GitHubhttps://github.com/openFrameworks-RaspberryPi/openFrameworks/issues/58#issuecomment-11319087.
"I believe in science. Unlike mathematical theorems, scientific results can't be proved. They can only be tested again and again, until only a fool would not believe them.
I cannot prove that electrons exist, but I believe fervently in their existence. And if you don't believe in them, I have a high voltage cattle prod I'm willing to apply as an argument on their behalf. Electrons speak for themselves."
-- Seth Lloyd: Quantum Mechanical Engineer, MIT
/.
Getting the following errors:
obj/linuxarmv6l/Release/src/testApp.o: In function testApp::setup()': testApp.cpp:(.text+0x7e8): undefined reference to
ofSoundPlayer::setMultiPlay(bool)'
testApp.cpp:(.text+0x834): undefined reference to ofSoundPlayer::loadSound(std::basic_string<char, std::char_traits<char>, std::allocator<char> >, bool)' obj/linuxarmv6l/Release/src/testApp.o: In function
testApp::update()':
testApp.cpp:(.text+0x1490): undefined reference to ofSoundPlayer::setPan(float)' testApp.cpp:(.text+0x14b8): undefined reference to
ofSoundPlayer::setSpeed(float)'
testApp.cpp:(.text+0x14cc): undefined reference to ofSoundPlayer::play()' obj/linuxarmv6l/Release/src/testApp.o: In function
ofSoundPlayer::~ofSoundPlayer()':
testApp.cpp:(.text._ZN13ofSoundPlayerD2Ev[_ZN13ofSoundPlayerD5Ev]+0x88): undefined reference to vtable for ofSoundPlayer' obj/linuxarmv6l/Release/src/main.o: In function
testApp::testApp()':
main.cpp:(.text._ZN7testAppC2Ev[_ZN7testAppC5Ev]+0x164): undefined reference to `ofSoundPlayer::ofSoundPlayer()'
collect2: ld returned 1 exit status
when compiling
Hey there, I think I found the problem -- it looks like one of the old config files slipped into this branch (my fault). It looks like it has some of the old settings that excluded sound and such ... I am going to do a fresh install and see if I can get it sorted out. More soon.
Hi all, I just pushed some updates to the makefile-cleanup
branch. Evidently, I fixed it in an my "various bugfixes" branch, but neglected to pull those changes into my makefile-cleanup branch. I just did a fresh clean / make and everything seems to be working again.
Just one reminder, to get the sound come out of my TV over HDMI, I had to do this:
sudo amixer cset numid=3 2
before running any oF audio tests.
Oooooooo I can wait to try that!!! On Dec 12, 2012 11:37 PM, "Christopher Baker" notifications@github.com wrote:
Hi all, I just pushed some updates to the makefile-cleanup branch. Evidently, I fixed it in an my "various bugfixes" branch, but neglected to pull those changes into my makefile-cleanup branch. I just did a fresh clean / make and everything seems to be working again.
Just one reminder, to get the sound come out of my TV over HDMI, I had to do this:
sudo amixer cset numid=3
before running any oF audio tests.
— Reply to this email directly or view it on GitHubhttps://github.com/openFrameworks-RaspberryPi/openFrameworks/issues/58#issuecomment-11322284.
Aaaand I have ofSoundPlayer working - tried first with .mp3, but that made the app exit before it started. But .wav is working.
@danthemellowman what did you do to get mp3 working? Did you have to install some special codecs?
Hi there. Totally new to the Github experience, I'm an Art & Technology student from Denmark currently working on a project coded in openframeworks and hopefully running on the Pi.
In the code I make use of the ofArduino functions, but while the code manage to compile, the programme throws an exception right from the start.
Hope this is of any help, please let me know if there are details or codes of conduct I should be following here.
And keep up the good work!