README.md 4.05 KB
Newer Older
SimRacingStudio's avatar
SimRacingStudio committed
1 2 3
# srsapi
This respository contains a set of examples on how to interact with the Sim Racing Studio (http://www.simracingstudio.com) API and lowlevel API (lla) using C# or Python 3.

SimRacingStudio's avatar
SimRacingStudio committed
4 5 6
Check out this step by step tutorial to get started with Unity3D and SRS:
https://gitlab.com/simracingstudio/srsapi/-/wikis/Getting-started-with-Unity3D-and-SRS

SimRacingStudio's avatar
SimRacingStudio committed
7
## What are the requirements to run the example
SimRacingStudio's avatar
SimRacingStudio committed
8
Sim Racing Studio App >=1.43.2 (Download it from https://www.simracingstudio.com/download)
SimRacingStudio's avatar
SimRacingStudio committed
9 10

## What is the difference between the API and Lowlevel API?
SimRacingStudio's avatar
Fix #1  
SimRacingStudio committed
11
The API allows full control of motion, shakers, wind and tachometer, it's very useful for simulation of vehicles, .
SimRacingStudio's avatar
SimRacingStudio committed
12

SimRacingStudio's avatar
Fix #1  
SimRacingStudio committed
13
The lowlevel api allows the developer control wind sim left and right fans individually from 0 to 100%.
SimRacingStudio's avatar
SimRacingStudio committed
14 15 16

## What the api example does?
It opens a socket and broadcasts the telemetry packets to the simracingstudio app
SimRacingStudio's avatar
Fix #1  
SimRacingStudio committed
17
For example the speed goes from 0 to 200 and from 200 to 0.
SimRacingStudio's avatar
SimRacingStudio committed
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37

## What the lowlevel api (lla) example does?
This example opens a socket and broadcasts the telemetry packets to the simracingstudio app
The fan power goes from 0 to 100 and from 100 to 0, and reverse in each side.

## How to run using C#?
* Using Visual Studio
* Create a new console application
* Replace the default Program.cs by the Program.cs from this repository
* Build and Execute

## How to run using Python:
* Download and install python 3
* Clone this repository
* Open the a command window and point to the location where the repository has been cloned
* Execute the follow command: python main.py

## API Definition
| Field | C Type | Description | Expected Value |
| --- | --- | --- | --- | 
SimRacingStudio's avatar
Fix #1  
SimRacingStudio committed
38 39 40 41 42
| api_mode | char*3 | API Header packet | constant: api |
| version | uint8 | API version packet | 102 |
| game | char*50 | Game sending telemetry | Example: Project Cars 2 | 
| vehicle_name | char*50 | Car, Boat or aircraft name | Example: Lamborghini Huracan | 
| location | char*50 | Airport code or Track name | Circuit Gilles-Villeneuve |
SimRacingStudio's avatar
SimRacingStudio committed
43
| speed | float | Wind Speed | 0 to 400 does not matter if km/h, m/s or mph, app is smart to learn automatically | 
44 45
| rpm | float | Engine Current RPM | 0 to 32000 |
| max_rpm | float | Engine Max RPM for SLI | 0 to 32000 |
SimRacingStudio's avatar
SimRacingStudio committed
46
| gear | int8 | Vehicle/Plane Gear | -1 = revere 0=Neutral 1 to 9=gears |
SimRacingStudio's avatar
Fix #1  
SimRacingStudio committed
47 48 49
| pitch | float | Pitch | in degrees -180 to +180 |
| roll | float | Roll | in degrees -180 to +180 |
| yaw | float | Yaw | in degrees -180 to +180 |
50
| lateral_velocity | float | used for traction loss | in float between -10 to 10 |
SimRacingStudio's avatar
SimRacingStudio committed
51 52 53
| lateral_acceleration | float | lateral gforce (sway)  | float values beteween -100 to 10 |
| vertical_acceleration | float | vertical gforce (heave) | float values beteween -10 to 10 |
| longitudinal_acceleration | float | longitudinal gforce (surge) | float values beteween -10 to 10 |
SimRacingStudio's avatar
Fix #1  
SimRacingStudio committed
54 55 56 57 58 59 60 61 62 63
| suspension_travel_front_left | float | Suspension Travel FL | in float values -10 to 10 |
| suspension_travel_front_right | float | Suspension Travel FR | in float values -10 to 10 |
| suspension_travel_rear_left | float | Suspension Travel RL | in float values -10 to 10 |
| suspension_travel_rear_right | float | Suspension Travel RR | in float values -10 to 10 |
| wheel_terrain_front_left | uint8 | Wheel Terrain Contact Type FL |  0=all others, 1=rumble strip, 2=asphalt |
| wheel_terrain_front_right | uint8 | Wheel Terrain Contact Type FR |  0=all others, 1=rumble strip, 2=asphalt |
| wheel_terrain_rear_left | uint8 | Wheel Terrain Contact Type RL |  0=all others, 1=rumble strip, 2=asphalt |
| wheel_terrain_rear_right | uint8 | Wheel Terrain Contact Type RR |  0=all others, 1=rumble strip, 2=asphalt |


SimRacingStudio's avatar
SimRacingStudio committed
64 65 66 67 68 69

## Lowlevel API Definition
| Field | C Type | Description | Expected Value |
| --- | --- | --- | --- | 
| api_mode | char*3 | API Header packet | constant: lla | 
| version | uint8 | API version packet | 101 |
SimRacingStudio's avatar
SimRacingStudio committed
70
| left_fan_power | float | Power in % of left fan | 0 to 100 | 
SimRacingStudio's avatar
SimRacingStudio committed
71
| right_fan_power | float | Power in % of right fan | 0 to 100 |
72 73
| rpm | float | Engine Current RPM | 0 to 32000 |
| max_rpm | float | Engine Max RPM for SLI | 0 to 32000 |
SimRacingStudio's avatar
SimRacingStudio committed
74 75
| gear | int8 | Vehicle/Plane Gear | -1 = revere 0=Neutral 1 to 9=gears |