Menu

Way to alter direction

Anonymous
2010-04-29
2013-04-30
  • Anonymous

    Anonymous - 2010-04-29

    Hello everyone!

    I'm wondering, is there an official way in OpenSteer to control boid's orientation, or when I want boid turn around to face a point, I should do some hack like setForward(0.99 * forward + 0.01 * target)?

    Thank you in advance!
    Ján

     
  • Craig Reynolds

    Craig Reynolds - 2010-04-29

    Hi.  It depends on what you are trying to do.  There is the kind of orientation change that results from steering during simulation (say while flying toward the target).  There is also setting orientation outside of simulation, as you might do to initialize an agent (say to point toward the target) before starting a simulation.  Or do you mean "turning in place" during simulation, like a hovering helicopter adjusting its heading?

    The first case would be handled with a behavior like seek, see OneTurning sample code.

    The second case can be accomplished by effectively setting the forward direction, but should be done with regenerateOrthonormalBasis (const Vec3& newForward) to properly maintain the local coordinate space.

    Probably you were talking about case three, since you mentioned a small change in orientation from current to target heading.  I would expect you can set the speed to zero and call regenerateOrthonormalBasis each frame to do the "hover turn" but I have not tried it.

    Craig

     
  • Anonymous

    Anonymous - 2010-04-29

    Thank you for an informational reply!

    In fact I mean a behaviour like steerForSeek, just parametrized not with one vector expressing target position, but also in addition with a target orientation. What I do at the moment is that I perform traditional steerForSeek plus in every frame make sure the orientation comes closer to the intended target one. However, I'm not sure it does the work correctly.

    I'm going to check the OneTurning example.

    Thanks,
    Ján

     
  • Anonymous

    Anonymous - 2010-04-29

    I've checked that sample code and it doesn't seem to do exactly what I need. I have two fixed vectors (one for position in a space and one for orientation - should be parallel with forward) and I'd like to direct the boid to reach this point.

     
  • Craig Reynolds

    Craig Reynolds - 2010-04-29

    OK, the good news is that now I understand exactly what you are talking about.  You want the "docking" steering behavior (like bringing a ship into a dock) as described in my 1999 paper ( http://www.red3d.com/cwr/steer/gdc99/ ):

    "…The arrival behavior … can be considered a constraint on position and speed. This can be extended to simultaneously constrain orientation (to produce docking), or a non-zero velocity, and/or to meet these constraints at a given time."

    The bad news is that I never implemented it (this is mentioned under http://opensteer.sourceforge.net/doc.html#KnownBugs ).  Worse than that, I made an attempt or two and did not produce a satisfactory result, so I can't just rattle off how to implement it.  What follows is just speculation.

    Say you have a target position P and a target heading H and the goal is to get to P along a path that is (nearly) parallel to H at the time of intersection.  Consider the line L defined by P and H.  In general terms you want to approach L then follow it (like a pathway) to P.

    One way to do that is to pick a point Q on the line some distance away from P (P - kH).  You could "seek" toward Q then switch your seek target to P.  (BTW, use "seek" if you just want to pass through P, use "arrival" if you want to come to a stop at P.)  This target switch might happen when you get within some distance of Q, or when your heading is close enough to H, or some combination of those.  choosing that criteria and picking "k" are sure to be hard to get right. 

    The way I tried to do it back in 1999 is to consider the turning radius of the vehicle, then to construct a circle(/sphere) of that radius that is tangent to Q (on the same side of L as the vehicle).  Then you seek toward the "limb" of the circle, steer around it at maximum turn rate until you reach Q, then steer straight toward P.  I'm sure that is hard to visualize without a picture, but it is similar to the way air traffic is routed into a runway.

    Implementing "docking" is a interesting and challenging bit of steering behavior design.  I think it would be fun to jump in and try it, but I have a long list of more pressing items on my to do list so I cannot offer to do this any time soon.

     
  • Anonymous

    Anonymous - 2010-04-29

    I understand. But I'm still very thankful for your time and insight. The idea you presented (the 1999 one) sounds reasonable to me, so if I have some time, I might look into it (however, as this one thing is not the core issue of things that need to be done, I might stick for my steerForSeek + regenerateOrthonormalBasis combo which already works "somehow").

    Still, if I happen to implement something of interest, I'll be sure to share it.

    I don't know if you keep track of projects that benefit from OpenSteer, but in case you do, this one's ours: http://urtax.ms.mff.cuni.cz/flyingsamurai/

    Once again, thanks!
    Ján

     
  • Craig Reynolds

    Craig Reynolds - 2010-04-29

    If you have something simple that does what you need: "don't mess with success!"  Especially now that I understand the time constraints you have.  In general the combination of seeking P while adjusting heading toward H will not produce "docking".  For example, if you want to reach P while heading west, but you are approaching from directly south of P, I don't think you would get the desired result.  Perhaps other aspects of your simulation prevent this problem.

    Thanks for the link to your project page.  I do collect links about applications and ports of OpenSteer, that "someday" I will merge into the doc.  Others here: http://delicious.com/cwr/opensteerdoc

    Erwin Coumans, the guy behind Bullet is a coworker of mine, I will tell him about your project.

     

Log in to post a comment.

MongoDB Logo MongoDB