i400/i590/b659: intelligent robotics preliminaries: vectors

32
I400/I590/B659: Intelligent Robotics Preliminaries: Vectors

Upload: mateo-noah

Post on 11-Dec-2015

226 views

Category:

Documents


1 download

TRANSCRIPT

Page 1: I400/I590/B659: Intelligent Robotics Preliminaries: Vectors

I400/I590/B659: Intelligent RoboticsPreliminaries: Vectors

Page 2: I400/I590/B659: Intelligent Robotics Preliminaries: Vectors

Lab 1

1. Install Klamp’t python API2. In Klampt/Python/demos folder: run python

gltemplate.py ../../data/athlete_fractal_1.xml3. Navigate with the mouse (hold Shift and Ctrl to pan and

zoom) to get a good screenshot of the robot4. Press ‘s’ to start simulating5. Take a screenshot, submit it in .jpg or .png format• Due next Wednesday• Ask your peers / myself for help installing• Document installation problems, email to me

([email protected])

Page 3: I400/I590/B659: Intelligent Robotics Preliminaries: Vectors

Agenda• Vector algebra: Representing and manipulating points and

directions in 2D, 3D, and higher dimensions

Page 4: I400/I590/B659: Intelligent Robotics Preliminaries: Vectors

Vectors• Represent physical quantities that exist in some “space”• Both direction and magnitude

• Represent ordered collections of related numbers• In this class:• 2D and 3D: Positions, velocities, accelerations, forces, pixel

positions…• Higher D: RGBA colors, configurations, robot-environment system

states, torques…

Page 5: I400/I590/B659: Intelligent Robotics Preliminaries: Vectors

Example #1• Bob is standing at point A. He moves north one meter. He then

moves east 2 meters. How far is he now from point A?

A

Page 6: I400/I590/B659: Intelligent Robotics Preliminaries: Vectors

Example #1• Bob is standing at point A. He moves north one meter. He then

moves east 2 meters. How far is he now from point A?

A

Page 7: I400/I590/B659: Intelligent Robotics Preliminaries: Vectors

Example #1• Bob is standing at point A. He moves north one meter. He then

moves east 2 meters. How far is he now from point A?

A

B

Page 8: I400/I590/B659: Intelligent Robotics Preliminaries: Vectors

Example #1• Bob is standing at point A. He moves north one meter. He then

moves east 2 meters. How far is he now from point A?

A

B

(0,0)

(2,1)

Page 9: I400/I590/B659: Intelligent Robotics Preliminaries: Vectors

Example #1• Bob is standing at point A. He moves north one meter. He then

moves east 2 meters. How far is he now from point A?

A

B

(2,1)

The displacement vector from A to B is (it is oriented vertically for reasons to be discussed later)

Page 10: I400/I590/B659: Intelligent Robotics Preliminaries: Vectors

Notation• A displacement vector starting at point A and ending at pint B

is denoted • Capitals• Not used much in this class

• A plain vector will be denoted • Point of origin is either unspecified, assumed, or does not need to

be made explicit to be meaningful (e.g., velocity)• Lowercase• Eventually we’ll drop the arrow

Page 11: I400/I590/B659: Intelligent Robotics Preliminaries: Vectors

Example #1• Bob is standing at point A. He moves north one meter. He then

moves east 2 meters. How far is he now from point A?

A

B

(2,1)

The length of the vector is .This is also known as the norm of the vector and is denoted .

?

Page 12: I400/I590/B659: Intelligent Robotics Preliminaries: Vectors

Norms• Definition: If is a vector, then • (Pythagorean theorem)

• [Subtle point: distance is not the same as distance traveled! Bob traveled 3m, but ended up about 2.23m away from the start]

Page 13: I400/I590/B659: Intelligent Robotics Preliminaries: Vectors

Comment• What about if Bob repeats the same procedure, arriving at

point C?

A

B

(2,1)C

Page 14: I400/I590/B659: Intelligent Robotics Preliminaries: Vectors

Comment• What about if Bob repeats the same procedure, arriving at

point C?

A

B

(2,1)C

(4,2)

Page 15: I400/I590/B659: Intelligent Robotics Preliminaries: Vectors

Comment• What about if Bob repeats the same procedure, arriving at

point C?

A

B

(2,1)C

(4,2)

(0,0)

The displacement vector from A to B is? The displacement vector from B to C is?The displacement vector from A to C is?

Page 16: I400/I590/B659: Intelligent Robotics Preliminaries: Vectors

Example #2: Multiplication• Dan is standing at point A. He moves in the same direction

that Bob originally did, but goes 50% farther. Where does he stand?

A

B

(2,1) D

Page 17: I400/I590/B659: Intelligent Robotics Preliminaries: Vectors

Example #2: Multiplication• Dan is standing at point A. He moves in the same direction

that Bob originally did, but goes 50% farther. Where does he stand?

A

B

(2,1)

Displacement vector from A to D is

D

Page 18: I400/I590/B659: Intelligent Robotics Preliminaries: Vectors

Scalar multiplication• To differentiate it from a vector, a “regular number” is known

as a scalar• Scalar-vector multiplication scales both elements of the vector

