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

Resolved SimTools connection to Ruby (SketchUp) - Not getting updated axis values

Discussion in 'SimTools DIY Version' started by pillowsack, Mar 14, 2017.

  1. pillowsack

    pillowsack New Member Gold Contributor

    Joined:
    Feb 21, 2017
    Messages:
    28
    Occupation:
    Programmer
    Location:
    Vancouver, WA, USA
    Balance:
    370Coins
    Ratings:
    +18 / 0 / -0
    Having an issue with getting updated values from SimTools while in Output Testing mode. I am using the Network interface to connect to a Ruby socket (SketchUp). Following the FAQ for the SketchyPhysics, I have messages logging to the console.
    Code:
    require 'socket.so'
    socket = UDPSocket.new
    socket.bind("127.0.0.1", 3157)
    SKETCHUP_CONSOLE.show
    timer_id = UI.start_timer(1, true) {
        puts socket.recvfrom_nonblock(100)
    }
    
    What I receive with <Axis1a>;<Axis2a> (extra information for bugging)
    Code:
    127;127
    AF_INET
    50797
    127.0.0.1
    127.0.0.1
    
    Now when I move the axis sliders, I get no change in values in the first line. 127 I know equals 0 or center on a servo. That tells me I am getting data from SimTools.

    Here is my interface settings just to be sure

    interface-settings-net.jpg
  2. pillowsack

    pillowsack New Member Gold Contributor

    Joined:
    Feb 21, 2017
    Messages:
    28
    Occupation:
    Programmer
    Location:
    Vancouver, WA, USA
    Balance:
    370Coins
    Ratings:
    +18 / 0 / -0
    Some extra information I stumbled upon.

    When I have Output Testing mode on and set the axis sliders to a position, then startup SketchUp, I see a value that represents where I am on the slider. But that's it, won't update if I move the slider.
  3. noorbeast

    noorbeast VR Tassie Devil Staff Member Moderator Race Director

    Joined:
    Jul 13, 2014
    Messages:
    21,030
    Occupation:
    Innovative tech specialist for NGOs
    Location:
    St Helens, Tasmania, Australia
    Balance:
    147,878Coins
    Ratings:
    +10,880 / 54 / -2
    My Motion Simulator:
    3DOF, DC motor, JRK
    • Agree Agree x 1
  4. pillowsack

    pillowsack New Member Gold Contributor

    Joined:
    Feb 21, 2017
    Messages:
    28
    Occupation:
    Programmer
    Location:
    Vancouver, WA, USA
    Balance:
    370Coins
    Ratings:
    +18 / 0 / -0
    Spent about 2 hours reading every post talking about the network interface and/or SketchUp. They all seem to be addressing the physics engine not reacting to input. Can't get to that point yet. :(

    I have a connection from SimTools to the Ruby socket, albeit what seems as only an initial connection and nothing else.

    My attached photo shows the correct axis assignments (that was my issue back with my little arduino serial interface) and my console logging parses, splits, and converts the initial value accurately. I just only get the first set of values. Even after shutdown of the Output Testing mode I still get the same values. Network issue is my only other lead.

    Fresh eyes on it in the morning I guess. Probably get some sort of packet sniffer running to see if I can uncover anything.
  5. noorbeast

    noorbeast VR Tassie Devil Staff Member Moderator Race Director

    Joined:
    Jul 13, 2014
    Messages:
    21,030
    Occupation:
    Innovative tech specialist for NGOs
    Location:
    St Helens, Tasmania, Australia
    Balance:
    147,878Coins
    Ratings:
    +10,880 / 54 / -2
    My Motion Simulator:
    3DOF, DC motor, JRK
    I bundled everything up so there was a known working configuration, which makes it much easier to get everything going and hopefully reduces the risk of a user mistake or version incompatibility issue.

    If the steps are followed it should work out of the box with the default model.
  6. pillowsack

    pillowsack New Member Gold Contributor

    Joined:
    Feb 21, 2017
    Messages:
    28
    Occupation:
    Programmer
    Location:
    Vancouver, WA, USA
    Balance:
    370Coins
    Ratings:
    +18 / 0 / -0
    I am not even at the point of loading a model, would have been no point if I wasn't getting real time values from SimTools.

    After sniffing on my network, I found that SketchUp was accepting other connections. Once it they were killed off, floodgates opened up! Still, that should not have caused my issues.

    Marking this one solved. Getting what I need now and can move on.
  7. yobuddy

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

    Joined:
    Feb 9, 2007
    Messages:
    5,282
    Occupation:
    Computer Technician
    Location:
    Portland, Oregon - USA
    Balance:
    49,199Coins
    Ratings:
    +5,093 / 18 / -0
  8. pillowsack

    pillowsack New Member Gold Contributor

    Joined:
    Feb 21, 2017
    Messages:
    28
    Occupation:
    Programmer
    Location:
    Vancouver, WA, USA
    Balance:
    370Coins
    Ratings:
    +18 / 0 / -0
    What I ended up with for a more stable connection. SU was crashing on me too with too many EWOULDBLOCK errors trying to do a split on message.

    Code:
    require 'socket.so'
    socket = UDPSocket.new
    socket.bind("127.0.0.1", 3157)
    
    def translate(f)
        return (f / 255) * 180
    end
    
    timer_id = UI.start_timer(0.01, true) {
        begin
            message, sender = socket.recvfrom_nonblock(100)
            new_message = true
        rescue Errno::EWOULDBLOCK
            new_message = false
        rescue Errno::ECONNRESET
            new_message = false
            UI.stop_timer @timer_id
            break
        end
    
        if new_message == true
            message1, message2 = message.split(";")
            $axis1 = translate message1.to_f
            $axis2 = translate message2.to_f
        end
    }