PX4 Star Wars Startup Tone

tldr; We made Star Wars the default theme for our px4 startup

Hi, I’m part of a lab that uses pixhawks in our uav setup. While the default “alarm tones” the buzzer makes for various situations (e.g. startup, arming, battery warning ...) are good, my labmates thought it would be a cool idea to set custom ones to other tunes that our nerdier sides would appreciate. Enter Star Wars-playing pixhawk UAV. It turns out that the process is fairly straightforward, and doesn’t take too long.

There’s a reasonable guide that we used for reference. The process works great! The only file that has to be changed in the px4 firmware setup is tone_alarm.cpp (Firmware/src/drivers/stm32/tone_alarm/tone_alarm.cpp). To change the startup alarm, we modified the ANSI music styled string for the default TONE_STARTUP_TUNE on line 328 to:

328    _default_tunes[TONE_STARTUP_TUNE] = "T200L4O4FO4FO4FP16MNL2O4B-.O5F.L8O5E-O5DO5CL2O5B-.L4O5F.L8O5E-O5DO5CL2O5B-.L4O5F.L8O5E-O5DO5E-L1O5C";

The new string is set to the opening theme for Star Wars. Check it out for yourself by going into the px4 software and modifying that line to this one.

We used musicnotes’ Star Wars main title sheet music for reference. The translation is pretty close (not exact with the triplets or the tempo). The result sounds pretty much exactly like a direct transcription of the melody notes. For the musically inclined, we start at measure 3 and end at measure 7, and also use dotted notes when needed instead of changing the tempo explicitly (there may be a cap on the amount of notes that can be processed based on the length of the string, we didn’t test that much and the issue only appeared on dosbox).

We also have some other attached alarm tunes that you can check out at the bottom of this post.

If you want to make your own songs, see Ansi Music Guide. It will tell you all you need to know, and the rest is up to your proficiency in music.

If you want to check your work, and since flashing the pixhawk every time is a hassle, then we’ve included what we used to do the same, as recommended by pixhawk’s documentation (https://pixhawk.org/dev/tone_alarm) which was to download a dosbox emulator and the Melody Maker Ansi Music Editor.

  1. Download and setup the dosbox emulator (sudo apt-get install dosbox for Ubuntu, then enter ‘dosbox’ to command line)

  2. Outside the emulator make a directory (i.e. dosprogs) and unzip Melody Maker to it (if you want, also see page 14 of MELODY.DOC)

  3. Mount the dosprogs folder (i.e. in dosbox, mount c ~/dosprogs) and cd to it (i.e. enter C:)

  4. If MMV31 is in dosprogs (can use 'DIR' in the emulator to show the directory and check), then type in ‘MMV31’ and extract

  5. We opened up a file in dosprogs outside the emulator called “STARWARS” with a basic text editor and just wrote the characters to it (didn’t use melody’s interface).

  6. We played the “music” using the command 'MMUTIL /P STARWARS' through command line ANSI music player

  7. Once satisfied, we moved the string into tone_alarm.cpp, flashed, and on startup it worked like a charm

Probably took an hour to get everything going and write some of the tunes. Would like to see what other songs people would put on their drones (we're planning to put ride of the valkyries somewhere :)

Links:

tone_alarm.cpp

Tone Alarm Guide

Ansi Music Guide

dosbox

Command Line ANSI Music Player for dosbox

Star Wars Sheet Music

exampleAlarms.txt

You need to be a member of diydrones to add comments!

Join diydrones

Email me when people reply –

Replies

  • Never mind. I managed to solve myself. 

    I finally can build the code and update the sound. 

    Thanks!


    Kyuhyong You said:

    It is very nice and useful tutorial. Thank you for sharing.

    Could you explain how I can build the modules in /src directory?

    I tried make px4-v2-quad and upload but the tone does not change.

  • It is very nice and useful tutorial. Thank you for sharing.

    Could you explain how I can build the modules in /src directory?

    I tried make px4-v2-quad and upload but the tone does not change.

  • This is great work, thanks for sharing! 

This reply was deleted.

Activity

DIY Robocars via Twitter
Saturday
DIY Drones via Twitter
RT @chr1sa: After more than a year of only virtual races, @DIYRobocars returns to the newly renovated @circuitlaunch on May 22 for the resu…
Apr 11
DIY Robocars via Twitter
RT @DAVGtech: And now available with LiDAR 🔥 https://twitter.com/Heavy02011/status/1381137016381964293
Apr 11
DIY Robocars via Twitter
RT @Heavy02011: #VirtualRaceLeague: @DIYRobocars Race #9 - #ParkingLotNerds #thunderhillracetrack, CA Join us for the next race April 24th,…
Apr 11
DIY Robocars via Twitter
RT @DWalmroth: Weather's finally cooperating, looking forward to racing 1:10 scale autonomous cars outdoors again! @diyrobocars, @NVIDIAEm…
Apr 7
DIY Robocars via Twitter
RT @AIDRI_: I finally succeeded in optimizing the trajectory and speed of a car on a #racetrack. Next step: implement a 2d controller and…
Apr 7
DIY Robocars via Twitter
@jetdillo @circuitlaunch Actually the second *in person* event in a year. We do virtual races every month
Apr 2
DIY Robocars via Twitter
Update: we're moving it back one day to Sunday (the 4th) at 11:00am instead
Apr 2
DIY Robocars via Twitter
@GrantEMoe @circuitlaunch Update: we're doing it on Sunday (4th) at 11:00am instead
Apr 2
Laurie J. Troy liked Jasper Kueppers's profile
Apr 1
DIY Robocars via Twitter
RT @chr1sa: Maybe we should have a mini @DIYRobocars race in our lower school's playground https://t.co/xLFeua1R6X
Mar 29
DIY Robocars via Twitter
If anybody wants to join us for an informal outdoors hack/race we're going to be meeting at the @CircuitLaunch park… https://twitter.com/i/web/status/1375907409223249923
Mar 27
DIY Robocars via Twitter
RT @SmallpixelCar: Ready to reopen, innovation has to continue. Inside/outside, LiDAR/GPS, race/delivery https://t.co/jpmvttoHEd
Mar 26
DIY Drones via Twitter
RT @DAVGtech: By far best race yet! Congratulations to the winner @Heavy02011 🥇🏆🍾👏👏👏 @diyrobocars @donkey_car @NVIDIAEmbedded https://t.co/…
Mar 20
DIY Robocars via Twitter
RT @Heavy02011: #VirtualRaceLeague: @DIYRobocars Race #8 - #ParkingLotNerds ⁦@DAVGtech⁩ ⁦@DWalmroth⁩ ⁦@OttawaAVGroup⁩ - join us tomorrow h…
Mar 20
DIY Drones via Twitter
RT @mrpollo: 11 years ago, the pxIMU was announced to the world on @DIYDrones, and it changed the life of many (mine included). The followi…
Mar 18
More…