Heading via lua

Discussion on the Lua Scripting capabilities for RaceCapture/Pro. Also see the <a href="http://autosportlabs.net/RaceCapturePro_Lua_Scripting">Lua Scripting Guide</a>

Moderators: JeffC, stieg

Post Reply
MrBlahh
Posts: 45
Joined: Tue Sep 27, 2016 11:13 pm

Heading via lua

Post by MrBlahh »

anyone worked out heading via lua?

not sure it's the best place to do it, due to jitter you would have to average out a few readings to calculate it reasonably

burn4005
Posts: 3
Joined: Mon Sep 10, 2018 2:38 am

Post by burn4005 »

came accross this post when looking to see if this bridge had been crossed..

I've created a function that will give heading angle in degrees.I haven't tested this yet but in theory it should work if Lua is fully implemented.

I got the function from:
https://www.igismap.com/formula-to-find ... longitude/

Code: Select all

function headingcalc&#40;lat2,lon2,lat1,lon1&#41;

  rlat1 = math.rad&#40;lat1&#41;
  rlon1 = math.rad&#40;lon1&#41;
  rlat2 = math.rad&#40;lat2&#41;
  rlon2 = math.rad&#40;lon2&#41;
  dlon = rlon2-rlon1
  x = math.cos&#40;rlat2&#41; * math.sin&#40;dlon&#41;
  y = math.cos&#40;rlat1&#41; * math.sin &#40;rlat2&#41; - math.sin&#40;rlat1&#41; * math.cos&#40;rlat2&#41; * math.cos&#40;dlon&#41;
  rhead = math.atan2&#40;x,y&#41;
  return math.deg&#40;rhead&#41;
end
a lot of math functions to do, not sure how computationally expensive it will be. i'd operate it at a much lower tick rate than the GPS. maybe 10hz instead of 50?

thoraxe
Posts: 47
Joined: Wed Dec 14, 2016 2:29 am
Location: Atlanta, GA
Contact:

Re: Heading via lua

Post by thoraxe »

MrBlahh wrote:anyone worked out heading via lua?

not sure it's the best place to do it, due to jitter you would have to average out a few readings to calculate it reasonably
I'm curious why you wanted to implement this. I may have a similar need with integration with an AEM CD-7 dash.

Post Reply