1. This Software is no longer supported by us. Please download the new motion control software SimTools.
    Dismiss Notice
  2. Do not share user accounts! Any account that is shared by another person will be blocked and closed. This means: we will close not only the account that is shared, but also the main account of the user who uses another person's account. We have the ability to detect account sharing, so please do not try to cheat the system. This action will take place on 04/18/2023. Read all forum rules.
    Dismiss Notice
  3. For downloading SimTools plugins you need a Download Package. Get it with virtual coins that you receive for forum activity or Buy Download Package - We have a zero Spam tolerance so read our forum rules first.

    Buy Now a Download Plan!
  4. Do not try to cheat our system and do not post an unnecessary amount of useless posts only to earn credits here. We have a zero spam tolerance policy and this will cause a ban of your user account. Otherwise we wish you a pleasant stay here! Read the forum rules
  5. We have a few rules which you need to read and accept before posting anything here! Following these rules will keep the forum clean and your stay pleasant. Do not follow these rules can lead to permanent exclusion from this website: Read the forum rules.
    Are you a company? Read our company rules

OutSim problem (Urgent!)

Discussion in 'Force-Sender & Plugins' started by ZachGriffin, Aug 18, 2009.

  1. ZachGriffin

    ZachGriffin New Member

    Joined:
    Jun 25, 2009
    Messages:
    5
    Balance:
    - 10Coins
    Ratings:
    +0 / 0 / -0
    Hi, I'm trying to make our sim send out LFS compatible UDP. But our test program just produces rubbish when sending to the 'outsim' plugin exe.
    As you can see we're setting a few static values to make sure the packet sizes and data lengths are ok. They seem to be.
    Can someone look at our code and test our app with the outsim.exe program? (No need to load x-sim)
    I'm sure it's something trivial.
    Thanks.

    Single exe file here
    http://users.on.net/~edan/games/KartSim ... Stream.zip

    thread at Raknet forums (Not sure if it's me or the net lib I use)
    http://www.jenkinssoftware.com/raknet/f ... 5#msg13355

    Code:
    #include RakPeerInterface.h
    #include RakNetworkFactory.h
    #include BitStream.h
    #include RakSleep.h
    #include <stdlib.h> // For atoi
    #include <cstring> // For strlen
    #include <stdio.h>
    #include <string.h>
    #include GetTime.h
    #include SocketIncludes.h
    #include SocketLayer.h
    
    #include Kbhit.h
    
    using namespace RakNet;
    char text[255];
    int rawSocket;
    
    // Motion simulator test
    struct OutMotion
    {
    	unsigned int time;	// time in milliseconds (to check order)
    
    	float angularVelocityX;		// 3 floats, angular velocity vector
    	float angularVelocityY;		// 3 floats, angular velocity vector
    	float angularVelocityZ;		// 3 floats, angular velocity vector
    
    	float	heading;	// anticlockwise from above (Z)
    	float	pitch;		// anticlockwise from right (X)
    	float	roll;		// anticlockwise from front (Y)
    
    	float	accelerationX;		// 3 floats X, Y, Z
    	float	accelerationY;		// 3 floats X, Y, Z
    	float	accelerationZ;		// 3 floats X, Y, Z
    
    	float	velocityX;		// 3 floats X, Y, Z
    	float	velocityY;		// 3 floats X, Y, Z
    	float	velocityZ;		// 3 floats X, Y, Z
    
    	int positionX;
    	int positionY;
    	int positionZ;
    
    	int		ID;			// optional - only if OutSim ID is specified
    };
    
    int main(void)
    {
    	unsigned short port = 4123;
    	unsigned short ps3 = 0;
    
    	rawSocket = SocketLayer::Instance()->CreateBoundSocket(port+10000, true, 127.0.0.1, 0);
    	printf(Socket opened = %i\n,rawSocket);
    
    	unsigned int startTime = RakNet::GetTime();
    
    	printf(sending data);
    	while (true)
    	{
    		OutMotion outMotion;
    		BitStream outgoingBitstream;
    
    		unsigned int raknetTime = RakNet::GetTime() - startTime;
    		float mover = ((float)raknetTime)/1000.0f;
    
    		printf(Time = %i : Mover = %f\n, raknetTime, mover);
    
    		outMotion.time = raknetTime;
    
    		outMotion.angularVelocityX = mover;
    		outMotion.angularVelocityY = mover;
    		outMotion.angularVelocityZ = mover;
    
    		outMotion.heading = mover;
    		outMotion.pitch = mover;
    		outMotion.roll = mover;
    
    		outMotion.accelerationX = mover;
    		outMotion.accelerationY = mover;
    		outMotion.accelerationZ = mover;
    
    		outMotion.velocityX = mover;
    		outMotion.velocityY = mover;
    		outMotion.velocityZ = mover;
    
    		outMotion.positionX = 0;
    		outMotion.positionY = 1;
    		outMotion.positionZ = 2;
    
    		outMotion.ID = 0;
    
    
    
    
    		outgoingBitstream.Write(raknetTime);
    
    		outgoingBitstream.Write(0.0f);
    		outgoingBitstream.Write((float)outMotion.angularVelocityY);
    		outgoingBitstream.Write((float)outMotion.angularVelocityZ);
    
    		outgoingBitstream.Write(outMotion.pitch);
    		outgoingBitstream.Write(0.0f);
    		outgoingBitstream.Write(outMotion.roll);
    
    		outgoingBitstream.Write(outMotion.accelerationX);
    		outgoingBitstream.Write(outMotion.accelerationY);
    		outgoingBitstream.Write(0.0f);
    
    		outgoingBitstream.Write(1.1f);
    		outgoingBitstream.Write(outMotion.velocityY);
    		outgoingBitstream.Write(1.2f);
    
    		outgoingBitstream.Write(outMotion.positionX);
    		outgoingBitstream.Write(outMotion.positionY);
    		outgoingBitstream.Write(outMotion.positionZ);
    
    		//outgoingBitstream.Write(outMotion.ID);
    
    		const char* data = (const char*)outgoingBitstream.GetData();
    		int length = (int) outgoingBitstream.GetNumberOfBytesUsed();
    		SocketLayer::Instance()->SendTo(rawSocket, data, length, 127.0.0.1, port, ps3);
    
    		RakSleep(200);
    	}
    
    	return 0;
    }
    
  2. ZachGriffin

    ZachGriffin New Member

    Joined:
    Jun 25, 2009
    Messages:
    5
    Balance:
    - 10Coins
    Ratings:
    +0 / 0 / -0
    Solved it :) It was an Endian swapping problem.
  3. ZachGriffin

    ZachGriffin New Member

    Joined:
    Jun 25, 2009
    Messages:
    5
    Balance:
    - 10Coins
    Ratings:
    +0 / 0 / -0
    We're currently developing KartSim which you may have heard of. I've put a few screenshots of it below.

    [​IMG]
    [​IMG]
    [​IMG]
    [​IMG]

    We've now successfully connected it to X-Sim so we'll play around with the settings a bit more to get it feeling right. A few issues we've had pop up which seem to be quite strange are the slow down after X-Sim has been run once and also the stepping of the SCN5 actuators.

    The slow down we've isolated to be either X-Sim or the FTDI drivers; we're not sure which. Using Windows 7 build 7100, if we system restore to before x-sim was first run, KartSim and other games (TrackMania is another) run perfectly. However as soon as X-Sim is run the games slow right down with KartSim going from around 80fps to ~20fps. Having a look at the KartSim process, the affinity is always set to 1 processor instead of the usual 2 so we suspect that X-Sim might be trying to manage the affinity of different processes which causes Windows 7 to slow down D3D applications? The other possibility is that X-Sim when calling the FTDI drivers causes a slowdown although I haven't seen any issues with FTDI drivers after searching through forums. Has this been tested? Is X-Sim modifying the affinity of the processes? Once it has been run and the slowdown occurs, even running the game directly without X-Sim running will cause a slowdown. The only remedy so far is to system restore to before X-Sim was first run.

    The other issue we've had which I suspect is just a setting we are missing is the stepping of the SCN5 actuators. With the Frex system we were able to get quite smooth movement from the actuators whereas now accessing them directly using nbglin USB-RS485 converters, the movement is quite jerky. The position seems to jump as opposed to moving up or down smoothly. Is there a setting within X-Sim that would fix this? The current settings are as per the forum post on converting a Frex system to X-Sim. We have tried playing around with the speed and acceleration values although the jerkiness is still there. Could this be something to do with slow down issue above?

    Apart from those, X-Sim has been quite powerful and the support has been great so we're looking forward to using it more. If we develop any specific math plugins we'll be sure to post them up here.
  4. ZachGriffin

    ZachGriffin New Member

    Joined:
    Jun 25, 2009
    Messages:
    5
    Balance:
    - 10Coins
    Ratings:
    +0 / 0 / -0
    Ok great, I should be able to get the movement smooth then. We'll have another go next week. We always used 2 computers using the FD 301 so will do the same with this as well.

    The affinity problem we will change which should fix it changing to 1 processor. We are using the 32bit version of Windows 7 so it sounds as though that is the problem. It is strange though that once x-sim has been run once, then even with a reboot DX applications are much slower even without X-Sim running. It seems as tho its making changes to the registry?

    Thanks for your help. It's much appreciated.