If LFS sends OutSim and OutGauge packages at the same time, jinsim mixes them up.
Relevant code fragments of my test:
...
client.enableOutGauge(100);
client.enableOutSim(100);
...
public void packetReceived(InSimResponse response) {
System.out.println(response.toString());
...
Consol shows only OutSim packages in pairs, every second data has garbage values in it. (OutGauge packets are interpreted as OutSim packets.) Some other odd things too.
Console example (the car was standstill):
OutSim [time=3290300, angularVelocity= InSimVector[-1130721910, 993656001, -1161843557], heading= 2.5322294, pitch=-0.026719127, roll=0.026609631, acceleration=InSimVector[990450776, 981792519, -1178328408], velocity=InSimVector[0, 0, 0], position=InSimVector[3929634, 38656090, 862852], id=0
OutSim [time=3291050, angularVelocity= InSimVector[4674136, 180224, 0], heading= 0.0, pitch=0.0, roll=0.0, acceleration=InSimVector[1032542369, 0, 0], velocity=InSimVector[1894, 4, 0], position=InSimVector[0, 1065353216, 1818588486], id=0
OutSim [time=3291300, angularVelocity= InSimVector[-1130721910, 993656001, -1161843557], heading= 2.5322294, pitch=-0.026719127, roll=0.026609631, acceleration=InSimVector[990450776, 981792519, -1178328408], velocity=InSimVector[0, 0, 0], position=InSimVector[3929634, 38656090, 862852], id=0
OutSim [time=3292050, angularVelocity= InSimVector[4674136, 180224, 0], heading= 0.0, pitch=0.0, roll=0.0, acceleration=InSimVector[1032542369, 0, 0], velocity=InSimVector[1894, 4, 0], position=InSimVector[0, 1065353216, 1818588486], id=0
OutSim [time=3292300, angularVelocity= InSimVector[-1130721910, 993656001, -1161843557], heading= 2.5322294, pitch=-0.026719127, roll=0.026609631, acceleration=InSimVector[990450776, 981792519, -1178328408], velocity=InSimVector[0, 0, 0], position=InSimVector[3929634, 38656090, 862852], id=0
OutSim [time=3293050, angularVelocity= InSimVector[4674136, 180224, 0], heading= 0.0, pitch=0.0, roll=0.0, acceleration=InSimVector[1032542369, 0, 0], velocity=InSimVector[1894, 4, 0], position=InSimVector[0, 1065353216, 1818588486], id=0
I've found the solution.
This is what I wrote to the LFS forum:
Well maybe my above post was not clear enough. Lets say, it's becouse I'm not a native speaker, and I was tried.
Nevertheless, I found the solution. I think it's a bug in OutChannel.java.
So the problem is, if both OutSim and OutGauge packages are sent by LFS, jinsim will interpret both as OutSim packages. From the user perspective it makes virtually no OutGauge packages received, and every second OutSim packages contains incorrect values. (This second packages are the OutGauge packages, only jinsim process them as they were OutSim packages.)
My solution was to change the run method of OutChannel.java.
I deleted every buffer.slip(); lines, and inserted buffer.position(0); at the end of the two if section.
I think the problem with the original, that the buffer.flip of the if else section sets the buffer limit to 68 (the last package's size). So after this every buffer.position(); reading will give 68 and will never go into the first if.
I run LFS on a PC, and jinsim on a laptop, that runs Ubuntu and connected via wireless to the PC. Just for the record, but I don't think this is an issue.