DIY Golf Launch Monitor

Launch monitor using low-cost raspberry pi and camera hardware to determine ball launch speed, angles and spin

Similar projects worth following
The project's main goal is to produce software and hardware designs for a fully-functional golf launch monitor that avoids the need for expensive high shutter-speed and high frame-rate cameras. Building the system has required developing techniques for high-speed, infrared, strobe-based image capture and processing using cameras such as the Pi Global Shutter camera (~$50 retail) and Raspberry Pi single board computers. A first version is built and currently under test. See the Project Log pages for the latest news!

Ultimately, the project should be able to accurately determine ball speed, launch angles, and--importantly--ball spin in 3 axes. The output of the system will be accessible on a stand-alone web-based app. Outputs and interfaces to popular golf-course simulators systems such as GsPro are in progress and will be tested soon.

The project will likely be released as open-source, though patent applications on some of the IP have been filed to keep options open.


My personal goal has been to use this project as a learning platform for myself.  So far, I’ve been able to explore all sorts of software and hardware that I hadn’t worked with previously.  I’ve been kid-in-a-candy-store, getting to learn all sorts of new technology, techniques, libraries, and platforms.  This has also forced me to spin up on my linear algebra again.  


Some of the technologies in use so far are:

  • Active-MQ (multi-protocol messaging middleware)
  • Apache Jakarta Server Pages (serves the web-based default system GUI)
  • Boost (various foundational libraries for logging, multi-threading, thread-safe data structures, command line processing, etc.)
  • Debian (Raspbian) Linux (OS)
  • JSON (serialization)
  • JMS (messaging)
  • KiCad (schematic capture and PCB layout)
  • Libcamera and Libcamera/rpicam-apps App (open-source camera stack & framework)
  • Maven (java build automation)
  • Meson & Ninja (build tools)
  • Msgpack (efficient architecture-independent serialization)
  • OpenCV (image processing & filtering, matrix math)
  • PiGPIO (GPIO and SPI library)
  • Raspberry Pi Single-Board Computers
  • Tomee (hosts the web-based interface)
  • KiCad (Schematic and PCB software)

The software is written almost entirely in C++, with the goal of having the codebase look close to commercial standards in terms of testability, architecture, and documentation.  There are some utilities (for functions like camera and lens calibration) that were easier to implement in Python and/or Unix scripts.


I’d like to have the entire system cost less than US$300.  I’m currently over-budget by about a hundred dollars, but have plans that should bring that price down.  For example, the new Raspberry Pi 5 should be able to support both of the system cameras, which could decrease the price by around $50 by avoiding a second Pi.

The high-level parts list at this time:

Additional Project Videos:

  • Printed Circuit Boards are Working!

    James Pilgrim6 days ago 0 comments

    The first run of printed circuit boards arrived today from JLCPCB.  These are the boards that help connect the components of the system and also keep the high voltage strobe signals isolated from the fairly fragile Raspberry Pi GPIO circuitry.  

    The boards look good.  Especially for the very low price that #JLCPCB charges for small boards like this.  The entire thing, including (slow) shipping was a whopping US$ 3.64.  I wasn’t able to get anything locally (which I would have preferred) for less than $300!  

    Here’s the unboxing pictures.  I’m sure they’ll go viral soon...

    It only took a few minutes to populate the board.  By dumb luck, all the holes ended up in the right places!  Pretty surprising given that this was my first attempt at having PCB boards manufactured and also because I'm using an unfamiliar CAD system.  Of course, it's a pretty simple circuit, so maybe even I couldn't screw it up. ;)

    Here’s the finished (populated) and empty boards:

    Most amazing of all, is that everything tested out and worked on the first try:

  • A Preliminary Accuracy Analysis - Spin Measurements

    James Pilgrim04/14/2024 at 20:31 0 comments


    Several folks have asked about accuracy and precision.  That’s a big topic, so I decided to start on only a single aspect – spin analysis – and just provide a couple of examples.  I haven’t worked out a formal, full, math-based error analysis yet, and am not certain I can. Instead, this log entry will just focus on providing anecdotal descriptions of the errors in what I believe are ‘typical’ scenarios.  I’m not even sure that a math-only analysis is a reasonable goal – there are an awful lot of case-specific potential places for errors to creep in, and it may not be possible to enumerate them all. I’d also probably have to go back to my grad-school books on error analysis and remember all of that. Ugh.  Of course, it would be great if this was all open source someday and some smarter folks could dig into the math and tear it all apart!

    Another important background point is that a real “ground-truth” against which to compare the system is hard to find.  You’d literally have to go to a real golf course, setup the LM(would have to be a very cloudy day to prevent the camera from being flooded with IR), and then measure the real-world distance, angle, etc. on the course and compare it to the results of the physics model in use by the LM/Simulator.  I don’t have those facilities yet. :/  As an alternative, the analysis here will be focused on comparing a best-estimate of the ‘’correct’ ball spin using visual techniques against the ball spin determined by the LM.  We’ll also make a comparison of how those difference(s) manifest themselves in pseudo-real-world coordinates in a simulator (here, GSPro).  The carry distance will also, of course, be determined by the determined launch angles and velocity, but we’re focused on spin here.  I’ll examine those measurements and the related accuracy in a later log entry.  So, let’s start…


    Spin speed accuracy is primarily governed by the accuracy of the angular delta measurement between the ball exposures and the accuracy of the determined time delta between the exposures.  The former is currently most important.  Precision is limited by the fact the system only deals with degrees of spin as an integer, so 1 degree is the upper limit on precision.

    Let’s start with the following first example, where the strobed ball images are shown below.  I chose these examples because they have a ball with strong registration markings that ended up facing the camera.  That makes for easier visual analysis of the spin.  These were also images where the Z-rotation was fairly substantive (these shots were using a 7-iron combined with crappy golf skills), and the X and Y rotations were near-zero, making it easier to focus on the back-spin.

    The system chose two ball exposures from the above image to use for spin analysis.  Those are the first two images, below, and labeled ‘1’ and ‘2’ above.

    From these images, the system determined XYZ Angles (in degrees) of -5, 0, and 37.  The -5 is side-spin, and the 37 is backspin. The 0 y-axis is “rifle-bore” spin, which is usually near zero.  The system determined the time between the two images to be 3500uS (3.5 ms).  The dark penumbra around the balls is a result of de-rotating the balls to a common frame of reference.  That de-rotation (reversed later in the processing) creates some dark edges because some of the back of the ball (to the camera) has no information when rotated around to the front in 3D.  The small dots (especially on the third image) are a result of the 3D/2D projection/de-projection operations.

    In order to provide a visual sanity-check for the player, the system reproduces the first ball image rotated by the determined angular deltas, and shows that image as the third image above.  In a perfect world, the result of rotating the first image by the delta angles should produce...

    Read more »

  • GSPro Interface Working

    James Pilgrim04/03/2024 at 18:11 1 comment

  • Connection Board Prototype

    James Pilgrim03/28/2024 at 13:34 0 comments

    Finally getting around to documenting the small bit of circuitry in the project to make it easier for folks  to produce.  And as am added bonus, I get to learn KiCad!  KiCad is a really great, free, open-source schematic and PCB layout tool.

    The circuit board facilitates the connections between the hardware elements in the system.  Those elements include the external shutter trigger on the PiCameras, the GPIO interfaces on the Pi computers, and the switching for the strobe light.  Importantly, the connection board opto-isolates and provides separate ground planes for each subsystem, including the higher-voltage strobe power supply.  That turned out to be important after I accidentally killed two different Pi units due to what appeared to be voltage transients from the strobe power supply getting to the GPIO chip on the Pi's.  Now, each power supply area is a separate, hopefully-safe island of its own.

    Shout out to the H11 high-speed opto-coupler chip.  Very easy to use, and quite hardy.

    Now if I can just find a low-cost, low-volume PCB manufacturer...

    Follow-up:  I'm trying JLCPCB, a low-cost China PCB factory.  They were pretty easy to work with.  I just uploaded my Gerber files and their website produced a quote and showed me a 3-D version of my board in a flash.

    I hope to go from this mess of spaghetti:

    To (hopefully) this:

  • Spin Analysis - Accuracy Verification

    James Pilgrim03/26/2024 at 13:57 0 comments

    One goal for the DIY launch monitor has been to be able to accurately determine the spin rate of balls in 3 axes without requiring any registration marks or other modifications to the ball (as some launch monitors need).  The system now has some new processing artifact outputs and other refinements to spin analysis to confirm that the spin analysis is working.  

    The main idea is that because this is currently a new, and relatively untested system, we want to be able to give developers (and players!) the tools they need to visually sanity-check the spin analysis.  One way to do that is to start by showing the two balls (an initial ball and a final ball that has undergone some spin) that were chosen for analysis. Then, take the spin angles that the system calculated for spin and apply them to the first ball and show how that looks.  If things are working correctly, the first ball image (to which the spin angles were applied) should look to a human just like the original second (target) ball.

    Particularly, depending on the trace-logging level, the system can now show the for-comparison balls at the same, normalized reference angle to make it more of an apples-to-apples comparison.  Each image is pre-rotated so that both appear as they would if the image were seen in the center of the image, straight down the camera lens bore.  

    For example, see the results of the spin analysis that the system chose for the highlighted balls in the first image below, where the results are shown in the three later images.  A ball with marks was used in this example, but that’s not necessary.

    As shown above, it looks great!  The exact determined angles above were (X, Y, Z):  (4, 6, 64) degrees before being adjusted for azimuth and pan angles.  Again, the system doesn’t require any registration marks like this ball has, but using a ball with marks does help for these visual sanity checks.  Oddly, the marks can actually detract a bit from the analysis accuracy.

    The little dots all over the images are the results of the proprietary fast 3D projection and un-projections that the system uses.  These ‘holes’ could be interpolated away like most rotation algorithms do, but that’s not necessary for accurate spin-angle analysis.  It could also chew up time and has other downsides.

  • GSPro sockets interface working (at least on test platform)

    James Pilgrim03/23/2024 at 22:32 0 comments

    A simulated GSPro launch monitor interface and test sockets server is now complete.  The server simulates an actual GSPro Connect system in order for me to be able to do end-to-end testing.  This LM interface send results data to the GSPro socket whenever a ball is hit.  I don’t actually have a real GSPro system yet - still need to rummage around for a sufficiently modern graphics card and build a machine to run that.

    An example JSON object that was sent from the launch monitor to the simulated GSPro server (and the simulated response) is shown below.  Hopefully I can validate on a real system soon.  The only thing I can see wrong at this point is that the spin angle is somehow being truncated to 0.  Probably a dopey radians/degree mistake on my part.

    [2024-03-23 16:18:46.440414] (0x0000007fb2794040) [trace] Received the following message from the Launch Monitor: 


        "DeviceID": "PTrac LM 0.1",

        "Units": "Yards",

        "ShotNumber": 1,

        "APIversion": "1",

        "BallData": {

            "Speed": 31.0,

            "SpinAxis": 0.0,

            "TotalSpin": 0.0,

            "BackSpin": 3743.0,

            "SideSpin": "-358.0",

            "HLA": 13.3,

            "VLA": "-7.9"


        "ClubData": {

            "Speed": 0.0,

            "AngleOfAttack": 0.0,

            "FaceToTarget": 0.0,

            "Lie": 0.0,

            "Loft": 0.0,

            "Path": 0.0,

            "SpeedAtImpact": 0.0,

            "VerticalFaceImpact": 0.0,

            "HorizontalFaceImpact": 0.0,

            "ClosureRate": 0.0


        "ShotDataOptions": {

            "ContainsBallData": true,

            "ContainsClubData": false,

            "LaunchMonitorIsReady": true,

            "LaunchMonitorBallDetected": true,

            "IsHeartBeat": false



    [2024-03-23 16:18:46.441129] (0x0000007fb2794040) [trace] Sending the following message from the GSPro simulated server: 


            "Code": 201,           

            "Message" : "GSPro Player Information",           

            "Player" : {

               "Handed": "RH",

               "Club" : "DR"

             }  }

  • New form factor for the Launch Monitor

    James Pilgrim03/23/2024 at 14:48 0 comments

    The absurdly long extension arm has been replaced with a more compact form factor.  The LM now has both cameras stacked vertically, and each both can be independently aimed. 

    The math for location computation took a while to finish, but seems to have actually increased accuracy.  The z-axis measurements are no longer purely ball-radius based, as the ball can now be seen at an angle.  

    With the ability to tilt the cameras, there is much more flexibility for where to tee the ball up versus where it will be imaged after it is hit.  Hopefully, this will allow for a greater range of ball speeds, as we can make up for slow reaction times that are currently inherent in the part of the system that senses the initial ball movement and begins the strobed imaging of the ball in flight.  For example, by placing the ball a little further back, there's more time to react to the movement of a fast-hit ball and get images of it before it flies out of the frame of the second (bottom) camera.

View all 7 project logs

Enjoy this project?



robhedrick wrote 2 days ago point

How's this coming along? I would love to see some code! 

  Are you sure? yes | no

andrew wrote 04/06/2024 at 04:56 point

This is looking really good! Do you have a GitHub repo yet?  I have been looking for a backyard setup. 

  Are you sure? yes | no

James Pilgrim wrote 04/06/2024 at 13:32 point

Not quite ready for a public repo yet, but hopefully someday not too far in the future.  Outdoor setups may be better served with a radar-based LM.  The DIY project is currently very sensitive to large amounts of IR light.

  Are you sure? yes | no

James Pilgrim wrote 04/02/2024 at 16:40 point

Hi all!  Apologies for being pokey about responding to everyone's DMs.  I've ALMOST got GSPro integration working, and will hopefully have a little demo video out soon showing some actual shots on (simulated) greens. 

I hope to provide some thoughtful responses to folks as soon as I get the GSPro connection working consistently.  (And thanks to the great GSPro people- they've been very helpful).

  Are you sure? yes | no

Eric wrote 03/27/2024 at 12:54 point

Project looks great. In the latest photo looks like your hitting with an actual golf club. Just curious, are you still planning on open sourcing this?

  Are you sure? yes | no

James Pilgrim wrote 03/28/2024 at 13:39 point

Yes - at this point, all the testing is with real clubs and golf balls.  Although I'm still searching for enough room to try out a big driver.  That will be necessary to prove out the high-speed capability of the LM, which is only theoretical at this point. ;/  I may have to borrow a friend with some real golfing skill as well, given that I'm not sure I can hit a ball anywhere near 100m/s.

The intent is still to open source the LM.  That said, there have been a couple of recent developments that might affect that, but seems unlikely to change.

  Are you sure? yes | no

camab wrote 03/24/2024 at 16:42 point

This is really cool. Something I've been wanting to do for awhile now but never attempted it. How are you handling the image capture timing? I think I've read that Skytrak uses a laser curtain to tell when the golf ball has been hit. Are you just having the first camera detect a golf ball via machine learning and then wait for it to move to trigger the second camera? 

  Are you sure? yes | no

James Pilgrim wrote 03/26/2024 at 03:01 point

Yes - The first camera just watches in a tight loop for any ball movement.  Once it moves, the second camera is triggered.

  Are you sure? yes | no

James Pilgrim wrote 03/23/2024 at 15:25 point

Ha - Thank you - I can't wait to start using it with a real golf simulator setup myself! :)  Still lots of testing to do, but am edging closer to using it in a simulator bay with a driver and a big screen every day.

  Are you sure? yes | no

Dylan Walsh wrote 03/11/2024 at 23:27 point

This is so freaking cool. Can’t wait to try this out.

  Are you sure? yes | no

Similar Projects

Does this project spark your interest?

Become a member to follow this project and never miss any updates