Results 1 to 9 of 9

Thread: Lean angle - left /right, using GoPro Data stream

  1. #1
    Potential Tuner
    Join Date
    Oct 2019
    Posts
    3

    Lean angle - left /right, using GoPro Data stream

    Hi guys,

    Has anyone been able to creat a "absolute" lean angle object using data from GoPro Data stream - Accelerometer / Gyroscope ?
    The data streams I see are
    Gyroscope (z) [rad/s] Gyroscope (x) [rad/s] Gyroscope (y) [rad/s]
    Accelerometer (up/down) [m/s2] Accelerometer (right/left) [m/s2] Accelerometer (forward/back) [m/s2]

    I know there is another application that managed to compute this somehow; tried and went down mathematics/physics rabbit hole last night trying to get a grasp of things; it's been a while since I played around with them) , but alas; maybe somebody here managed already to compute this stream?

    P.S. My immediate application would be motorcycle lean angle, relative to the asphalt.

    Thanks, and cheers.

  2. #2
    I don't think this is built in, but I would think that Gyroscope (z) [rad/s] would be the field that you would want. This would probably only work if the camera is physically attached to the bike itself though. If you have the camera mounted on your helmet, I would think that you would be keeping your head mostly level through the turns, and the GoPro data wouldn't tell you much of anything about lean angle.

    A gauge like this should work:Lean Angle - Gauge.rro

    You should be able to copy that gauge (or create your own) into the Styles folder, and then when you next open RaceRender, it should appear in the list of Gauges.

    If you set the field to Gyroscope z, then you should be getting values between -1.57 (bike on the ground on the left) and 1.57 (bike on the ground on the right). Realistically, you're probably only going to get numbers between -1 and 1 since 1 radian is 57.2958 degrees.

    If you prefer looking at degrees, you could create a custom field at the bottom of the Input File Config where you take the Gyroscope z field and multiply it by 57.2958. Then you could use the custom field in the gauge for something that might be more comprehensible. You would likely need to change the Range from -1.57/1.57 to -90/90 at that point though.

  3. #3
    Potential Tuner
    Join Date
    Oct 2019
    Posts
    3
    Thanks for your informative reply.
    I have indeed mounted the gopro camera in the nose of my track bike as leveled as I could to the relative upright position on the stands.

    I will try to use the Z axis. And apply the formula you suggested.
    As I said, there is there are some other applications that calculate this according to.. from what I gather... relative position on previous and next reading. (like a lead and lag reference)
    I will try to compare results and see if they match.

    Love RR as race editor (also love your work on the kart F1 like leaderboard and sectors, still fidgeting around with my HUD, nothing definitive, but for race sessions would definitely try and include your leaderboard), if I have to use 3rd party to get an accurate lean angle well no worries.
    I won't name them, as I don't think it's appropriate.

    P.S. Thanks for sharing the gauge, I'm mobile now, but will definitely try it tonight.

  4. #4
    Potential Tuner
    Join Date
    Oct 2020
    Posts
    3
    Hello,

    I have used the following formula to calculate pitch and roll based on raw accelerometer readings in microcontroller code:

    accelerationX = (signed int)(((signed int)rawData_X) * 3.9);
    accelerationY = (signed int)(((signed int)rawData_Y) * 3.9);
    accelerationZ = (signed int)(((signed int)rawData_Z) * 3.9);
    pitch = 180 * atan (accelerationX/sqrt(accelerationY*accelerationY + accelerationZ*accelerationZ))/M_PI;
    roll = 180 * atan (accelerationY/sqrt(accelerationX*accelerationX + accelerationZ*accelerationZ))/M_PI;

    As you can see roll (lean angle) is based on readings from all 3 acceleration readings.

    I found this post while trying to determine how I can get lean angle readings from GoPro data stream like the poster. I too have the other application I think he means that does the calculation to determine lean and I assume it uses a formula like I post above.

    Is there any way in RaceRender to do complex formula such as that for a custom field? I only see simple calculations in the UI. I suppose the other option is to edit the CSV that it creates from the GoPro data and add the calculation there?

    Thanks, Jeff

  5. #5
    Quote Originally Posted by J_D_W View Post
    Hello,

    I have used the following formula to calculate pitch and roll based on raw accelerometer readings in microcontroller code:

    accelerationX = (signed int)(((signed int)rawData_X) * 3.9);
    accelerationY = (signed int)(((signed int)rawData_Y) * 3.9);
    accelerationZ = (signed int)(((signed int)rawData_Z) * 3.9);
    pitch = 180 * atan (accelerationX/sqrt(accelerationY*accelerationY + accelerationZ*accelerationZ))/M_PI;
    roll = 180 * atan (accelerationY/sqrt(accelerationX*accelerationX + accelerationZ*accelerationZ))/M_PI;

    As you can see roll (lean angle) is based on readings from all 3 acceleration readings.

    I found this post while trying to determine how I can get lean angle readings from GoPro data stream like the poster. I too have the other application I think he means that does the calculation to determine lean and I assume it uses a formula like I post above.

    Is there any way in RaceRender to do complex formula such as that for a custom field? I only see simple calculations in the UI. I suppose the other option is to edit the CSV that it creates from the GoPro data and add the calculation there?

    Thanks, Jeff
    Editing the CSV itself would be the most straightforward, but that would also be the most time consuming since you would need to do it for every video that you make.

    Fortunately, all of those functions are available in the Enhanced Script Editor. If you can describe what you would like the gauge[s] to look like and provide a sample CSV, I can look into implementing it. Then you would just need to copy the .rro file that I'll upload here onto your computer once and include it in a template that can be used for any video.

  6. #6
    Potential Tuner
    Join Date
    Oct 2020
    Posts
    3
    Hello,

    I did not realize the Enhanced Script Editor was available. Coding isn't an issue but since I am getting data from a GoPro file I have since realized I dont even have the CSV file to understand what fields I have available to base the gauge on. Is there an example of a enhanced object/gauge that works on GoPro data? Is there somewhere the list of attributes available to the enhanced scripting language from a GoPro video? Still loking around for myself otherwise.

    Jeff

  7. #7
    Quote Originally Posted by J_D_W View Post
    Hello,

    I did not realize the Enhanced Script Editor was available. Coding isn't an issue but since I am getting data from a GoPro file I have since realized I dont even have the CSV file to understand what fields I have available to base the gauge on. Is there an example of a enhanced object/gauge that works on GoPro data? Is there somewhere the list of attributes available to the enhanced scripting language from a GoPro video? Still loking around for myself otherwise.

    Jeff
    If you right click on the data Input File, there's an option to Export > CSV. That would be the easiest way to get the data in a sharable format. I just figured that would be the easiest way for me to understand which fields you have, but I'm not sure that a GoPro by itself would have enough fields to calculate all of this.

    On my Hero 8 Black, I see Time, Latitude, Longitude, Altitude, and Speed which (if there's a good enough satellite connection) can be interpreted by RaceRender into AccelX and AccelY (calculated data fields are noted by parentheses), but I don't see any AccelZ field. Recording data separately on a phone using something like Track Addict or Race Chrono can use the phone accelerometers to record that type of info and (at least with RaceChrono) actually give you a separate Lean Angle field without any need for calculating it.

    If you're looking to code it yourself, you would just need to call a few GetDataIndex("Fieldname") in the background script so that you know which index the data would be in, and then call GetDataValue(Index) to get the actual value itself in the foreground script. To see what fields you have available, you can add a Text Data object and just click the Field dropdown to see what is available.

  8. #8
    Potential Tuner
    Join Date
    Oct 2020
    Posts
    3
    I see Time, Latitude, Longitude, Altitude, and Speed as well from the menu but the data within the video has more data in the GMPF stream. Using https://goprotelemetryextractor.com/free I can process the same video and extract the accelerometer data to CSV and get X, Y and Z in m/s2. So I assume RaceRender is processing that stream as well and just automatically maps it correctly for the other gauges that use it (ie gyroscope) as there is no way to calculate gyro (for example) from the items such as lat, long, alt and speed. The data stream should include accelerometer at 200hz, gyro at 200hz and GPS location at 18hz (though that is up for discussion depending where you read it)

    As for recording separately on the phone, I have a data logger under my trackbike seat and send over BT to the phone but I am tired of extracting the data from my data logger or phone app and then having to link up to the video. I thought it be neat to get lean from the camera stream and then the only thing I am missing from my data logger would be throttle and brake sensors but I dont really need them in the video.

    Maybe I will get https://github.com/gopro/gpmf-parser working on the video and see what attribute names the stream use and poke around a bit deeper.

    Thanks, Jeff

  9. #9
    Tuner in Training
    Join Date
    Dec 2015
    Location
    Niskayuna, NY
    Posts
    21
    wbmt, J_D_W, et al.:

    I'm interested in this thread, too, because:

    1) I asked about lean angle inclusion four years ago. See https://forum.hptuners.com/showthrea...ngle-on-iPhone

    2) That telemetry extractor (https://goprotelemetryextractor.com/...emetry-extract) notes that it includes "Smoothing/noise reduction." I wonder whether that would help when GoPro occasionally and briefly loses it GPS coordinates, which I reported on last year; see https://forum.hptuners.com/showthrea...086#post567086

    As I noted, my work-around at the time was to find those errant columns in the CSV file, and interpolate them (although, as I said at the time, I feel that RaceRender should itself do this sort of smoothing).

    The bad news is that extractor software is a whopping $299.