sketchucation logo sketchucation
    • Login
    ℹ️ Licensed Extensions | FredoBatch, ElevationProfile, FredoSketch, LayOps, MatSim and Pic2Shape will require license from Sept 1st More Info

    Servo Starting Angle

    Scheduled Pinned Locked Moved Newbie Forum
    sketchup
    3 Posts 2 Posters 3.0k Views 2 Watching
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • S Offline
      stevepowers
      last edited by stevepowers

      Although this is a general question it's causing me problems with the simulation of a JCB digger. File attached.

      I'm using servos on the digger arms but as, when the simulation starts, the servo angle is taken as zero any subsequent movement is taken from that start position. So if the arm starts off in the incorrect position after the last simulation the digger arm can crash into other components.

      I need to be able to know the starting position of the servo or, more likely, of the digger arm. Any ideas.

      Note - the attached file uses a joystick as the control device - see the script to understand.

      Postscript (Added later) I should have explained that this is using MSPhysics. It works with the version of Sketchup Make 2017 I am using and is the latest version of MSPhysics - 1.0.3.


      servo starting position demo v2.skp

      1 Reply Last reply Reply Quote 0
      • BoxB Online
        Box
        last edited by

        You might call it general, but it is a very specific subject.
        You need to tell us what you are using for the animation.
        Is it Sketchy physics that works with the rather old version 2016 that you seem to have or is it Msphysics that works with the newer versions, but not with the latest if I remember correctly.

        1 Reply Last reply Reply Quote 0
        • S Offline
          stevepowers
          last edited by

          For completeness I can report that I have managed to fix this problem myself, albeit in a rather "brute force" way - so if there's a simpler solution I'd be very interested.

          Rather than try to measure the property of the servo itself, I obtained the position of the objects it was ultimately linked to using script such as the following for each object -

          @@pos_mainarm_cylinder = this.get_position(1)
          @@pos_mainarm_ram = this.get_position(1)

          Then by computing the distance between the two objects I was able to limit the movement of the servo so as to remain within the correct range.

          dist = distance(@@pos_mainarm_cylinder, @@pos_mainarm_ram)
          joy = joystick(:lefty)
          if ( dist > 1.000 && joy < 0 ) || ( dist < 0.380 && joy >0 ) || (dist < 1.000 && dist > 0.380)
          @_mainarm = @_mainarm - joy
          end

          The limits of 1.00 and 0.38 were from the known dimensions of the objects. The local variable @_mainarm was then used to control the servo. The distance function uses Pythagoras's theory to calculate the distance between the middle of each object.

          As I say - any simpler ideas? Nonetheless it now works as intended irrespective of the starting position of the servos.

          1 Reply Last reply Reply Quote 0
          • 1 / 1
          • First post
            Last post
          Buy SketchPlus
          Buy SUbD
          Buy WrapR
          Buy eBook
          Buy Modelur
          Buy Vertex Tools
          Buy SketchCuisine
          Buy FormFonts

          Advertisement