Hello world app?

This is probably a totally weird question. First post here. I did some ardupilot code spelunking back in the atmega2560 days and prior to that, but nothing ardupilot related since then. This probably isn’t the right subsection to post this, but I couldn’t find a better one. Sorry if my question makes no sense to those that fully understand the ardupilot ecosystem, but I’m trying to learn, and I currently know very little about the modern ardupilot ecosystem. I have good familiarity with arduino, linux, c++, python, make … but waf is new to me, and prior to today I haven’t looked at chibios (or how chibios interacts with ardupilot code and how the waf build system ties it all together). Ok, so with the disclaimers in place, here is my dumb question.

I would like to write a simple hello world or blinky led application that is as minimalist as possible and run it on a pixracer board (and I also am intrigued by the matek f765 board.) Later I might want to experiment with running some of my own software/algorithms on these boards … if I can get out of the starting gate without falling flat on my face.

ChibiOS looks nice and seems to support all the interesting FC boards that exist in the world (at least via ardupilot?) So Chibios seems like a reasonable way to proceed (versus bare metal coding and spending the next 10 years learning the datasheet/registers for the stm32F765…)

If I want to be minimalistic and write a hello world app on top of chibios, is there an easy way to cherry pick a board config out of the ardupilot tree and use it directly with chibios? Would it be easier to try to add my own “ArduHelloWorld” module to the ardupilot build tree?

I am in that awkward place of looking for a path of least resistance without knowing anything, so I thought maybe asking for a few gentle nudges in the right direction (or advice that what I have in mind isn’t practical) might save me a lot of frustration at the outset. I did just compile the arduplane code on my fedora 34 system, so I at least was able to manage that.

Thanks in advance for any thoughts or nudges …

Curt.

There are some “examples” folders in the ArduPilot source, for example: https://github.com/ArduPilot/ardupilot/tree/master/libraries/AP_HAL/examples/UART_test (which can be compiled and uploaded via ./waf --target=examples/UART_test --upload).

No LED examples, from what I can see though.

1 Like

Thanks Stephen!

Ok, I’m getting my pixracer to output: Hello on UART SERIAL0 at 48.066 second … on /dev/ttyACM0 as seen on minicom … cool!

So much to learn, and waf is a new egg I’ve never seen before and know nothing about, but this is definitely a positive starting point.

Is there a better place to post dumb/noob waf questions and other dumb questions as I try to figure out aspects of the ardupilot code layout and build system?

Perhaps drop in to the discord server where the Devs hang out: https://ardupilot.org/discord
I suspect you’ll pick things up quickly: if memory serves correctly, whilst you may not have played around in the ArduPilot codebase much, the dark arts of state estimation and flight control are not foreign to you.

1 Like

The dark arts of discord do worry me though. But maybe that is a more appropriate place for random/scattered “I don’t know what I’m doing” type questions. I’ll have to figure out how to get on Australian time I suppose … from memory it’s about a day and a half off from my local time zone.

:slightly_smiling_face: 7.25am Monday here

For what it’s worth, I’m hoping wherever you ask your questions, I can find them. I want to lurk and learn! :slight_smile:

1 Like

We need to document this better. @peterbarker pointed Curt towards searching the git history for the recent Blimp vehicle type to see an example, which is a start but somewhat clunky.

1 Like

And I came up pretty short on that suggestion. :frowning: It looks like the commit with the initial blimp changes included a wide range of unrelated other changes throughout the entire project, so there is still a huge amount of diff’s to wade through, especially when you aren’t super sure what to be looking for.
That said, mine is probably not a very common request, and any build system for a project like this is going to be complex … Maybe if there is someone who knows this part of the ardupilot source code magic, they could give me a couple nudges and I could try to take some basic notes.
I have one theory that I still need to try, but I ran out of steam last night.

Thanks,

Curt.

@tridge could give the best pointers, but tends to be pretty busy.

1 Like

Yeah I was hoping not to bother the heavy lifters in the project. I’ll keep poking at it as time permits and see what I can puzzle my way through.

Ok, so far …

  1. create / copy a new top level subdirectory. I think in ardupilot terms this would be creating a new ‘vehicle’. I copied examples/UART_test -> Curt

  2. Edit the top level wscript to add your new vehicle to the common name list (not the necessarily the subdir name) … so like: plane, blimp, copter … curt_test

  3. Your new vehicle subfolder needs a proper wscript itself and this is where you need to edit the same common vehicle name you chose. The subdirectory name is whatever you want and waf appears to search the source tree for a wscript with a ‘program_name’ that matches what you asked to build.

  4. Edit …/ardupilot/libraries/AP_Vehicle/AP_Vehicle_Type.h to #define APM_BUILD_Subdir with a new value (I picked 101 to stay out of the way of possible future expansion.) But most likely these changes will live only on my own hard drive. Note: the symbol you define uses the subdir name, not the common name you picked.

This gets me a ways down the path. Now I need to puzzle through what I really need in my new vehicle subdir, and what changes I need to make to the subdir/wscript file to get a clean compile of a simple hello world type program.

In retrospect, I should have copied Blimp -> Curt and then made mods from there, instead of UART_test -> Curt and then copying Blimp/wscript -> Curt/wscript and editing wscript. So I have a complete mess inside the Curt directory, but at least waf finds my new vehicle and makes it’s best attempt … up to a link error which is pretty expected.

Edit: So yes, it seems like the much smarter plan would be to copy an existing vehicle, add it to the top level wscript and AP_Vehicle_Type.h and then whittle away all the things you don’t need (carve away everything that doesn’t look like an elephant.)

2 Likes