Programming c# question

Hey everyone,

I'm playing around with getting telemetry from Assetto Corsa shared memory using c#. and the shared memory library

I'm struggling to get the steering angle data from the sim/game and I was wondering if any of you could possibly point me in the right direction?

I have a basic console application in which I'm accessing the data, based on attached document.
Here's the basic code:

using System;
using System.Runtime.InteropServices;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Threading;
using AssettoCorsaSharedMemory;
using System.IO.Ports;
using System.Security.Policy;
using static System.Net.Mime.MediaTypeNames;

namespace AC_console_testing
{
class Program
{
static void Main(string[] args)
{
AssettoCorsa AssettoCommunicator = new AssettoCorsa();
AssettoCommunicator.Start();
AssettoCommunicator.PhysicsUpdated += ACPhysicsUpdated;
Console.Read();
}
private static void ACPhysicsUpdated(object sender, PhysicsEventArgs e) //get shared memory info whenever it changes
{


double SteerAngle = e.Physics.SteerAngle; // getting the steering angle info
Console.WriteLine("HDG: {0}", SteerAngle); // printing it out on the console
Console.WriteLine("");
}
}
}



Problem I'm having is that the steerangle shows values from -1 to 1 which is ofcourse not an angle.
The car debug app that comes with assetto corsa does show steer angle per wheel in degrees in the suspension graph tab, so I'm wondering if anyone has a clue as to where this info is retrieved from?

Or where could I find the 'car debug' app so I could look at the code?

Thanks
Q
 

Attachments

  • ACSharedMemoryDocumentation.pdf
    101.5 KB · Views: 903
Problem I'm having is that the steerangle shows values from -1 to 1 which is ofcourse not an angle.
I've never looked much at the shared memory, and (annoyingly) the documentation doesn't define what you get in that float.
Or where could I find the 'car debug' app so I could look at the code?
All of the built-in apps are truly built into the executable, as far as I'm aware, so there's simply no Python code available to see.
The car debug app that comes with assetto corsa does show steer angle per wheel in degrees in the suspension graph tab, so I'm wondering if anyone has a clue as to where this info is retrieved from?
Not sure where the app gets it, but if you look at the Python docs for AC apps you will see that you can use ac.getCarState() to get "Steer, Radians of steer rotation [-2pi,2pi]", which may be good enough to meet your needs (despite +/- 2 pi sounding a little smaller than I'd have expected).
I can't recall if I've ever personally checked that value though, and not all of the things mentioned in the Python docs actually work properly... [edit: I just checked some old data dumps and that field does indeed look sensible]
 
Last edited:
I don't if this will help or not, but it sounds very similar to an issue I had with the telemetry in AMS2. The 'steer' metric was simply a ratio of the steering joystick axis, so -1 was fully counterclockwise and +1 was full clockwise. To add to the confusion, the documentation was never clear if wheel meant steering wheel or tyre wheel. To get the angle of the steering wheel, I had to determine the max rotation in the game settings. To get the angle of the tyre relative to the vehicle, I had to determine the steering ratio of the vehicle from the vehicle setup (I think this might be what ac.getCarState() is doing as it's quite low?). This was compounded a little by the fact that the left and right tyres won't have the same angle when turning, so I just decided to determine the 'average' between the two
 
Last edited:
To get the angle of the tyre relative to the vehicle, I had to determine the steering ratio of the vehicle from the vehicle setup (i think this might be what ac.getCarState() is doing?). This was compounded a little by the fact that the left and right tyres won't have the same angle when turning, so I just decided to determine the 'average' between the two
Ah yes this reminds me that in AC, you can ask for per-tyre data which appears to include the direction - see pic below for an excerpt from the Python docs. (Again, I'm not convinced I ever looked at this data, so it may or may not be as-described, and it may be relative to the world rather than the car, so the car orientation may need to be determined as well :))

Not sure if this is what the OP is after, or if it's truly the steering-wheel angle. Sounds like you actually wanted the angle of the tyre relative to the vehicle though?

1685356902219.png
 
Not sure if this is what the OP is after, or if it's truly the steering-wheel angle. Sounds like you actually wanted the angle of the tyre relative to the vehicle though?
Honestly, I didn't know what I wanted to start with :D. It was all a bit of a learning exercise.... I actually ended up just using -1/+1 as a ratio in MoTeC as generally all I seemed to care about was how much more or less, not a precise angle, but that only worked if the steering ratio in the car setup was the same.

I just checked and ACTI has a channel in MoTeC called 'Steering Angle' with units in degrees and I'm seeing values up to 90 deg in the logs I have available. It might be worth looking at the python part of that tool to see what it's doing to get the value.

 
I just checked and ACTI has a channel in MoTeC called 'Steering Angle' with units in degrees and I'm seeing values up to 90 deg in the logs I have available. It might be worth looking at the python part of that tool to see what it's doing to get the value.
Good idea. I just had a quick peek though and it seems like the relevant bit of work may be done within an EXE :unsure:
 
Ah yes this reminds me that in AC, you can ask for per-tyre data which appears to include the direction - see pic below for an excerpt from the Python docs. (Again, I'm not convinced I ever looked at this data, so it may or may not be as-described, and it may be relative to the world rather than the car, so the car orientation may need to be determined as well :))

Not sure if this is what the OP is after, or if it's truly the steering-wheel angle. Sounds like you actually wanted the angle of the tyre relative to the vehicle though?

View attachment 667905
Yeah I saw that data initially but I'm not smart enough to make anything of it. They seem to be relative to the world.
I do have a car heading value so how do you think I would go about getting the angle ? Just substracting/adding the value of the tyreHeading from/to the car heading?

I need the angle (either the wheel or general steering angle) for following reason:

I'm making a simple motion platform and basically I need Gforce to the side.
I know there's AccG in the telemetry, but this is in fact just the acceleration force, and not the Gforce.
For example, when you are static on the banked curve in old Monza, the Gforce provided by assetto corsa is centered, whereas I expect the lateral Gforce to show a force to the side due to the bank, causing my motion platform to bank.

I know I can calculate that force when static, since I know the acceleration to earth is 1G or 9.81 m/s² :
Centrifugal force calculation.jpg


So when standing still, I can use this value.

When driving however, I need to be able to calculate the centrifugal/centripetal force to be able to determine wheter the resultant force causes a bank, or if the lateral forces (centripetal/-fugal) are cancelling eachother out, causing the motion platform to be level.

To calculate this force I need to calculate the radius.
To calculate the radius I'd need the steering angle. (it also requires the base of the car but this is just an approximation of the average car since I don't have the live data for "base of car" available from assetto corsa)

Hope this clears it up a bit :)
 
