1. 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
  2. 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!
  3. 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
  4. 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

Question Problems about writing a plugin

Discussion in 'SimTools Plugins' started by ZKILLA, May 31, 2017.

  1. ZKILLA

    ZKILLA Member

    Joined:
    Apr 5, 2017
    Messages:
    54
    Location:
    Australia
    Balance:
    417Coins
    Ratings:
    +7 / 0 / -0
    My Motion Simulator:
    SCN5, SCN6
    Hi guys, I got some problems when I tried to write a Simtools plugin, and I really stuck here and hope some one can help me to finish it.
    The thing is, this plugin is not about racing game or G force seat. I'm doing some project to build a device and in this project I need to control two SCN6 motors. I built a simulate model by Labview to generate UDP packets which contain the two numbers- the moving distance for two SCN6 motor. I'm using Simtools to control the two motors and what I need now is to write a plugin to receive the UDP packets and command the motors. I think the codes in the plugin should be relatively simple because all the information that I need in UDP packets are just two numbers and plugin just need to transfer the string to array and let the motors read those numbers and stretch the same length. And the UDP plugin sample that I found in this forum can already finish the function that transferring string data to byte array data. But the rest task is quite difficult to me because the plugin sample is quite long and complex and I'm really bad at coding. Can somebody teach me how to write a plugin to achieve the function that I mentioned above? Thank you guys.
  2. ZKILLA

    ZKILLA Member

    Joined:
    Apr 5, 2017
    Messages:
    54
    Location:
    Australia
    Balance:
    417Coins
    Ratings:
    +7 / 0 / -0
    My Motion Simulator:
    SCN5, SCN6
    Please please please
  3. yobuddy

    yobuddy Well-Known Member Staff Member Moderator SimAxe Beta Tester SimTools Developer Gold Contributor

    Joined:
    Feb 9, 2007
    Messages:
    5,162
    Occupation:
    Computer Technician
    Location:
    Portland, Oregon - USA
    Balance:
    48,171Coins
    Ratings:
    +5,037 / 16 / -0
    I'm not sure I understand what you are trying to do buddy.
    Where is the incoming data coming from?
    yobuddy
  4. ZKILLA

    ZKILLA Member

    Joined:
    Apr 5, 2017
    Messages:
    54
    Location:
    Australia
    Balance:
    417Coins
    Ratings:
    +7 / 0 / -0
    My Motion Simulator:
    SCN5, SCN6
    Thank you mate, thank you for your reply. I'll attach a picture to explain. This is what I'm using to generate data, this software names Labview, and it's a simulation program. So I used a simulation block here to generate some data and also a UDP block to transfer the UDP packets. What I want to do is write a plugin to catch those UDP packets data. It's totally the same as normal game plugin, only difference is I want to catch UDP packets from a simulation program, not a game. Any idea about this? Cheers buddy.
  5. ZKILLA

    ZKILLA Member

    Joined:
    Apr 5, 2017
    Messages:
    54
    Location:
    Australia
    Balance:
    417Coins
    Ratings:
    +7 / 0 / -0
    My Motion Simulator:
    SCN5, SCN6

    Attached Files:

  6. yobuddy

    yobuddy Well-Known Member Staff Member Moderator SimAxe Beta Tester SimTools Developer Gold Contributor

    Joined:
    Feb 9, 2007
    Messages:
    5,162
    Occupation:
    Computer Technician
    Location:
    Portland, Oregon - USA
    Balance:
    48,171Coins
    Ratings:
    +5,037 / 16 / -0
    Sure, no problem.
    I can't really see the pic to clearly, but all you need to do is send the udp data.
    And catch it with the plugin.

    Lets start like this:
    Send like this Roll,Pitch,Heave,Yaw,Sway,Surge in plain text. (you can use extra 1 thru 3 also if needed.)
    Then we just catch and parse the data with the plugin and assign the input to the appropriate DOF.

    Are you already sending data of some sort?
    yobuddy
  7. ZKILLA

    ZKILLA Member

    Joined:
    Apr 5, 2017
    Messages:
    54
    Location:
    Australia
    Balance:
    417Coins
    Ratings:
    +7 / 0 / -0
    My Motion Simulator:
    SCN5, SCN6
    Thanks for your reply buddy, actually I already captured some UDP packets just now by using a python code, which is attached with this post. This really makes me believe that the UDP packets is generated well! From the attachment you can see there are two numbers, and that are the exact distances that I want the motors to stretch.
    So do you mean that I can assign the outputs as Roll and Pitch directly? But how can I achieve that? From my side I think I just need to recognise the two numbers from UDP packets and set them as Roll and Pitch in the plugin, then assign them to the appropriate DOF, am I correct?
  8. ZKILLA

    ZKILLA Member

    Joined:
    Apr 5, 2017
    Messages:
    54
    Location:
    Australia
    Balance:
    417Coins
    Ratings:
    +7 / 0 / -0
    My Motion Simulator:
    SCN5, SCN6
    Forget attaching again:confused:

    Attached Files:

  9. yobuddy

    yobuddy Well-Known Member Staff Member Moderator SimAxe Beta Tester SimTools Developer Gold Contributor

    Joined:
    Feb 9, 2007
    Messages:
    5,162
    Occupation:
    Computer Technician
    Location:
    Portland, Oregon - USA
    Balance:
    48,171Coins
    Ratings:
    +5,037 / 16 / -0
    You basically catch the UDP packet, parse it out (to get the Pitch and Roll values).
    And then assign the values to the inputs of the game plugin.
    Pitch_Output = Pitch you parsed
    Roll_Output = Roll you parsed

    I can help with the plugin, maybe send the data like this.
    S:Roll_Value,Pitch_Value:E

    Then I will make a plugin for you to look at and see how easy it is buddy!
    yobuddy
    • Friendly Friendly x 2
  10. ZKILLA

    ZKILLA Member

    Joined:
    Apr 5, 2017
    Messages:
    54
    Location:
    Australia
    Balance:
    417Coins
    Ratings:
    +7 / 0 / -0
    My Motion Simulator:
    SCN5, SCN6
    Thank you buddy, you are really sooooo kind and helpful! Forgive me that I always ask some stupid questions because I'm really bad at coding and programming.:( I'm a little bit confused about you said that send you the data like S:Roll_Value,Pitch_Value:E, because I'm using the Labview model to generate the UDP packets and you can see from the picture I posted above, you can use the slider to control the Roll value and Pitch value. So it's not a certain value obviously, it should be a thread or something I think, so I don't not how to present it to you.
    Like you said, I think I need do some codes to catch the UDP packets and parse it out, and this is what I feel hopeless, like I said I really bad at coding, I feel I like a idiot.:oops:
    Sorry for my ignorance again and thank you for your reply buddy, cheers.
  11. yobuddy

    yobuddy Well-Known Member Staff Member Moderator SimAxe Beta Tester SimTools Developer Gold Contributor

    Joined:
    Feb 9, 2007
    Messages:
    5,162
    Occupation:
    Computer Technician
    Location:
    Portland, Oregon - USA
    Balance:
    48,171Coins
    Ratings:
    +5,037 / 16 / -0
    Right now it looks like it puts out "## Roll? Pitch? ##" or something like that.
    It would be nice if it put out a string to we check that it is all there.
    (we could look to see that a 'S:' and a ':E' is present)
    And then grab the data we need from the string.

    So I was suggesting sending data from labview like this "S:Roll_Value,Pitch_Value:E".
    what do you think?
    yobuddy
  12. ZKILLA

    ZKILLA Member

    Joined:
    Apr 5, 2017
    Messages:
    54
    Location:
    Australia
    Balance:
    417Coins
    Ratings:
    +7 / 0 / -0
    My Motion Simulator:
    SCN5, SCN6
    Alright, I got your point this time! I'll do that without problem, and I'll send you the result after I finish this, thanks buddy!
  13. ZKILLA

    ZKILLA Member

    Joined:
    Apr 5, 2017
    Messages:
    54
    Location:
    Australia
    Balance:
    417Coins
    Ratings:
    +7 / 0 / -0
    My Motion Simulator:
    SCN5, SCN6
    Hey buddy, I modified the model as your suggestion, and here is the result. The string is start from "S:" and end by ":E", how do you feel about this? Cheers.

    Attached Files:

    • S.png
      S.png
      File size:
      116 KB
      Views:
      641
  14. yobuddy

    yobuddy Well-Known Member Staff Member Moderator SimAxe Beta Tester SimTools Developer Gold Contributor

    Joined:
    Feb 9, 2007
    Messages:
    5,162
    Occupation:
    Computer Technician
    Location:
    Portland, Oregon - USA
    Balance:
    48,171Coins
    Ratings:
    +5,037 / 16 / -0
    @ZKILLA,
    Can you remove the blank space and add the coma between roll and pitch?
    I should be able to look at this tomorrow sometime.
    yobuddy
    • Friendly Friendly x 2
  15. ZKILLA

    ZKILLA Member

    Joined:
    Apr 5, 2017
    Messages:
    54
    Location:
    Australia
    Balance:
    417Coins
    Ratings:
    +7 / 0 / -0
    My Motion Simulator:
    SCN5, SCN6
    Hi bro, how do you feel this time? I removed the blank and add a comma between two values. Here is the UDP packets that I catch. Cheers!

    Attached Files:

  16. yobuddy

    yobuddy Well-Known Member Staff Member Moderator SimAxe Beta Tester SimTools Developer Gold Contributor

    Joined:
    Feb 9, 2007
    Messages:
    5,162
    Occupation:
    Computer Technician
    Location:
    Portland, Oregon - USA
    Balance:
    48,171Coins
    Ratings:
    +5,037 / 16 / -0
    Ok please set the output port to "4123". (default SimTools game plugin port)
    Then please change the coma "," in the output, to a dash "-" to make it work for all regions.
    (S:Roll_Value-Pitch_Value:E") <-- looks like this now
    (sorry for the change, but its guaranteed to work even if the output uses comas or decimal places).

    Then try out this little app to see if we are catching the data correctly.
    let me know how it goes buddy.
    yobuddy

    Attached Files:

    • Friendly Friendly x 3
  17. ZKILLA

    ZKILLA Member

    Joined:
    Apr 5, 2017
    Messages:
    54
    Location:
    Australia
    Balance:
    417Coins
    Ratings:
    +7 / 0 / -0
    My Motion Simulator:
    SCN5, SCN6
    Hey mate, I tested your app and found it can only catch one value normally, and the other one is blank. I don't know why it is like this, and I guess it might caused by different data format, anyway, I'm not sure about this, how do you feel? Cheers!

    Attached Files:

  18. ZKILLA

    ZKILLA Member

    Joined:
    Apr 5, 2017
    Messages:
    54
    Location:
    Australia
    Balance:
    417Coins
    Ratings:
    +7 / 0 / -0
    My Motion Simulator:
    SCN5, SCN6
    Hi buddy, I found that when the value be positive, the app can show those values correctly, when any value goes to negative, it will become blank or loose the minus mark. Anyway, it seems can work now, only need to make a little modification it should work perfectly. Thank you so much for your help!

    Attached Files:

  19. yobuddy

    yobuddy Well-Known Member Staff Member Moderator SimAxe Beta Tester SimTools Developer Gold Contributor

    Joined:
    Feb 9, 2007
    Messages:
    5,162
    Occupation:
    Computer Technician
    Location:
    Portland, Oregon - USA
    Balance:
    48,171Coins
    Ratings:
    +5,037 / 16 / -0
    lol, makes sense since we were using a minus sigh for the delimiter.
    ok, replace the dash "-" with a colon":" and try this.
    yobuddy

    Attached Files:

  20. ZKILLA

    ZKILLA Member

    Joined:
    Apr 5, 2017
    Messages:
    54
    Location:
    Australia
    Balance:
    417Coins
    Ratings:
    +7 / 0 / -0
    My Motion Simulator:
    SCN5, SCN6
    Questions still there, When I set two values to be negative, the roll value changes to pitch and miss the minus mark and pitch value vanished, as it shown in the figure I attached. Cheers buddy.

    Attached Files: