flighttrack5_c.jpg
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.

3D_track.jpg
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.

 

Video

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:

SplineNav.h
SplineNav.pde

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.

 

Warnings

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!
E-mail me when people leave their comments –

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

Join diydrones

Comments

  • Developer

    I always get a little confused with all the different spline names but I think we are using Cubic Hermite spline's. They only depend on the waypoints at each end of the segment and the velocity vector at each end of the segment.

  • This is the cubic spline reference i am following

    http://www.geos.ed.ac.uk/~yliu23/docs/lect_spline.pdf

    And code

    http://oceancolor.gsfc.nasa.gov/staff/norman/seawifs_image_cookbook...

    See how every segment, depends on every other segment. I don't see how a localized approach is possible

  • Hi David

    I am curious as to how you reduce processing overhead in spline computation. For example if there are 5 spline segments, segment-1 depends on segment-2, which depends on 3... and so on.

    If you had a mission made entirely of splines wouldn't it be too much overhead trying to solve this tridiagonal system of equations for the second derivative?

  • Hi Chris,

    I've put an APM in the case of a Phantom 1 (see http://diydrones.com/profiles/blogs/arduphantom-apm-arducopter-in-a...), but Phantom 2 may be more difficult. The Phantom 1 ESCs can connect directly to the APM outputs, but I believe the Phantom 2 ESCs do not use the standard PWM signal. Maybe you could use Phantom 1 ESCs in your Phantom 2 case though.

  • Hi David,

    Please excuse the dumb question, but can I get this ArduCopter3.0/SplineNav to work with my DJI Phantom 2 Vision Plus ?

    Thanks very much for your time!!  -Chris

  • Developer

    Dusan, spline curves are being developed and tested by both David and Leonard in the current beta of copter 3.2, and we have a policy of not documenting features until they are in final form in a full code release.  You can read about the developement over here http://diydrones.com/forum/topics/arducopter-3-2-beta-testing

  • @Leonardthall, I don't know is it working or not but can tell you that isn't well documented, at least not under name of spline curve spline mode or anything like it. I would like to see somebody actually fly a mission and explain like David how to set it up.

  • Developer

    David, can you elaborate on how it isn't working well?

  • The latest release has spline segments in Auto mode, but they don't seem to work very well yet, so for now I would still suggest installing my SplineNav 0.3 from GitHub.

  • Did  this ever make it to official release ?

This reply was deleted.