robot and maths
TRANSCRIPT
-
8/4/2019 Robot and Maths
1/17
Introducing
MathematicalConceptsthrough Robots
-
8/4/2019 Robot and Maths
2/17
Caluclating the Circumference
The circumference of a circle is the length around it.The circumference of a circle can be calculated from its diameter using the formula:
Or, substituting the radius for the diameter:
where ris the radius and dis the diameter of the circle, and the Greek letter is defined as the ratio of
the circumference of the circle to its diameter. The numerical value of is 3.141 592 653 589 793....
-
8/4/2019 Robot and Maths
3/17
Calculating Distance to Move
Distance = Rotations * 360 = DegreesCircumference
-
8/4/2019 Robot and Maths
4/17
Worksheet:
Directions: Given the known values of the diameter of a Robot wheel and the distance between
wheels on the Robot, calculate the degrees of rotation needed and movement block programming for
the robot to complete the following moves:
Given Values:
Robot wheel diameter: 5.6 cm
Distance between wheels: 11.3 cm
Pi: 3.14
Degrees in a Circle: 360
Drive straight line forward 20 cm. (20 cm)
Straight Line:
1. Figure out the circumference of the Wheel:
Circumference = 3.14 * 5.6 cm (Diameter)
Circumference =
2. Figure out the number of rotations needed to go the distance
Distance
Circumference= Rotations
3. Change Rotations to Degrees for Motor Block Commands.
Rotations * 360 = (Degrees)
-
8/4/2019 Robot and Maths
5/17
Swing Turn Left 45 degrees
Swing Turn:
1. Figure out the circumference of the Wheel:
Circumference = 3.14 * 5.6 cm (Diameter)
Circumference =
2. Calculate the Circumference of the big circle the robot would make if it turned all the wayaround in a swing turn.
Big Circumference = 3.14 * Distance Between Robot Wheels * 2
3. Calculate the arc segment the robot wheel has to travel to make the swing turn:
Degree of Turn
360
* Big Circumference = Arc Segment
4. Figure Out wheel rotations needed to travel arc segment:
Arc Segment
Wheel Circumference= Rotations
5. Change Rotations to Degrees for Motor Block:
Rotations * 360 = (Degrees)
6. Decide which wheel to rotate:
Turning Left -> use wheel on right side of robot
Turning Right -> use wheel on left side of robot
-
8/4/2019 Robot and Maths
6/17
Point Turn Right 180 degrees.
Point Turn:
1. Figure out the circumference of the Wheel:
Circumference = 3.14 * 5.6 cm (Diameter)
Circumference =
2. Calculate the Circumference of the big circle the robot would make ifit turned all the way around in a point turn.
Big Circumference = 3.14 * Distance Between Robot Wheels
3. Calculate the arc segment the robot wheel has to travel to make the swing turn:
Degree of Turn
360
* Big Circumference = Arc Segment
4. Figure Out wheel rotations needed to travel arc segment:
Arc Segment
Wheel Circumference= Rotations
5. Change Rotations to Degrees for Motor Block:
Rotations * 360 = (Degrees)
6. Decide which wheels to rotate:
Turning Left ->
Right wheel forward Number of Degrees, Left wheel backward Number of Degrees.
Turning Right ->Left wheel forward Number of Degrees, Right wheel backward number of Degrees.
-
8/4/2019 Robot and Maths
7/17
The X/Y Coordinate System in NXT
The LCD screen has a horizontal resolution of 100 pixels and a vertical resolution of 64
pixels. This simply means you could place 100 small dots across the screen and 64 small dotsdown the screen. Values actually start with a zero, so the range of coordinates for X is 099,
and for Y, the range is 063.
When using the DISPLAY block (or any block where you must specify a location on the
LCD screen), you specify a location by using its horizontal value (X coordinate) and its
vertical value (Y coordinate). So, to place a pixel (or dot) directly in the center of the screen,
you would have a DISPLAY block place a Point with an X coordinate of 50 and a Y
coordinate of 32.
To summarize, the X/Y value of a pixel in the lower-left corner is 0/0. For the upper-right
corner, the value would be 99/63. Remember, the Y value increases only as you move up the
LCD screen, so the value of a pixel in the upper-left corner is 0/63, and a pixel in the lower-
right corner is 99/0.
-
8/4/2019 Robot and Maths
8/17
The Math Block
The 'Math' block (located in the 'Advanced' section in the 'complete palette' tab) is used to
carry out mathematical operations on inputs. The NXT robot can do some very simple math:
addition, subtraction, multiplication, and division. The figure below shows the MATH block
and its configuration panel.
In the Operation section, there is a drop-down menu for you to select the type of operation
to be performed. If you click the drop-down menu, you should see the following options:
Addition:This option will add values A and B. Subtraction:This option will subtract value B from value A.
Multiplication:This option will multiply value A by value B. Division:This option will divide value A by value B. Absolute value:This option will calculate the absolute value of A. Square root:This option will calculate the square root of value A.
The MATH block uses two values: A and B. For the NXT-G 1.0 users, these values can be
positive or negative integers. An integeris a whole number with no decimal values. If you
attempt to enter in a number such as 4.3 or 10.8 the MATH block will round the values up
or down to the nearest integer (4 and 11 for my examples). But for NXT-G 2.0 users, you
are not limited to integer math. Decimal values are allowed.
-
8/4/2019 Robot and Maths
9/17
The data hub on the MATH block shows that there are two input data wire plugs (one for
value A and one for value B) and three output data wire plugs. The MATH block requires one
or two integer values, depending on the option you selected in the Operation section: if A or
B is left blank, its value defaults to 0, except for Absolute Value or Square Root where only
Value A is used.
Numbers can be entered manually by typing a value for A and a value for B in the
configuration panel, or they can be provided by running one data wire into plug A and
another data wire into plug B.
Example:
Try the sample program (taken from LEGO MINDSTORMS NXT-G Second Edition
Programming Guide) that makes use of two random numbers (generated by two RANDOM
blocks). Each RANDOM block uses its output data plug to run a wire into the A and B input
data plugs on the MATH block.
Once values A and B have been added together, you want to see the answer on the LCD
screen. To do this, you have to first convert the number to text. Drop in a NUMBER TO
TEXT block and drag a data wire from the Result data plug on the MATH block into the
Number data plug on the NUMBER TO TEXT block.
In order to see the answer on the Bricks LCD screen, drag a data wire out of the Text data
plug on the NUMBER TO TEXT block and into the Text data plug on the DISPLAY block.
-
8/4/2019 Robot and Maths
10/17
The Random Block
The 'Random' block (located under the 'Data' section in the 'complete palette' tab) is used to
generate a random number between the range specified in its properties. You can use the
slider to adjust between 0 and 100 or simply type in the range into the input boxes if different
ranges are needed.
.
-
8/4/2019 Robot and Maths
11/17
Calculate Area and Volume(taken from nxtprograms.com)
1. Which formula to use?
AREA = Length x Width VOLUME = Length x Width x height
2. Lets build the measuring device.
This simple device can be used to calculate length, area, and volume by rolling the wheel
along surfaces. The NXT does the math and displays the results on the screen in both metric
and English units.
-
8/4/2019 Robot and Maths
12/17
-
8/4/2019 Robot and Maths
13/17
-
8/4/2019 Robot and Maths
14/17
-
8/4/2019 Robot and Maths
15/17
-
8/4/2019 Robot and Maths
16/17
3. It is time to create the program (instructions) that will automatically work out thearea and volume on our behalf.
-
8/4/2019 Robot and Maths
17/17
Getting Length .
Getting Width and working out the Area
Getting Height and working out the Volume
Have a look at the video:
http://www.youtube.com/watch?v=OXgg6SWaAJc