**Note:** some of the variable names will have changed from the video, specifically x, y, and h.

θ = theta = angle

x = horizontal distance

y = vertical distance

A right triangle is formed with h, x, and y. Thus, we can establish the following trigonometric identities:

sin(θ) = y / h

cos(θ) = x / h

Here, we are assuming that we know the angle θ (for example, from a gyro sensor or IMU) and the distance h as measured by a sensor. We can use this information to calculate the distances x and y by using the trigonometric identities listed above:

y = h sin(θ)

x = h cos(θ)

Let us define h=h1+h2. h is therefore the total length of the hypotenuse in the right triangle. Since we know the horizontal distance x, which is the width of the field, we can therefore find the angle θ.

Let us first establish the following trigonometric identities by simply taking the reverse of the previous identities discussed (note that arcsin is the inverse function of sin):

θ = arcsin(y / h)

θ = arccos(x / h)

By these identities, we can simply plug in h we measure with our sensors to get θ = arccos((4 feet)/h), and thus we have the angle the robot is facing. Note that the angle you get won’t be able to distinguish whether the robot is pointing towards h1 or h2. Note the following image will yield the same angle theta, but the robot will be oriented differently.

Note first the difference between radians and degrees. They are both ways of measuring angles. There there are 360 degrees in a circle, whereas there are 2π radians in a circle. Therefore, 1 degree = π/180 radians.

In RobotC, these are the function calls for trigonometric functions:

`asin(y/h)`

returns the arcsine in radians (arcsin(y / h)).

`acos(y/h)`

returns the arccosine in radians (arcsin(x / h)).

`sin(θ)`

returns the value of y/h for an angle θ in radians.

`cos(θ)`

returns the value of x/h for an angle θ in radians.

`sinDegrees(θ)`

returns the value of y/h for an angle θ in degrees.

`cosDegrees(θ)`

returns the value of x/h for an angle θ in degrees.

`radiansToDegrees(θ)`

returns the angle in degrees for a given angle θ in radians.

`degreesToRadians(θ)`

returns the angle in radians for a given angle θ in degrees.

Note that the values you get back from the sensor may not be exactly accurate. First, the value an ultrasonic or infrared sensor returns can vary from the true result, especially at long distances, since practically its is impossible to make a perfectly accurate sensor. In particular, both the infrared and ultrasonic sensors have a maximum distance it can sense up to, and the ultrasonic sensor will give junk values if it is placed directly up to something (when the distance between the object and the sensor is very low). In other cases, they should be fairly accurate.

Another thing to note is that ultrasonic sensors don’t see in a straight line, but instead a cone. That means the value you get back will be approximately the closest distance to any obstacle inside a conical region in front of it, as demonstrated by the image below.

In the diagram below, even though the obstacle (denoted by the black circle) is not directly in front of the sensor, since it is in the conical field of view the sensor will not return the distance to the wall but instead something closer to the distance to the obstacle.

Finally, some infrared sensors (such as the LEGO EV3 infrared sensor) don’t provide an absolute distance measurement; they must first be converted to distances, and their values may change depending on the color of the surface.

