Shop OBEX P1 Docs P2 Docs Learn Events
An ROV revelation — Parallax Forums

An ROV revelation

Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
edited 2015-05-21 19:31 in Robotics
Okay, this may be old news to some of you, but I just had an AHA! moment regarding guiding an floating ROV via GPS. But first, a review of terms:
heading: The direction the robot is pointed.
course: The direction the robot is moving.
bearing: The direction to the robot's destination.
speed: The velocity in course direction.

Typically, for navigation, you can compute an error angle, which is course - bearing and use that, along with the speed, to modify your thrusters, rudder, wheel speed, whatever. But in floating craft, there are factors like wind and currents to contend with. In most cases the above relationship works fine. But what I've found in the field is, if the environmental forces are pushing you backwards from your intended target, course and bearing will be in different quadrants, more than 90 degrees apart. So the error term will be very large, and the obvious reaction is to turn sharply -- which is the exact opposite of what you want to do, because it does not change the error angle.

My working assumption regarding any compass is that it will be inaccurate, regardless of any care you've take to calibrate it. But it will be approximately correct all of the time. And here's where the heading reading from the compass becomes useful. If the course and heading values are more than 90 degrees apart, you're probably being pushed backwards. So the thing to do in that case is to add 180 degrees to the course (mod 360), and negate the speed figure. Then, you can compute a new error angle and forward thrust correction that gives you a better reaction to the situation, i.e. to speed up rather than to keep turning and getting the same huge error angle.

D'oh! or Aha! ? Not sure which, but I'm gonna run with it and see what happens.

-Phil

