Flying 3D Spline Curves between Waypoints with ArduCopter 3.0

Figure 1: Mission Planner waypoints and telemetry track after 3 spline circuits

I wanted my ArduCopter to fly smooth continuous curves between waypoints for some nicer aerial video, so I coded up this SplineNav class. Each spline segment is a cubic polynomial curve defined in 3D space, with 1st and 2nd derivatives continuous wherever two segments meet at a waypoint. This gives a nice smooth transition between curve segments during flight (Figure 1). It also saves time and battery, since abrupt speed and direction changes are avoided.

Figure 2: Autopilot logged track after 3 spline circuits

The SplineNav class, like CIRCLE mode, calls the loiter controller, which is what allows it to precisely control position along the curve using GPS and inertial navigation (thanks to the brand new ArduCopter 3.0 firmware). Unlike CIRCLE mode, in SplineNav the autopilot takes full control of setting altitude as well, so it can fly complex 3D curves. However, it also references your WPNAV_SPEED, WPNAV_SPEED_DN, and WPNAV_SPEED_UP parameter settings to avoid flying too fast, or climbing or descending too quickly.

For this video I wanted a slightly more wild ride, so I increased my WPNAV_SPEED_DN to 250 cm/s, and WPNAV_SPEED_UP to 350 cm/s. I left WPNAV_SPEED at 500 cm/s for now, but will try increasing it later. Figure 2 shows the 3D track in Google Earth. If you reduce these UP/DN speed parameters you will get the same 3D track for these waypoints, but at the steep up and down locations SplineNav will reduce its travel speed along the 3D curve.



I shot this SplineNav demonstration video with my ArduPhantom. The GoPro is mounted on a Hummer 2-axis brushless gimbal designed for DJI Phantom.

Source Code

Here's the source code for developers and brave testers to test and suggest fixes and improvements. There's a .PDE file and an .H file, both of which go in your ArduCopter 3.0 sketch folder:


Follow the directions in the SplineNav Readme to make the ArduCopter 3.0 code call SplineNav. Then compile with the special ArduPilot version of the Arduino IDE, and upload to your copter. Set your waypoints with Mission Planner, or with the channel 7 switch, and go test out SplineNav.



Make sure your loiter is rock solid before you test, because SplineNav relies on the loiter controller. Also, the first time you test a new set of waypoints, you should probably keep WPNAV_SPEED low, perhaps just 200 cm/s or so. That way you'll have enough time to take over control in case the spline curve intersects any solid objects!

Views: 10805

Comment by Gary Mortimer on June 15, 2013 at 6:49am

Oooh that's nice

Comment by David Dewey on June 15, 2013 at 6:53am


Comment by Brian Morgan on June 15, 2013 at 6:58am

I've been looking for this type of flight curve for a while. Eureka!

Comment by HeliStorm on June 15, 2013 at 7:09am
Very nice. I love the ArduPhantom you have built.
Comment by David Dewey on June 15, 2013 at 7:14am

Me too, I like that it's nice and small so I can carry it hiking and stuff. And the case makes it rugged and crash resistant.

Comment by John Church on June 15, 2013 at 7:35am
Very nice David. This is a tremendous feature and I'm sure your spotlight is getting warmed up! :)

3D Robotics
Comment by Chris Anderson on June 15, 2013 at 7:36am

Impressive work! Are you on the dev list? This should definitely be submitted for consideration as an addition. 

Comment by David Dewey on June 15, 2013 at 8:00am

Thanks Chris, I went ahead and signed up on the dev list. Yes, it would be great if this could be included in a future ArduCopter release.

3D Robotics
Comment by Chris Anderson on June 15, 2013 at 8:04am

David, if you work within our GitHub repository, the team can easily review and integrate the code. Are you using GitHub already?

Comment by David Dewey on June 15, 2013 at 8:25am

Well, I'm not very familiar with GitHub yet, but earlier today I set up a GitHub repository and put the SplineNav files there. Once I learn more about using GitHub I'll be more confident to work within the Ardupilot repository.


You need to be a member of DIY Drones to add comments!

Join DIY Drones

© 2019   Created by Chris Anderson.   Powered by

Badges  |  Report an Issue  |  Terms of Service