The online racing simulator
Outsim pitch and roll
(9 posts, started )
Outsim pitch and roll
For some reason I think I've decided I might be competent enough to write a little python app that stabilizes the camera relative to the world, and after doing some searches I've ended up a tad confused about the pitch and roll values. Are they relative to the car body, the velocity vector, or the world?
I've not played with OutSim for some time but they should be relative to the angle of the road the vehicle is currently travelling on. Edit: I after reading detail's reply, I thought OutSim gave you body roll rather than camera roll (which is what you're trying to set)?

To your idea, that is the camera that I have used in my little car sim at work, it does give a very different feeling to what LFS and others give, especially when realistic road going setups are used.
Let me reply basing just on my memory: In LFS settings you can set camera heading and pitch relative to car body. So I assume they are relative to car body as well.
Oohh, got it working!


import struct, socket, os, math

is_isi = struct.Struct('BBBBHHBBH16s16s')
is_ver = struct.Struct('BBBB8s6sH')
is_cpp = struct.Struct('BBBB3lHHHBBfHH')
is_tiny = struct.Struct('BBBB')
is_small = struct.Struct('BBBBL')
outsimpack = struct.Struct('I3ffff3f3f3L')

config = open('camlevel_cfg.txt', 'r')
insimport = int(config.readline())
outsimport = int(config.readline())
pitch_multi = float(config.readline())
roll_multi = float(config.readline())
average_window = int(config.readline())
average_multi = float(config.readline())
camera_average = int(config.readline())
config.close()

pitch_list = [0]*average_window
roll_list = [0]*average_window

socket.setdefaulttimeout(10)

insim = socket.socket()
insim.connect(('127.0.0.1',insimport))
insim.send(is_isi.pack(44,1,0,0,outsimport,0,0,0,0,'','CamLevel'))
insim.send(is_small.pack(8,4,0,1,1))
outsim = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
outsim.bind(('127.0.0.1',outsimport))
while True:
try:
pitch, roll = (outsimpack.unpack(outsim.recv(64))[5:7])
pitch, roll = math.degrees(pitch),math.degrees(roll)
del pitch_list[0]
pitch_list.append(pitch)
del roll_list[0]
roll_list.append(roll)
pitch = pitch - (sum(pitch_list) / average_window)*average_multi
roll = roll - (sum(roll_list) / average_window)*average_multi
pitch, roll = pitch * pitch_multi, roll * roll_multi
pitch = int(pitch * 182.044444444444)
roll = int(roll * 182.0444444444)
if pitch < 0:
pitch = -pitch
else:
pitch = 65535 - pitch
if roll < 0:
roll = -roll
else:
roll = 65535 - roll
insim.send(is_cpp.pack(32,9,0,0,0,0,0,21,pitch,roll,
255,255,90.0,camera_average,8192))
except socket.timeout:
insim.send(is_small.pack(8,4,0,1,0))
insim.send(is_small.pack(8,4,0,1,1))
pitch_list = [0]*average_window
roll_list = [0]*average_window

What language is this?
Looks like python.
He said it's Python in the first post.
Anyone make it in C/Arduino??

Outsim pitch and roll
(9 posts, started )
FGED GREDG RDFGDR GSFDG