Last edited:
Honestly, I didn't know what I wanted to start with :D. It was all a bit of a learning exercise.... I actually ended up just using -1/+1 as a ratio in MoTeC as generally all I seemed to care about was how much more or less, not a precise angle, but that only worked if the steering ratio in the car setup was the same.

I just checked and ACTI has a channel in MoTeC called 'Steering Angle' with units in degrees and I'm seeing values up to 90 deg in the logs I have available. It might be worth looking at the python part of that tool to see what it's doing to get the value.

I'll have a look at it when I get a chance, but I think I'll start digging in the python docs and see if I manage to get python code into c# or make an app to communicate this to my c# program
 
I know there's AccG in the telemetry, but this is in fact just the acceleration force, and not the Gforce.
I use that metric in both AMS2 and GT7 to derive the G forces for MoTeC on the car by simply dividing them by 9.8. This doesn't give the gravity component as you rightly point out, but I was looking at the other metrics and noticed it gives you the roll and pitch. Do these correctly reflect the attitude of the vehicle when stationary on a banked corner? If so, it feels like it might be easier to simply use a bit of trig with those for the gravity component away from directly upright.
 
I use that metric in both AMS2 and GT7 to derive the G forces for MoTeC on the car by simply dividing them by 9.8. This doesn't give the gravity component as you rightly point out, but I was looking at the other metrics and noticed it gives you the roll and pitch. Do these correctly reflect the attitude of the vehicle when stationary on a banked corner?
I maybe worded it a bit wrong: the AccG is an acceleration which can be formed into a G value, but the problem is that it doesn't give the constant Gforce you feel when you're for example standing still on a sloped surface. So I figured I could calculate this using the above procedure.

As for the pitch/bank, they also give some vague number.
I looked at wikipedia for Spa and there it states:
"Eau Rouge and Raidillon in 1997, with a maximum gradient in excess of 18%"
18% which is approx 9,65 degrees.

So I took this value and compared it to what I got in the sim.
For example, Spa Raidillon I get a value of 0.15 for both pitch and roll. (for roll I mean when I turn the car perpendicular to the track, to confirm roll uses the same value structure as pitch)
To get to the 9.65 degrees I just divide by 0.15 (sim value) and multiply by 9.65 (target degrees) OR multiply by 64 (which is 9.65/0.15 )

I double checked with Batthurst which has an approx slope of 17% on the steepest part and it matches, so this is my approximation of the sim value for pitch and roll.

If so, it feels like it might be easier to simply use a bit of trig with those for the gravity component away from directly upright.
That's indeed what I'm trying to do, but I need to account for centrifugal force to see how much I need to offset the gravity component.
At a standstill it's fairly easy, only when the car is moving I need to know the centrifugal force, for which I need radius etc.

Thanks!
 
Last edited:
For example, Spa Raidillon I get a value of 0.15 for both pitch and roll. (for roll I mean when I turn the car perpendicular to the track, to confirm roll uses the same value structure as pitch)
To get to the 9.65 degrees I just divide by 0.15 (sim value) and multiply by 9.65 (target degrees) OR multiply by 64 (which is 9.65/0.15 )
hmmm... it might be simply in radians....

0.15 radians is approx 8.16 degrees - bit less than your 9.65 though.... :unsure:
 
At a standstill it's fairly easy, only when the car is moving I need to know the centrifugal force, for which I need radius etc.
ok, I'm surprised you cannot just use the acceleration axis (probably the X) to figure that out. I'm guessing it does not report the correct acceleration during cornering?
 
one thing that might be important, for GT7 I had to rotate the acceleration into local space first (i.e. relative to the vehicle, not the track). The AC one says it's local, but maybe that is not correct?
 
hmmm... it might be simply in radians....

0.15 radians is approx 8.16 degrees - bit less than your 9.65 though.... :unsure:

well...
...but I'm not smart enough to make anything of it...
is as valid as it was back then. I think you're right. The approximation I did was based on a wikipedia article, so maybe not on the part of track I was standing on, so I'll consider them radians

ok, I'm surprised you cannot just use the acceleration axis (probably the X) to figure that out. I'm guessing it does not report the correct acceleration during cornering?
as per above, I can absolutely use this. Was just blind to the option and it works exactly as I wanted it to.

Using a crude version of the software I made but as you can see it works with your idea:

roll.jpg



Thanks everyone in this thread for the help, solution was very simple with the given data and your suggestions! :):)
 

Latest News

Do you prefer licensed hardware?

  • Yes for me it is vital

  • Yes, but only if it's a manufacturer I like

  • Yes, but only if the price is right

  • No, a generic wheel is fine

  • No, I would be ok with a replica


Results are only viewable after voting.
Back
Top