Adding a new vehicle from scratch

Hello !

I’ve been using and coding on Ardupilot for a while now and I used it on a lot of various projects. Most of these projects did have robots that would not fit in a “Rover” or “Drone” description so I had to implement heavy modifications to the code to get it working ( Modifying Motors Layer, Attitude control etc … ). So far, all I’ve managed to do is to modify codes that were supposed to be handled by drones or rover, and most of the code is unused or useless. Also, the architecture of current vehicle codes is not always suiting to my needs and I’m going to use Ardupilot a lot in the future.

That’s why I would like to build a vehicle code from scratch, using only the HAL library and getting rid of most of the work around autopilots, to get somehow my own version of the code. However, so far I haven’t found a way to build a new code from scratch. Every time I try to use the command ./waf build --target “myvehicle”, there are errors precising that I must create a “task generator” for my vehicle.

Is there any “empty” vehicle code already existing ? Or is there any way to add a new vehicle to the build utility ?

I know it’s a hard problematic, so thanks in advance.

Paul.

1 Like

Hi,
I was recently interested in doing the same thing for a research project I am working on, and I was able to make some initial progress. I thought for myself that it could be useful to make some heavy mods to the ArduPlane vehicle category, so I just made a copy of the ArduPlane folder in my branch of the repository and called it “ArduModel” (you can name it whatever you want, but this one seemed to make sense for me). Then the other mods I had to make so it would compile with $ ./waf is I had to edit lines 37 and 38 of the version of the wscript file that was copied from the ArduPlane folder and is now in the ArduModel so they went from

program_name='arduplane',
program_groups=['bin', 'plane'],

to

program_name='ardumodel',
program_groups=['bin', 'model'],

I also had to edit line 552 of the wscript file in the root ArduPilot repository folder so that it went from

for name in ('antennatracker', 'copter', 'heli', 'plane', 'rover', 'sub', 'bootloader','iofirmware','AP_Periph'):

to

for name in ('antennatracker', 'copter', 'heli', 'plane', 'model', 'rover', 'sub', 'bootloader','iofirmware','AP_Periph'):

Now when I run $ ./waf --help in my local version of the ArduPilot repository, the first part of the output looks like

sdeal3@ME02W0464GRD03:/mnt/d/sdeal3/Documents/ardupilot-research$ ./waf --help
waf [commands] [options]

Main commands (example: ./waf build -j4)
  AP_Periph     : builds AP_Periph programs
  all           : builds all programs of all group
  antennatracker: builds antennatracker programs
  benchmarks    : builds all programs of benchmarks group
  bin           : builds all programs of bin group
  bootloader    : builds bootloader programs
  build         : executes the build
  check         : builds all programs and run tests
  check-all     : shortcut for `waf check --alltests`
  clean         : cleans the project
  configure     : configures the project
  copter        : builds copter programs
  dist          : makes a tarball for redistributing the sources
  distcheck     : checks if the project compiles (tarball from 'dist')
  distclean     : removes build folders and data
  examples      : builds all programs of examples group
  heli          : builds heli programs
  install       : installs the targets on the system
  iofirmware    : builds iofirmware programs
  list          : lists the targets to execute
  localinstall  : runs install using BLD/install as destdir, where BLD is the build variant directory
  model         : builds model programs
  plane         : builds plane programs
  rover         : builds rover programs
  rsync         : runs localinstall and then rsyncs BLD/install with the target system
  step          : executes tasks in a step-by-step fashion, for debugging
  sub           : builds sub programs
  tests         : builds all programs of tests group
  tools         : builds all programs of tools group
  uninstall     : removes the targets installed

So now $ ./waf knows about my new vehicle “model” and I can compile and upload it to my flight controller with the command $ ./waf model --upload. Obviously there are a lot of things that I won’t be needing that are copied over from ArduPlane, but the scheduler can be easily edited in the main ArduPlane file to remove the functions that I am not using and add the new functions that I want to use.

Sorry for the length, but this is just some of my thoughts that I had as I am trying out some interesting ways of tackling drone and robotics projects while taking advantage of the modularity and portability of the ArduPilot codebase.

1 Like