Concurrent file upload and sound playback for Lego 'plays'

Post your NXJ projects, project ideas, etc here!

Moderators: roger, imaqine, 99jonathan

New User
Posts: 1
Joined: Fri Jul 10, 2009 5:40 pm

Concurrent file upload and sound playback for Lego 'plays'

Postby RobotSoul » Fri Jul 10, 2009 6:55 pm

Hello, all.

I am currently working on a project that involves using 2 mobile Lego robots as 'actors' in a scripted play controlled by a single laptop computer. I have gathered from several other posts that there will be little trouble using NXTControl on the laptop to remotely control the two robots using Bluetooth.

I want to include customized speeches in these scripts, but these .wav files are relatively large (~100kB for 10 seconds of speech) and take a long time to transfer (I believe a test I ran required ~17 seconds to transfer a 50kB file, but I may be remembering wrong). Having the sound file play and then transferring the next sound file will produce awkward pauses in real-time operation. One solution I have examined is chopping up the .wav files into 5 second .wav files and transferring the next sound file required as the robot is playing the current sound file. If I am thinking correctly, I could create two separate threads, one to play the sound file and another to communicate with the computer via Bluetooth and receive the next sound file. I would like to know if NXTCommand already handles things this way (IE, uploadFile and playSoundFile are blocking threads) and, if not, if there are any problems that you foresee with the two-thread configuration I have described.

As an added complication, there may be times where one of the 'actors' is required to speak and move at the same time. I believe that the thread-switching in LeJOS can handle this, but I am unfamiliar with how Bluetooth works on the NXT and I would appreciate some assurance that the LCP listener thread in NXTCommand and the upload thread will not interfere with each other.

Thank you for your time and for creating and maintaining this Forum - it has been an invaluable resource for me since I started this project.

-Robot Soul

Return to “NXJ Projects”

Who is online

Users browsing this forum: Yahoo [Bot] and 1 guest