Talk to me · Julian Reder · Resume · GitHub

DroneTracker

AERPAW · 2024 - Present

An automated tracking service that points AXIS pan-tilt-zoom cameras at flying drones using live GPS coordinates from Kafka and records flight video over VAPIX.

2024 - Present View Project ↗
PythonVAPIXKafkageopyDockerLinux/Unix
AXIS Q-8615E site pose in YAML UAV now lat lon alt lead NEU velocity tilt = elevation pan = spherical bearing zoom = FOV(range, size) to 0-9999 camera north-offset wraps into AXIS +/-180 VAPIX ptz.cgi, record.cgi, export.mkv
Tracking diagram showing how drone GPS coordinates are transformed into physical camera pan, tilt, and zoom angles.

Built

I developed DroneTracker as a containerized service that reads real-time drone position and velocity telemetry from Apache Kafka, computes the required camera orientation angles, and issues pan, tilt, and zoom commands to AXIS optical cameras over the VAPIX network protocol. Because existing control libraries only supported movement commands without video recording, I also forked and updated the camera client library to manage recording sessions on the camera's local storage.

Hard parts

  • Translating geodetic coordinates into camera angles requires calculating spherical bearings for pan, elevation angles for tilt, and optical zoom steps based on distance and vehicle dimensions.
  • Handling camera compass offsets requires wrapping angles correctly into the camera's native pan range of minus 180 to positive 180 degrees.
  • Supporting predictive lead times requires managing coordinate frame conventions carefully so vertical velocity directions match physical drone movement.
  • Network delays and stale telemetry packets had to be filtered out so the camera would hold a resting position rather than slewing toward outdated coordinates.

Learned

Connecting physical cameras to network telemetry requires handling camera hardware mechanics, network authentication, and video storage management alongside the mathematical coordinate transformations.

Also

  • Geodetic coordinate conversion to pan, tilt, and zoom values for AXIS PTZ cameras with optical calibration.
  • Kafka integration for telemetry ingestion, operator commands, and service status reporting.
  • Automated video recording start, stop, and file export using an updated VAPIX integration library.
  • Docker Compose deployment with support for local simulation and dry-run testing without physical hardware.

Automating camera tracking for drone flights

During field experiments at AERPAW, researchers frequently fly autonomous drone missions that need high-definition video documentation. Manually operating a camera to follow a fast-moving drone across wide open fields is difficult and unreliable, especially during complex multi-vehicle flights. I developed DroneTracker to automate this process by reading live GPS coordinates from the testbed telemetry stream and continuously aiming an AXIS Q-8615E pan-tilt-zoom camera directly at the aircraft while managing video recording sessions.

The service is published in the quantumbagel/DroneTracker repository and runs as a Docker container deployed at the camera tower site. It listens to Kafka messaging topics for telemetry updates and operator instructions, then communicates with the camera over local network interfaces using the manufacturer's VAPIX API.

Calculating camera angles from geodetic coordinates

The core tracking logic converts latitude, longitude, and altitude measurements from the drone into local camera viewing angles. Pan is calculated as a spherical bearing from the camera's surveyed installation point to the aircraft, tilt is derived from relative elevation and slant range, and zoom is computed using a calibrated field-of-view model that adjusts optical magnification based on drone size and distance. These configuration parameters are stored in a site configuration file so the camera can be redeployed to different towers without code changes.

To keep the camera pointed smoothly at moving targets, the service can apply an optional predictive lead time based on reported velocity vectors. Getting this right required converting velocity components into consistent North-East-Up reference frames, accounting for camera mounting compass offsets, and enforcing minimum angular movement thresholds to keep the motor assembly from oscillating unnecessarily on tiny coordinate fluctuations.

AXIS Q-8615E site pose in YAML UAV now lat lon alt lead NEU velocity tilt = elevation pan = spherical bearing zoom = FOV(range, size) to 0-9999 camera north-offset wraps into AXIS +/-180 VAPIX ptz.cgi, record.cgi, export.mkv
Coordinate transformation geometry mapping aircraft geodetic coordinates into local pan, tilt, and optical zoom steps.

Field operations and camera control

Running tracking software in the field comes with practical network and hardware constraints that do not show up in clean simulated environments. For example, if network lag delays telemetry packets, issuing commands based on old data causes the camera to swing toward where the drone was seconds ago rather than where it is now. To prevent this, the tracker discards outdated packets and parks the camera safely whenever the telemetry stream times out.

Managing video recording also required custom work on the camera interface. The existing open source Python library for AXIS cameras supported basic movement but lacked methods for starting or exporting recordings, so I forked the project to add recording controls and file retrieval over Digest-authenticated HTTP endpoints. The service also includes a dry-run mode that logs computed angles without connecting to a physical camera, making it easy to test logic updates from a laptop before deploying to the field.

Kafka telemetry lat lon alt vx vy vz Geodesy bearing, range, elev Lead + offset NEU, +/-180 wrap Zoom model Q-8615E FOV to 0-9999 AXIS VAPIX ptz.cgi, record.cgi, export.mkv
Overview of the telemetry pipeline from Kafka message ingestion to VAPIX camera control and video export.