
Title:
03ps08 Circular Motion Solution

Description:

Here's a function "move" as a class function of the class robot

that implements where I get my motion vector,

and the motion vector is defined to be steering first, then distance.

I have a few error checks here to make sure the steering doesn't exceed

the max steering angle, and the same is true for distance.

I want it to be nonnegative.

As I go down, I now implement the motion model.

Let's just look a little bit more.

I make a new robot copy as in my sample code in class.

I copy all the narrowing parameterslength, bearing noise, steering noise, and distance noise.

Nothing surprising here.

Here I'll apply the noise, which you don't need it for the first implementation,

but later on as we go on, you need it to actually add noise.

I just add Gaussian noise with the corresponding steering noise and distance noise parameters.

If I set the mean of the Gaussian to be the steering command

and the distance command then this adds noise.

I could have equally written steering plus random.gauss,

zero, comma, and then the noise parameter.

As I go down further, here is my execution of motion.

My turning angle, I called "turn."

This is the tangents of the noisy steering

times the distance moved divided by the robot length.

As in my explanation of this question, I'm going to branch and see if my turn is significant enough.

It's smaller than tolerance, and tolerance was set about to 0.001.

Then I just model a straight motion.

I get my new robot coordinates by the old robot coordinates,

moving in the orientation of the robotcosine for x and sine for y.

I increase my orientation by turn, which is likely essentially zero.

In case I go beyond 0 or 2π,

I do the modal operation here just to make sure my angles are nicely between 0 and 2π.

The more interesting caseas we go down

in this program you can see that I now calculate the radius

as the noise distance divided by turning.

Then I find the center of the circle around which I'm turning,

using the exact same math I just gave you.

I now first change the orientation to be the new orientation

by adding turn to the old orientation, modal, or 2π.

Then I plug the new orientation into the sine and cosine argument,

multiply by radius, add to the center of the circle to get my result.

This routine over here gives me exactly what I wanted.