by the same amount. If a, b, and c are scalars, then:

• It commutes:

• Scalar division is the same as multiplying by 1/c

• [As usual, don’t divide by zero]

Page 19: I400/I590/B659: Intelligent Robotics Preliminaries: Vectors

Scalar multiplication• Scalar multiplication “passes through” the norm operation:

• (Why?)

Page 20: I400/I590/B659: Intelligent Robotics Preliminaries: Vectors

Points vs. Displacements• A point X in space can be represented for the purposes of

calculations (out of the realm of pure thought) as a displacement vector from some special reference point O, called the origin• The representation of a point P changes depending on the choice

of O• When comparing or manipulating two points, their

representations as vectors must use the same origin!• A displacement vector from point X to Y is the same regardless

of the choice of origin• [Note: what about the orientation of the reference axes? More

later]

Page 21: I400/I590/B659: Intelligent Robotics Preliminaries: Vectors

Example #3: Vector addition• Suppose Bob is at B=(2,1). Bob then moves South 2 meters

and east 3 more meters, arriving at E. What are E’s coordinates?

A

B (2,1)

E

(3,-2)

Page 22: I400/I590/B659: Intelligent Robotics Preliminaries: Vectors

Example #3: Vector addition• Suppose Bob is at B=(2,1). Bob then moves South 2 meters

and east 3 more meters, arriving at E. What are E’s coordinates?

A

B

(2,1)

E

(3,-2)

�⃗�𝐵+�⃗�𝐸= �⃗�𝐸

�⃗�𝐸=[21]+[ 3−2]=[ 5−1]Vector addition : produces a new vector in which ‘s first element is equal to the sum of the first elements of and , and its second element is equal to the sum of the second elements.

Page 23: I400/I590/B659: Intelligent Robotics Preliminaries: Vectors

Example #4: Vector subtraction• Dan is at back at D=(3,1.5). Along which vector would he have

to move in order to reach E=(5,-1)?

A

(3,1.5)

E

(5,-1)

�⃗�𝐷+�⃗�𝐸= �⃗�𝐸

�⃗� 𝐸=[ 5−1]−[ 31.5 ]=[ 2−2.5 ]

Vector subtraction : produces a new vector in which ‘s first element is equal to the first element of minus the first element of , and its second element is equal to the second element of minus the first element of .

D

�⃗�𝐸= �⃗�𝐸− �⃗�𝐷

Page 24: I400/I590/B659: Intelligent Robotics Preliminaries: Vectors

Vector subtraction: another view• With normal numbers, • With vectors, • (Try it)

Page 25: I400/I590/B659: Intelligent Robotics Preliminaries: Vectors

Distances• How far is D from E?

• Step 1: calculate • Step 2: calculate the norm

• In other words, the distance between D and E is

A

(3,1.5)

E

(5,-1)

D

?

Page 26: I400/I590/B659: Intelligent Robotics Preliminaries: Vectors

Interpolation• To go from D to E gradually, you can use linear interpolation

A

(3,1.5)

E(5,-1)

D

for u[0,1] a scalar parameter

Or…

Or…

Page 27: I400/I590/B659: Intelligent Robotics Preliminaries: Vectors

Higher dimensions• Everything is exactly the same, but the vectors contain more

elements• 3D: • 4D: • Etc…• Scalar-vector multiplication, vector addition and subtraction

remain essentially the same

Page 28: I400/I590/B659: Intelligent Robotics Preliminaries: Vectors

Norms in higher dimensions• 3D: if , then (why?)• 4D: if • Etc…

Page 29: I400/I590/B659: Intelligent Robotics Preliminaries: Vectors

Standard vector spaces• Cartesian space• 1D space: ℝ• 2D space: ℝ2

• Etc… ℝn

• It can be shown that any space of objects that transform like vectors do, with scalar-vector multiplication and vector-vector addition, is isomorphic to ℝn for some n*

*as long as it has finite dimension

Page 30: I400/I590/B659: Intelligent Robotics Preliminaries: Vectors

Cheat sheet• Notation for n-dimensional vectors:• , , etc

• Space of n-dimensional vectors: ℝn (Cartesian space)• Norm: • Scalar-vector multiplication: • Norms and scalar multiplications: • Vector-vector addition:

• Vector-vector subtraction:

• No such thing as vector-vector multiplication, vector-scalar addition.

Page 31: I400/I590/B659: Intelligent Robotics Preliminaries: Vectors

Implementation in Python• Lists:• E.g., [2,1], or [0.5,-0.8]• Operators +, -, *, / do not work in the same way• Use klampt.vectorops.{add,sub,mul,div}• Norm: klampt.vectorops.norm• Distance: klampt.vectorops.distance

• Numpy arrays:• E.g., numpy.array([2,1]), or numpy.array([0.5,-0.8]),• Operators +, -, *, / work as desired• Norm: numpy.linalg.norm• Distance: numpy.linalg.norm(x-y)

Page 32: I400/I590/B659: Intelligent Robotics Preliminaries: Vectors

Next time• Matrix algebra, linear transformations (Principles A.E)• No class on Monday