Comments

  • ercoerco Posts: 20,255
    edited 2015-05-18 21:42
    Sounds logical, I'm sure it's one of those "have to try it to appreciate it" situations. WRT speed increase, I'm sure an occasional comparison of water speed (like airspeed, but in water) vs. actual speed (via GPS) would be helpful. You'll have to Youtube some of your wonderful experiments, I can't wait!
  • W9GFOW9GFO Posts: 4,010
    edited 2015-05-19 04:11
    I don't think your heading needs to be very accurate. It will rarely be equal to the course. I'm also curious as to how you intend to have it follow a course line rather than just navigate between waypoints. If you only do the latter then every path will resemble an arc with decreasing radius.as it approaches each waypoint. Which I don't imagine will suit it's mission very well.
  • LoopyBytelooseLoopyByteloose Posts: 12,537
    edited 2015-05-19 05:29
    Fishermen often say you have to think like a fish to catch fish.

    This is a delightful glimplse of the need to think like an ROV to get it to navigate well. I have been pondering something similar with autonomous flight vehicles and the 9DOH sensors. A lot the issues are similar and problems related.

    Just because it gets into visualizing navigation, it gets very exciting and fun.

    The maths behind why we use quadrants, and why we have to be careful with info from the adjacent quadrants is significant. It might be a little hard for a newbie to grasp.
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2015-05-19 08:17
    W9GFO wrote:
    I'm also curious as to how you intend to have it follow a course line rather than just navigate between waypoints.
    First you add sub-waypoints along the desired path, perhaps 10 meters apart. Also, if you use the course and bearing to compute the error, rather than the heading and bearing, the heading will tilt off-course automatically to compensate for wind or current. Of course, this only works if you're moving and can establish a course direction from the GPS. When stopped, the heading and bearing are all you've go to go on.

    -Phil
  • W9GFOW9GFO Posts: 4,010
    edited 2015-05-19 20:52
    First you add sub-waypoints along the desired path, perhaps 10 meters apartl

    If you had a GPS with cm accuracy I think that would work. With standard GPS the variations are so large that I think you will get a zig zag course with that method. I think you need to be constantly checking your distance from the course line and steering to stay on that line. Describing that line mathematically is what I am curious on how to do.
  • John AbshierJohn Abshier Posts: 1,116
    edited 2015-05-20 07:39
    Here is a method to measure distance from a point to a line segment. It is ugly because of the format of Spin floating point.
    Pri PointToSegment(ptx, pty) : d  | vx, vy, wx, wy, c1, c2, b, pbx, pby, i
    ' s1 from s2 is to
      i := curSeg
      vx := F.FSub(pX[i] , pX[i-1])  ' depends on segment only
      vy := F.FSub(pY[i] , pY[i-1])
      wx := F.Fsub(ptx , pX[i-1])   ' depends on point
      wy := F.Fsub(pty , pY[i-1])
      c1 := F.FAdd(F.FMul(wx ,  vx) , F.FMul(wy , vy))
      if (F.FCmp(c1 , 0.0) == -1)
    '    d := Distance(ptx, pty, pX[i-1], pY[i-1])   'point is closest to beginning of segment
        d := 0.0 ' turning at the begining of the segement gets confused by returning distance to point
        return
      c2 :=  F.FAdd(F.FMul(vx , vx) , F.FMul(vy , vy))
      if (F.FCmp(c2 , c1) == -1)
        d := Distance(ptx, pty, pX[i], pY[i])
        curSeg++                              ' point is closer to end of segment than to line
        return
      b := F.FDIV(c1,c2)
      pbx := F.FAdd(pX[i-1] , F.FMUL(b,vx))
      pby := F.FAdd(pY[i-1] , F.FMUL(b,vy))
      d := Distance(ptx, pty, pbx, pby)
      if F.FCmp((F.FSub(F.FMul(wx , vy) , F.FMul(wy , vx))) , 0.0) == -1   ' pos if on left of path 
        return d
      else
        return F.FNeg(d)  
      return
    Pri Distance (p1x, p1y, p2x, p2y) : d | tx, ty
      tx := F.FSub(p1x , p2x)
      ty := F.FSub(p1y , p2y)
      d :=  F.FAdd(F.FMul(tx , tx) , F.FMul(ty , ty))
      d := F.FSqr(d)
    

    John Abshier
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2015-05-20 08:58
    W9GFO wrote:
    With standard GPS the variations are so large that I think you will get a zig zag course with that method.
    Parallax's PAM-7Q modules are amazingly accurate, so long as you wait long enough after power-up for HDOP to come down. Here's a track from a recent experiment with the ROV and 10m-separated sub-waypoints:

    attachment.php?attachmentid=114253&d=1432136736

    The ROV was programmed to leave the dock, slew to the starting point at 2.0 kts, go down the channel at 1.5 kts until it reached the end of the second float past the long pier, turn around, and come back to the first waypoint at 2.0 kts. At that point it stops and waits for me to take over with the RC. Everything is recorded on an SD card, black-box style, for further analysis.

    I have endured a lot of zig-zag tracks to get to this point. Some were so bad that they looked like puzzle joints between sub-waypoints. What I've found is that they're mostly due to over- or under-correcting the turning. For a given platform, the straightest tracks are had when the turn rate and speed are in the best ratio to each other. I'm also using a PID loop. P- or PI-only have proved inadequate.

    The platform I used for the above track has no fin, skeg, or chine. It will turn on a dime and is rather difficult to control with the RC transmitter. I added a small strap-on fin for added stability, and it completely changed the dynamics. It was much easier to guide under RC control; but under program control, I got the zig-zag track again, and I haven't taken the time to adjust the speed/turnrate ratio with the fin and have removed it for now.

    My biggest problem currently is suspended strands of seaweed clogging the thrusters. We've put screens in front of them to keep the weeds from tangling in the prop. But now they pile up against the screens. As soon as that happens, the ROV starts spinning, and I have to bring it limping home under RC control. Because of the seaweed, I've have yet to make a good test of the topic that started this thread, even though the wind and currents lately have been ideal for the challenge.

    One design objective of the platform is that it has to perform in a 2 kt. current. That's because the sea stars being monitored inhabit a narrow channel separating the mainland from an island, and the tidal currents can be extreme. That's a pretty tall order, and at this point I'm not sure it's doable.

    -Phil
    903 x 871 - 173K
  • ercoerco Posts: 20,255
    edited 2015-05-20 09:13
    Amazing accuracy! You're discovering new things and writing some of it here. Write some more and get it published in SERVO! I'm sure Robin would love it. Beer money and helping others.A win-win!
  • xanaduxanadu Posts: 3,347
    edited 2015-05-20 16:38
    That track looks great! It seems like you have the hard part accomplished already. If the seaweed becomes too big an issue could you propel it using a pusher airplane prop and rudder topside like a swamp boat?
  • W9GFOW9GFO Posts: 4,010
    edited 2015-05-20 20:32
    Here's a track from a recent experiment with the ROV and 10m-separated sub-waypoints:
    That's certainly a nice track but I doubt you had much current to deal with in the marina. Do that in the sound and I will be a believer. It has nothing to do with steering ability, which you seem to have sorted out, it is all about being constantly drifted off course then correcting towards the next waypoint. Not really an issue in calm waters.
  • macrobeakmacrobeak Posts: 354
    edited 2015-05-21 07:14
    I agree with xanadu. if current and seaweed are a problem perhaps you should explore the swamp boat option. Not so difficult to do - you already have ESC controls for the thrusters - just swop the thrusters for above board EDF's.
  • ercoerco Posts: 20,255
    edited 2015-05-21 08:03
    Or occasionally do a full throttle reverse to purge the seaweed.

    Edit: I'm surprised no one has suggested PhiPi change the thread's title to "A ROV-elation".
  • kwinnkwinn Posts: 8,697
    edited 2015-05-21 19:31
    erco wrote: »
    Or occasionally do a full throttle reverse to purge the seaweed.

    Edit: I'm surprised no one has suggested PhiPi change the thread's title to "A ROV-elation".

    Someone has now.
Sign In or Register to comment.