DexterOS Python --- Pygame and Playing Sounds


#1

I have just put together a new GoPiGo3. I’m surprised that pygame does not seem to be there. Am I missing something or do I need to install it?


#2

Which operating system are you using?


#3

I am using Dexter OS.


#4

I think we may have talked about this, and realized that pygame usually gives output to a monitor and DexterOS is meant to be run as a wifi-tethered device, not with a monitor attached. Can you remember @cleoqc or @RobertLucian?


#5

Exactly, @JohnC.

@rscherl, most of what pygames offers cannot be supported with the remote connection found in DexterOs, unfortunately.


#6

@rscherl if you’re interested in using pygame, why notinstall Raspbian for Robots? You will have all python GoPiGo3 drivers installed, and you’ll be able to use pygame.


#7

Thanks for all the comments. My reason for using pygames is to play audio files. Is there another alternative for that given what is installed on the GoPiGo3. I didn’t find any documentation.

One option I thought of was installing pygames. Do you see this as creating any problems, if I am only playing audio files.

Perhaps you have another suggestion.

I did see the instructions for installing Raspbian for Robots on the GoPIGo3. If I do that, would I loose the wifi network created by the GoPiGo3. I rather like that as it makes it very easy to connect. Also, would I loose the onoff switch capability, which I also like.


#8

Our application (already implemented on a GoPiGo2) is to have the robot move towards an autistic child, then stop and play a series of sentences. we then record the child’s responses. Later on we will have more interaction depending on the response of the child. So, the wifi connection with the GoPiGo3 is useful and all we need from pygames is the audio file playing capability.


#9

@rscherl,

The DexterOS connectivity is indeed an easy way to connect, but the price to pay is that you lose Internet connectivity. That means you can’t install anything on DexterOS.

You could go with Cinch - which you can turn off on demand. Cinch is just Raspbian for Robots with a similar connectivity to DexterOS. With Cinch, you would be able to install whatever you need and still connect via the GoPiGo3 access point. It’s a more advanced setup than DexterOS.

Or you can make a call similar to what we do in Bloxter. We call aplay to play .wav files internally.

Cleo


#10

Btw, I love your application, and would love hearing more about it!


#11

Thanks for your suggestions. I’ll look into them and see what works for us. Will keep you informed about the project too.

Rich


#12
from subprocess import call
cmd = '''aplay /home/pi/Sam_Dev/webapp/static/sam_wav/"bark_DEX.wav"&'''
call([cmd],shell=True)

This is the Python code we use internally to play a .wav file.
Unfortunately, only those files can be played with this approach.


#13

Thanks You. I will try this then. Xxxxxxxxxxxxxxxxxx
Rich


#14

Hey @rscherl, I think @cleoqc has the best idea here for Python! Note you can also play sounds in Bloxter as well.

Sounds like a really awesome application, we would love to feature it or do a blog post on it if you’re up for that.


#15

Thanks for the encouragement. We’ll let you know how things turn out and can certainly create a blog post.

Rich


#16

Cleoqc:

Unfortunately, something is missing, I get an error with aplay (even typing at the command line). I have an error from the ALSA lib, card 0 missing?

I am using an external speaker plugged into the round hole.
Rich


#17

@rscherl
I attempted the following at the command line:

sudo aplay /home/pi/Sam_Dev/webapp/static/sam_wav/bark_DEX.wav

sudo is required. Does it work for you?

Cleo


#18

Yes that works. Thanks!! As usual the error mssg didn’t say anything about permission, so I did not think of this.

One other thing, do I need to do anything special to save files that I upload? They seemed to disappear from session to session.


#19

@rscherl,
yeah! One step forward!

Sound files are meant to be kept on a USB drive, and not transferred to the SD card. As for your Python files, make sure you’re running DexterOS 1.2 There was a bug before this version, that erased the user-defined Python files.

Cleo


#20

I’m not sure how to find out what version I am using? There must be a simple command?
I see that installing a newer version is involved using the USB drive.
I did not see in the Python area, how to save onto the USB drive vs the SD card. I did see that when I looked at Bloxter programming.

My sound files are disappearing between sessions.

I was wondering why you (all) decided on the USB drive rather than using a larger sd card?

Rich