Difference between revisions of "OutSim"
From LFS Manual
Jump to navigationJump to search| (5 intermediate revisions by 2 users not shown) | |||
| Line 1: | Line 1: | ||
| − | + | {{see also|OutGauge}} | |
| − | OutSim is a | + | '''OutSim''' is a protocol which allows motion simulator support in LFS. More information can be found in the file {{folder|LFS|doc|InSim.txt}} and {{folder|LFS|doc|OutSimPack.txt}}. |
| + | |||
| + | == Configuration == | ||
| + | |||
| + | To instruct LFS to send OutSim packets, update this section of your {{folder|LFS|cfg.txt}} file: | ||
| + | |||
| + | <big><pre>// OutSim Mode 0 :0-off 1-driving 2-driving+replay | ||
| + | // OutSim Delay 1 :minimum delay between packets (100ths of a sec) | ||
| + | // OutSim IP 0.0.0.0 :IP address to send the UDP packet | ||
| + | // OutSim Port 0 :IP port | ||
| + | // OutSim ID 0 :if not zero, adds an identifier to the packet</pre></big> | ||
| + | |||
| + | == Example == | ||
| + | |||
| + | Here is an example of receiving OutSim packets using Python. | ||
| + | |||
| + | <big><pre>import socket | ||
| + | import struct | ||
| + | |||
| + | # Create UDP socket. | ||
| + | sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) | ||
| + | |||
| + | # Bind to LFS. | ||
| + | sock.bind(('127.0.0.1', 30000)) | ||
| + | |||
| + | while True: | ||
| + | # Receive data. | ||
| + | data = sock.recv(256) | ||
| + | |||
| + | if not data: | ||
| + | break # Lost connection | ||
| + | |||
| + | # Unpack the data. | ||
| + | outsim_pack = struct.unpack('I12f3i', data) | ||
| + | time = outsim_pack[0] | ||
| + | angvel = [outsim_pack[1], outsim_pack[2], outsim_pack[3]] | ||
| + | header = outsim_pack[4] | ||
| + | pitch = outsim_pack[5] | ||
| + | roll = outsim_pack[6] | ||
| + | accel = [outsim_pack[7], outsim_pack[8], outsim_pack[9]] | ||
| + | vel = [outsim_pack[10], outsim_pack[11], outsim_pack[12]] | ||
| + | pos = [outsim_pack[13], outsim_pack[14], outsim_pack[15]] | ||
| + | |||
| + | # Release the socket. | ||
| + | sock.close()</pre></big> | ||
| + | |||
| + | == See also == | ||
| + | |||
| + | * [[InSim]] | ||
| + | * [[OutGauge]] | ||
| + | |||
| + | [[Category:Programming]] | ||
Latest revision as of 10:59, 11 February 2026
See also: OutGauge
OutSim is a protocol which allows motion simulator support in LFS. More information can be found in the file LFS\doc\InSim.txt and LFS\doc\OutSimPack.txt.
Configuration
To instruct LFS to send OutSim packets, update this section of your LFS\cfg.txt file:
// OutSim Mode 0 :0-off 1-driving 2-driving+replay // OutSim Delay 1 :minimum delay between packets (100ths of a sec) // OutSim IP 0.0.0.0 :IP address to send the UDP packet // OutSim Port 0 :IP port // OutSim ID 0 :if not zero, adds an identifier to the packet
Example
Here is an example of receiving OutSim packets using Python.
import socket
import struct
# Create UDP socket.
sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
# Bind to LFS.
sock.bind(('127.0.0.1', 30000))
while True:
# Receive data.
data = sock.recv(256)
if not data:
break # Lost connection
# Unpack the data.
outsim_pack = struct.unpack('I12f3i', data)
time = outsim_pack[0]
angvel = [outsim_pack[1], outsim_pack[2], outsim_pack[3]]
header = outsim_pack[4]
pitch = outsim_pack[5]
roll = outsim_pack[6]
accel = [outsim_pack[7], outsim_pack[8], outsim_pack[9]]
vel = [outsim_pack[10], outsim_pack[11], outsim_pack[12]]
pos = [outsim_pack[13], outsim_pack[14], outsim_pack[15]]
# Release the socket.
sock.close()