Announcement

Collapse
No announcement yet.

Talking to Protee SDK with Python

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Talking to Protee SDK with Python

    I am trying to use JSON over TCP as described here.


    I start the Protee Golf Interface, then TGC as I normally would.

    I have made a simple program that attempts to send the sample data to port 1933 using the Python Requests module, but I get Error 10061 - No connection could be made because the target machine actively refused it. I am not much of a programmer, but could somebody or ProTee United give me a hint as to what I am doing wrong? Or an example Python script that is able to send data to the Protee Golf Interface would work as well. I have attached a photo of the error and my code is below.

    Code:
    import requests
    import json
    
    url = "http://localhost:1933"
    
    payload = {"protocol":"GenericTCP", "info":{"device":"UNKNOWN", "version":"1.0.0", "club":"false", \
                "ball":"true", "spin":"true"}, "data":{"counter":"0", "shotnumber":"0", "clubspeed":"0",\
                "swingpath":"0", "clubface":"0", "facerelative":"0", "sweetspot":"0", "ballspeed":"10.0", \
                "launchangle":"25.4", "ballpath":"3", "backspin":"3000", "sidespin":"-300", "axis":"2", \
                "carry":"0"}}
    
    r = requests.post(url, data=json.dumps(payload))
                                 
    cv2.waitKey(0)[ATTACH=JSON]{"data-align":"none","data-size":"full","title":"Error.jpg","data-attachmentid":190431}[/ATTACH]
    Attached Files

  • #2
    Ball not launching? but packets being sent?

    Comment


    • andygg1986
      andygg1986 commented
      Editing a comment
      I believe nothing gets sent and the ball definitely does not launch.

  • #3
    andygg1986 I haven't had a chance to look into this yet, but if you'd like to and we get Protee's blessing, I'd love to opensource a Protee Python client library.

    If you'd like to work on this together, feel free to fork and make pull requests here. I can't do heavy development right now, but I can review, test, and confirm that it works as expected:


    I believe the first success milestone will be getting something about a license error.

    Comment


    • andygg1986
      andygg1986 commented
      Editing a comment
      Yes I think an open source library would be great to speed development for other hardware platforms as well, as long as Protee is on board

  • #4
    Make sure GSX is running and set the input to Generic TCP.

    I just tested this and it works for me.

    I was lazy so just opened a Telnet session, connected to the port, then sent the example launch data (copy/paste from the SDK example). Received 202 response ("data accepted") and it launched the ball nicely in TGC. Verified the TGC info screen showed the proper values. Repeated with an invalid dataset and got a 203 response ("invalid data"). So working fine as far as I can see.


    EDIT: I see Protee has just changed the SDK description this evening. It is now something different presumably so you don't need to use GSX. I didn't test the new way. I tested what used to on the SDK page and what you have in your example above.
    Last edited by FaultyClubs; 03-01-2019, 12:05 PM.

    Comment


    • andygg1986
      andygg1986 commented
      Editing a comment
      Thanks. I wasn’t using GSX since it was a Protee SDK, but I am going to proceed using their new info below to reduce the number of programs that are running.

  • #5
    Hi Guys,

    We just updated the SDK documentation as it was rather old.

    Please check :


    With this documentation you can interact with the ProTee Golf Interface directly

    Comment


    • andygg1986
      andygg1986 commented
      Editing a comment
      Thanks! Protee customer support comes through again!

  • #6
    Are there any python programmers out there who could help me out with some sample code to send the example data to Protee Golf Interface? I am banging my head against this and not getting anywhere. I’ve never programmed anything with JSON over TCP and I’m sure I’m just doing something fundamentally wrong with sending it.

    Comment


    • ChadGolf
      ChadGolf commented
      Editing a comment
      I’ll look into something tonight.

    • andygg1986
      andygg1986 commented
      Editing a comment
      Thanks ChadGolf. I was hoping there were some other programmers on here. I didn’t want to add on to your crazy workload that you have been doing for the simulator community, but I would appreciate the help.

  • #7
    I can't access the Protee Interface because I'm a Skytrak user. I'll submit a support ticket and see if they allow me to activate a license.

    Comment


    • #8
      I'm not a programmer. But I tried to get it working using Requests module and gave up. Couldn't really see anything wrong with what you did.

      I did manage to launch the ball from gsx using sockets however. And read status from the Protee interface but for some reason I couldn't launch the ball from the Protee interface and ran out of time looking.

      Comment


      • #9
        I missed seeing this, but I think the requests API is for HTTP GET, POST, and those kind of requests.

        The protee SDK linked looks to be a straight TCP connection, so that's probably why sockets is working.

        Comment


        • FaultyClubs
          FaultyClubs commented
          Editing a comment
          Ah so desu ka...yes, think you're right. I tried the request put function but could never get past the connection so switched to sockets.

      • #10
        Just curious...what are you guys working on?

        Comment


        • #11
          andygg1986 It took a day of delay because I had to get a provisional Protee Golf Interface license from Protee, but they responded with some very helpful tips (since I'm a SkyTrak user) and I got the full API working.



          Should be pretty self explanatory, the SDK manages its own connections, just call get_game_status and launch_ball and it should work. I looked through the parameters and I just set the ones that seem to be absolutely required with the rest only being set if they are specified in launch-ball.

          You can run the library with python ProTeeSDK.py [optional_ip_address]
          and it will launch random shots to demonstrate for you.

          Comment


          • andygg1986
            andygg1986 commented
            Editing a comment
            Oh my gosh, thank you so much!!! I had been working on this all weekend and getting very frustrated. I will work on getting this integrated over the next few days into my program.
        Working...
        X