PiBoSo Official Forum

GP Bikes => Mods => Plugins => Topic started by: Gurchur on July 12, 2018, 07:03:37 PM

Title: Trying to understand how plugin works
Post by: Gurchur on July 12, 2018, 07:03:37 PM
Hi everyone!! I am new in the forum and a new user of GPB.

I am doing a simulator of 3 axis but before knowing that GPB exists I only has in mind to create the analog signals from the encoders and sensors and make a bypass thow a joystick to control MotoGP. Now that I played GPB, the new potencial is huge and I woul like to get the data from the simulator to a program to control the motors.

The problem is that I do not understand well how comunicate with the .dll I created using the GPB_example.c

This is what I have done for the moment:

    1) I just created the .dll using labview CVI (is very similar to visual studio) using the GPB_example.c and creating a new .h with all the function names (but removing the "_declspec(dllexport)" .With both files I could create the .dll, copy it in the PlugIn folder of GPB and renamed as .DLO.
       When I go to the track the game suddenlly exit then I expect I am missing something (or all!! :).

       Regarding the custom program I need to do to get the data,  do I just make calls to the functions of the .dll or how I do that??, I really do not understand it, if anyone has any example of a program communicating continueslly with the GPB in .C and getting for example the spped of the bike would be a huge help and I believe I could start.

Many thanks for your help!!!




Title: Re: Trying to understand how plugin works
Post by: speedfr on July 12, 2018, 09:26:04 PM
Hello,

this kind of question is either for h106frp (who did the exact same process for catching FFB) and/or HornetMax who is the author of MaxHUD (overlay ingame) and MaxTM (telemetry).

Keep up  !!
Title: Re: Trying to understand how plugin works
Post by: Gurchur on July 13, 2018, 06:50:25 AM
Many thanks Speedfr, I hope they (the master programmers  8) 8))  read the post and guide me a little  ;D

Title: Re: Trying to understand how plugin works
Post by: HornetMaX on July 13, 2018, 09:33:07 AM
Why are you removing the "_declspec(dllexport)" ? Without that I'm not sure the .dll will be correctly built.

I'm not familiar with the compiler you are using, it may have a different syntax to declare the function to export, but you'll have to do this one way or the other.
I use Visual Studio.

Also, assuming you want to send GPB output values (e.g. bike lean and pitch) to your external device, I'd probably think about using the proxy approach (proxy.dlo writes to a memory area and your external program can read from that from outside GPB, not from "inside" as with an output plugin).

Maybe h106frp can be of more help on this.
Title: Re: Trying to understand how plugin works
Post by: h106frp on July 13, 2018, 09:57:49 AM
I built my interface using the Proxy dlo.
The compiled proxy.dlo (I used codeblocks C for this) returns a handle to the shared memory area that you have created and I then used Visual Studio C++ to read from the shared memory space and manipulate the values before I sent them to my device
Title: Re: Trying to understand how plugin works
Post by: HornetMaX on July 13, 2018, 10:03:52 AM
Quote from: h106frp on July 13, 2018, 09:57:49 AM
I built my interface using the Proxy dlo.
The compiled proxy.dlo (I used codeblocks C for this) returns a handle to the shared memory area that you have created and I then used Visual Studio C++ to read from the shared memory space and manipulate the values before I sent them to my device
Curiosity: why do you need to compile proxy.dlo ? It comes with GPB no ?
Title: Re: Trying to understand how plugin works
Post by: Gurchur on July 13, 2018, 11:47:11 AM
Many thanks!!! for your answers.

I will use the proxy example as I did not know that in the other way was internal. I will try this afternoon checking the handle to the memory area. I will feedback you very soon.

Again +1000!!  ;D ;D
Title: Re: Trying to understand how plugin works
Post by: HornetMaX on July 13, 2018, 11:48:35 AM
Last comment: if your device needs to send signals to GPB, you may have to look at an input plugin too.
Title: Re: Trying to understand how plugin works
Post by: h106frp on July 13, 2018, 01:27:17 PM
Quote from: HornetMaX on July 13, 2018, 10:03:52 AM
Quote from: h106frp on July 13, 2018, 09:57:49 AM
I built my interface using the Proxy dlo.
The compiled proxy.dlo (I used codeblocks C for this) returns a handle to the shared memory area that you have created and I then used Visual Studio C++ to read from the shared memory space and manipulate the values before I sent them to my device
Curiosity: why do you need to compile proxy.dlo ? It comes with GPB no ?