Motor encoders measure how many degrees a motor has rotated. So if the motor encoder value reported is 720, the motor has gone 2 full rotations. Therefore, the formula to calculate the number of rotations is (# of rotations) = (# of degrees)/360°. Let (# of rotations) = r and (# of degrees) = n. Thus, r = n/360°.

**Note**: in the stock graphical LEGO software, encoder values can be provided as either rotations or degrees.

First, we can easily find the circumference of a wheel by finding the radius and applying the equation c = 2πr. Note that the circumference c is how far the robot moves with one rotations of the motor (and thus the wheel).

The equation d = c*r is true to find the distance d the robot moves with r rotations. Since r = n/360°, d = c*n/360°. By simply rearranging the equation, we get n = d*360/c°. Therefore, given the distance we want to travel, we know how many degrees the motor needs to spin. This can be used in conjunction with a loop or similar to implement a moving function.

To turn a certain angle in place, we can execute a point turn where the robot’s two motors turn in opposite directions. Thus, when the robot turns 360°, each motor traces the circumference of a circle with a diameter of the distance between the robot’s wheels.

If we define the wheelbase (the distance between the wheels) to be w, we can calculate the circumference of this circle with πw. To turn an arbitrary amount, we multiply this circumference by the ratio of the angle desired a to one full revolution: a/360°. Now that we know the distance that each wheel needs to travel, we can apply the equations from moving in straight lines; the only difference is that one wheel is rotating in the opposite direction. Therefore the equation for the degrees a motor needs to turn is n = aπw/(360c) where c is the circumference of the wheel.

- Resources
- Resources for learning how to program in RobotC, including basic programming constructs and accessing sensors and motors, can be found on the Storming Robots site.
- Please sign up for the forum if you have not done so already. There you can post any questions or concerns you may have. Instructions are on last week’s recap.

- Sensors
- Touch
- Detects when it pushes against something (like a button). Can potentially be used to detect if the robot hits a wall or the other robot.

- Light
- Measures how much light is reflected back (white reflects more than black). Can be used to detect what color the robot is on, white or green. Since penalty boxes, the midfield line, etc are white, the light sensor may be used to help determine the location of the robot.

- Ultrasonic/Infrared
- Measures the distance from the sensor to an object, such as a wall. Can also be used to determine the location of the robot, specifically to see if its getting too close to a wall.

- Gyro
- Measures the rotation of the robot. In other words, it can help you figure out what direction the robot is facing.

- Motor Encoder
- Measures how many times the motor has spun. Can possibly be used to aid movement functions (figure out how far the robot has moved) and other applications. This functionality is built right into the motor and does not need a seperate sensor.

- Cameras
- Can track different blobs of color and return their location. Essential for tracking the orange ball. We will go more into this topic in a future meeting.

- Allowed sensors
- A full list of allowed sensors will be released with the rules. Tentatively, first party sensors (sensors made by LEGO) and third party sensors from Mindsensors and HiTechnic will be allowed. For cameras, PixyCam and NXTCam from Mindsensors will be allowed. If there are any sensors that are not on the approved list, please reach out to the organizers through the forum.

- Touch
- Summary of rules Q&A
- To rephrase the rules, the robot must fit within a circle 23cm in diameter.
- A “handle” is simply something that allows referees to easily pick up the robot without causing damage. It can be made out of anything; a loop of zip-ties connected together will do.

- What to do before the next meeting
- We recommend continuing in planning the robot design, especially with the understanding of the available sensors in mind.

Full meeting recording:

]]>- Philosophy of the competition
- The goal of the competition was to create an experience that had a low bar to entry. We found that may established competitions have a large focus on hardware, so much so that both the difficulty of starting a team and the cost to entry were unreasonably high. This competition attempts to alleviate the issue by employing a more unified hardware platform. Therefore, we seek to restrict hardware to what is easily available to all competitors.

- Sources of information
- The home page for the entire competition is legosoccer.stormingrobots.com. This may be merged with the blog in the future.
- Our primary means of pushing out information will be through the blog. It can be found at stormingrobots.com/blog/category/lego-soccer/.
- Ask questions regarding the competition on the forum (the “LEGO Soccer League” category). You must make an account. For the username, please use your real name. The “secret word” is “r2d2”. The account will need to be approved by the forum administrator before you can use it.

- Hardware and Software
- For programming the robot, we recommend using RobotC, but other options like ev3dev (for the very advanced) and the native block programming are acceptable.
- You must be using a LEGO NXT or EV3 (or RCX but they are very outdated). Teams are responsible for obtaining the hardware themselves.
- See more detailed hardware restrictions in §1 of the rules.

- What to do before the next meeting
- Read the rules, which can be found on the blog and the main page.
- Start forming teams

**NOTE:**The maximum team size for the full game league is 4 participants, not 3. We stated during that the maximum team size for the full game was 3. The website also currently shows 3 as the maximum size, and should be corrected soon. - Start brainstorming for the hardware implementation. Start thinking about what sensors you would like to have. We will be going more into this next meeting.

Full meeting recording:

]]>