YouTube

Got a YouTube account?

New: enable viewer-created translations and captions on your YouTube channel!

English subtitles

← 03ps-08 Circular Motion Solution

dummy description

Get Embed Code
2 Languages

Showing Revision 1 created 10/24/2012 by Amara Bot.

  1. Here's a function "move" as a class function of the class robot
  2. that implements where I get my motion vector,
  3. and the motion vector is defined to be steering first, then distance.
  4. I have a few error checks here to make sure the steering doesn't exceed
  5. the max steering angle, and the same is true for distance.
  6. I want it to be non-negative.
  7. As I go down, I now implement the motion model.
  8. Let's just look a little bit more.
  9. I make a new robot copy as in my sample code in class.
  10. I copy all the narrowing parameters--length, bearing noise, steering noise, and distance noise.
  11. Nothing surprising here.
  12. Here I'll apply the noise, which you don't need it for the first implementation,
  13. but later on as we go on, you need it to actually add noise.
  14. I just add Gaussian noise with the corresponding steering noise and distance noise parameters.
  15. If I set the mean of the Gaussian to be the steering command
  16. and the distance command then this adds noise.
  17. I could have equally written steering plus random.gauss,
  18. zero, comma, and then the noise parameter.
  19. As I go down further, here is my execution of motion.
  20. My turning angle, I called "turn."
  21. This is the tangents of the noisy steering
  22. times the distance moved divided by the robot length.
  23. As in my explanation of this question, I'm going to branch and see if my turn is significant enough.
  24. It's smaller than tolerance, and tolerance was set about to 0.001.
  25. Then I just model a straight motion.
  26. I get my new robot coordinates by the old robot coordinates,
  27. moving in the orientation of the robot--cosine for x and sine for y.
  28. I increase my orientation by turn, which is likely essentially zero.
  29. In case I go beyond 0 or 2π,
  30. I do the modal operation here just to make sure my angles are nicely between 0 and 2π.
  31. The more interesting case--as we go down
  32. in this program you can see that I now calculate the radius
  33. as the noise distance divided by turning.
  34. Then I find the center of the circle around which I'm turning,
  35. using the exact same math I just gave you.
  36. I now first change the orientation to be the new orientation
  37. by adding turn to the old orientation, modal, or 2π.
  38. Then I plug the new orientation into the sine and cosine argument,
  39. multiply by radius, add to the center of the circle to get my result.
  40. This routine over here gives me exactly what I wanted.