I guess I just wanted to be sure my data structures would agree and was not completely sure if the demo code was a direct example of the current proxy.dlo

It did not take long to do anyway.
Title: Re: Trying to understand how plugin works
Post by: HornetMaX on July 13, 2018, 01:34:29 PM
Quote from: h106frp on July 13, 2018, 01:27:17 PM
I guess I just wanted to be sure my data structures would agree and was not completely sure if the demo code was a direct example of the current proxy.dlo
Had this doubt too but Pib confirmed the .dlo comes from the source code he publishes.
But why the different compiler ?

Title: Re: Trying to understand how plugin works
Post by: Gurchur on July 13, 2018, 04:02:40 PM
I am trying to create the proxi dll but  "direct.h"  file is missing, do you know from where I can get it?

Many thanks!!
Title: Re: Trying to understand how plugin works
Post by: HornetMaX on July 13, 2018, 05:07:36 PM
Quote from: Gurchur on July 13, 2018, 04:02:40 PM
I am trying to create the proxi dll but  "direct.h"  file is missing, do you know from where I can get it?

Many thanks!!
It's a windows/microsoft file. If your compiler does not provide it, it may use a different header for the very same functions. Google around.
Title: Re: Trying to understand how plugin works
Post by: h106frp on July 13, 2018, 08:11:50 PM
Quote from: HornetMaX on July 13, 2018, 01:34:29 PM
Quote from: h106frp on July 13, 2018, 01:27:17 PM
I guess I just wanted to be sure my data structures would agree and was not completely sure if the demo code was a direct example of the current proxy.dlo
Had this doubt too but Pib confirmed the .dlo comes from the source code he publishes.
But why the different compiler ?

It was just very easy to build it in codeblocks  :)
Title: Re: Trying to understand how plugin works
Post by: Gurchur on August 15, 2018, 06:14:52 PM
Hi Guys!!

I found some time and I finally developed the Code to interface with GPBikes. Thanks to all you its working great but I have some questions and doubts that maybe you have the answer:

1: Pitch-Yaw-Roll angles: they seems to be changed as Pitch is giving me the suposed Roll angle (lean) and the Yaw is giving me the Picth.  Also the Roll is giving me back huge angles (similar yo the Picth data), do you know why could be?
2: the speed: I tried to take the bike speed from Xvelocity and YVelocity but do not macth the one the game is marking. Then I used the FWheelSpeed and the speed seems to be similar but 10% lower, strange.
3: Gear: the m_iGear integer gives me a number that its changing all the time, no matter the Gear used (10950188675 and similar)
4: Steer: this variable changes from 0 to 1 and some times It's value is between (0,1) do It relates with the Steer forces or position?
5: Steer Torque: its always giving 1,4238. This should be moving?

Thats all!!! Many thanks for your help!!! In 1 month I Will start with the hardware, I am really exited about It!!

Many thanks!!

Title: Re: Trying to understand how plugin works
Post by: h106frp on August 15, 2018, 07:23:44 PM
Are you using shared memory space? if so it is most likely that the variable sizes (bytes) that you have declared do not match the ones defined.
Title: Re: Trying to understand how plugin works
Post by: Gurchur on August 22, 2018, 08:21:15 PM
Many thanks!! Yes, I believe has to be something similar. I will investigate as I believe can be related with the int size for Windows 64 bits that is 4 bytes not 2 bytes. I will feedback you with the resulta.  :)

Title: Re: Trying to understand how plugin works
Post by: HornetMaX on August 22, 2018, 08:27:39 PM
Quote from: Gurchur on August 22, 2018, 08:21:15 PM
Many thanks!! Yes, I believe has to be something similar. I will investigate as I believe can be related with the int size for Windows 64 bits that is 4 bytes not 2 bytes.
Surely not that, int size is 32bit in both x32 and x64 windows.

You're likely messing up with pointers or data layout.