TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

Ask HN: Calculating Acceleration range from json data in Python

4 pointsby uber1geekover 9 years ago
I am writing a script where i have some geojson data from a gps receiver of a bike with speed, timestamp and latlong. I have so far sorted the data using natsort, which gives the output in reverse order with the relevant timestamps.<p>Basically what i want to do here is trim a video (max 60 - 90 seconds) based on when the rider accelerates. So i need to get the range of timestamps which i can pass onto another script for processing of the video. Is there any formula out there for calculating acceleration which is relevant to my problem ? How can i get the range?<p>https:&#x2F;&#x2F;github.com&#x2F;uber1geek&#x2F;Python-GPS-Data-Analysis

2 comments

bigiainover 9 years ago
How simplistic an answer do you need? (apologies if this way underestimates where your question is coming from...)<p>Acceleration is change in speed[1] over time. Delta V over delta T. How many meters per second did you change your speed by every second?<p>So for a first approximation: Take three consecutive datapoints (a, b, and c). Calculate the distance and time between point a and b (from their lat&#x2F;longs and timestamps). Divide the distance by the time to get average speed between a and b. Now do the same for points b and c. Now you can subtract one from the other to get &quot;change in speed&quot;, and you can approximate the corresponding &quot;change in time&quot; several ways depending on the nature of your data (if you&#x27;ve got reliable one-point-per-second datapoints, just use 1 second as your &quot;change in time&quot;. if your gps data isn&#x27;t that consistent, I&#x27;d first try averaging the two time intervals a-b and b-c and using that.)<p>Now just keep doing that iteratively for every point and the two points following it to get a stream of acceleration datapoints and their relative timestamps. Turning this into Python is left as an exercise for the reader :-)<p><i>Edit</i>: I just re-read the full question after posting this - if you&#x27;ve got reliable speeds for each timestamped datapoint, ignore the first half of that, all you need to to is calculate &quot;the speed at time b minus speed at time a divided by time difference between time a and b&quot; , then assign that as the acceleration for time b (for simplicity, or for some new average time halfway between time a and b to bet closer to &quot;the truth&quot;). That&#x27;ll probably get you &quot;close enough&quot;.<p>Note that if you&#x27;re getting typical GPS data &quot;noise&quot;, you&#x27;ll probably want to track a moving average of the calculated accelerations. The multi rotor controller guys seem to mostly use &quot;kalman filters&quot; to clean up and make sense out of real world noisy sensor data... For your use case of algorithmicly generating timestamps in video, you quite likely wont need to get their level of precision. Try the easy way first...<p>[1] I&#x27;ll handwave away the technicalities of the difference between speed and velocity for at least the first approximation solution here...
评论 #11102542 未加载
mjhea0over 9 years ago
clickable &gt; <a href="https:&#x2F;&#x2F;github.com&#x2F;uber1geek&#x2F;Python-GPS-Data-Analysis" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;uber1geek&#x2F;Python-GPS-Data-Analysis</a>
评论 #11104156 未加载