## Introduction

Howdy All,

Today I am going to be talking about some design work I've been doing for Ardie. If you recall, I recently discussed testing two new sensors for Ardie that I would be using for his eyes here. Since the tests went well, my next step was to determine where and how I wanted to mount those sensors on Ardie. In order to do that, I put together some schematics and Matlab code. Laying out the geometry of the sensors in the schematics allowed me to derive the mathematical relationships between where I mounted the senors, and what the field of view (FOV) of the sensors in front of Ardie would be. I could then use this math in Matlab code to vary the sensor mounting locations to determine which positions gave Ardie the optimal viewing field.

Today I am going to be talking about some design work I've been doing for Ardie. If you recall, I recently discussed testing two new sensors for Ardie that I would be using for his eyes here. Since the tests went well, my next step was to determine where and how I wanted to mount those sensors on Ardie. In order to do that, I put together some schematics and Matlab code. Laying out the geometry of the sensors in the schematics allowed me to derive the mathematical relationships between where I mounted the senors, and what the field of view (FOV) of the sensors in front of Ardie would be. I could then use this math in Matlab code to vary the sensor mounting locations to determine which positions gave Ardie the optimal viewing field.

## Describing the Sensor Geometry

In order to properly describe the sensor geometry I had to hash out some terminology. First and foremost, I knew that the sensors had a 10 degree cone of vision off of their center line thanks to page 5 of the parallax ping sensor spec sheet found here. I decided to call this angle the gamma angle, and it is properly denoted by the greek symbol in Figure 1 below.

Furthermore, I began developing a nomenclature for other geometries on Ardie. The beta angle shown in Figure 1 depicts the angle between the center of view line of one of the ping sensors, and the "vertical," within the picture. This vertical is sometimes noted as the n vector, or the normal. Furthermore, the horizontal dimensions on the schematic above are described in terms of w, the width in centimeters of Ardie's primary platform. This was measured to be 7.8 cm. The vertical measurements are described in terms of h. At the present time, there is only about three centimeters worth of "vertical," area on which to mount the sensors. Thus, the maximum value of h is 3.0 cm. This could change pending a redesign of Ardie's primary frame.

For this design, I decided to mount the sensors with a beta angle of ~7 degrees. The sensors have a FOV angle (gamma) of 10 degrees, which is the maximum value of beta that I could use. However, such a design would result in the two fields never intersecting and, thus, an infinite deadzone would exist directly in front of Ardie. A beta angle of seven degrees gives me an intersection some distance off of Ardie's front bumper, but also allows a little bit of FOV margin in case Ardie intersects any strangely shaped objects in his path that don't return the ultrasonic ping signal directly back to the source.

One of the disadvantages of this design decision, however, is that there will be a FOV deadzone out in front of Ardie, as well as at the right and left corners due to the conical nature of the senor fields. The front deadzone will resemble a tall triangle and will exist in the area between the two sensor FOV's before they intersect. So long as nothing gets dropped directly in front of Ardie, this deadzone should be allowable as the intersection of the two FOV's at some distance (h_d) off of Ardie's front bumper will allow Ardie to maneuver around objects before they enter this deadzone.

The corner deadzones could pose a problem however.

Nonetheless, these deadzones became the primary drivers in my design. By describing the height of the central deadzone off of Ardie's front bumper (h_d), as well as the width from Ardie's centerline to the inner edge of each FOV (w_d), and the width from the FOV outer edge to the edge of Ardie's frame (w_side), I could determine just how large, and therefore dangerous, each sensor deadzone could be.

For this design, I decided to mount the sensors with a beta angle of ~7 degrees. The sensors have a FOV angle (gamma) of 10 degrees, which is the maximum value of beta that I could use. However, such a design would result in the two fields never intersecting and, thus, an infinite deadzone would exist directly in front of Ardie. A beta angle of seven degrees gives me an intersection some distance off of Ardie's front bumper, but also allows a little bit of FOV margin in case Ardie intersects any strangely shaped objects in his path that don't return the ultrasonic ping signal directly back to the source.

One of the disadvantages of this design decision, however, is that there will be a FOV deadzone out in front of Ardie, as well as at the right and left corners due to the conical nature of the senor fields. The front deadzone will resemble a tall triangle and will exist in the area between the two sensor FOV's before they intersect. So long as nothing gets dropped directly in front of Ardie, this deadzone should be allowable as the intersection of the two FOV's at some distance (h_d) off of Ardie's front bumper will allow Ardie to maneuver around objects before they enter this deadzone.

The corner deadzones could pose a problem however.

Nonetheless, these deadzones became the primary drivers in my design. By describing the height of the central deadzone off of Ardie's front bumper (h_d), as well as the width from Ardie's centerline to the inner edge of each FOV (w_d), and the width from the FOV outer edge to the edge of Ardie's frame (w_side), I could determine just how large, and therefore dangerous, each sensor deadzone could be.

## Calculating the Height Intercept (h_int)

Figure 2: This image shows the geometry used to derive the

relationship between h_int, w_b, beta, and gamma.

relationship between h_int, w_b, beta, and gamma.

The first step in properly describing the sensor FOV geometry, therefore, was determining how far the central deadzone stretched out in front of Ardie. To keep my design simple (and to simplify the control laws that I will develop for Ardie later) I decided to keep the geometry of the two sensors symmetric. This also had the added benefit of simplifying the computation of h_int, the vertical distance from the sensors to the intersection of the inner edges of the two sensor FOV's.

To analyze this geometry properly, I drew a "zoomed in" version of the diagram posted above. This is shown as Figure 2. In order to determine h_int, I described the horizontal distance from Ardie's centerline to a single sensor mounting location as w_b (width to sensor B). Furthermore, I named the angle between Ardie's central normal vector (depicted in dotted black) and the sensor's inner FOV line (depicted in dotted green) eta (looks like a crooked '3' at the top of the diagram). Using basic trig, we can see that:

tan(eta) = w_b / h_int

If we describe eta in terms of gamma and beta, we can fully describe h_int based on known design parameters. In order to do this, we need to develop a few more angles on Figure 2. Note that theta is the angle between the sensor FOV center line (solid green) and the horizontal reference. Psi is the angle between the inner edge of the sensor FOV (dotted green) and the horizontal reference. Phi is the angle between the inner edge of the sensor FOV and the vertical normal. Mu is the compliment to Psi. While these are depicted (lightly) in Figure 2, it may help to refer to the original design documents for reference. Knowing these angles, we can describe eta in terms of gamma and beta as follows:

To analyze this geometry properly, I drew a "zoomed in" version of the diagram posted above. This is shown as Figure 2. In order to determine h_int, I described the horizontal distance from Ardie's centerline to a single sensor mounting location as w_b (width to sensor B). Furthermore, I named the angle between Ardie's central normal vector (depicted in dotted black) and the sensor's inner FOV line (depicted in dotted green) eta (looks like a crooked '3' at the top of the diagram). Using basic trig, we can see that:

tan(eta) = w_b / h_int

If we describe eta in terms of gamma and beta, we can fully describe h_int based on known design parameters. In order to do this, we need to develop a few more angles on Figure 2. Note that theta is the angle between the sensor FOV center line (solid green) and the horizontal reference. Psi is the angle between the inner edge of the sensor FOV (dotted green) and the horizontal reference. Phi is the angle between the inner edge of the sensor FOV and the vertical normal. Mu is the compliment to Psi. While these are depicted (lightly) in Figure 2, it may help to refer to the original design documents for reference. Knowing these angles, we can describe eta in terms of gamma and beta as follows:

theta = 180 - ( 90 + beta)

thus

theta = 90 - beta

phi = gamma - beta by defintion

psi = theta + phi + beta by definition

thus

(90 - beta) + (gamma - beta) + beta = psi

90 + gamma - beta = psi

mu = 180 - psi by definition

thus

mu = 180 - (90 + gamma - beta)

mu = 90 - gamma - beta

since mu and eta are in a right triangle defined by h_int, w_b, and the centerline:

eta = 90 - mu

eta = 90 - (90 - gamma + beta)

thus

eta = gamma - beta

And we finally arrive at the conclusion that:

tan(eta) = tan(gamma - beta) = w_b / h_int so

h_int = w_b / (gamma - beta)

thus

theta = 90 - beta

phi = gamma - beta by defintion

psi = theta + phi + beta by definition

thus

(90 - beta) + (gamma - beta) + beta = psi

90 + gamma - beta = psi

mu = 180 - psi by definition

thus

mu = 180 - (90 + gamma - beta)

mu = 90 - gamma - beta

since mu and eta are in a right triangle defined by h_int, w_b, and the centerline:

eta = 90 - mu

eta = 90 - (90 - gamma + beta)

thus

eta = gamma - beta

And we finally arrive at the conclusion that:

tan(eta) = tan(gamma - beta) = w_b / h_int so

h_int = w_b / (gamma - beta)

Further inspecting Figure 2 also allows us to determine the distance from Ardie's center line to the inner edge of a sensor's FOV.

## Calculating Inner FOV Border (w_d)

Figure 3: Notice that w_d (marked in the upper left corner) completes

a triangle very similar to the triangle completed

by w_b (marked in the lower left of the picture).

a triangle very similar to the triangle completed

by w_b (marked in the lower left of the picture).

Determining the distance between Ardie's centerline and the sensor's inner FOV edge is fairly simple after determining h_int. Notice that the triangle in Figure 2 made by the geen dotted line, the black dotted line, and w_b contains a smaller triangle made by the green dotted line, the black dotted line, and the width marked w_d in Figure 3. Also notice that, while tan(eta) could describe the relationship w_b / h_int, it could also describe the relationship of w_d / h_d if we define h_d as the distance between Ardie's front bumper and the intersection point of both sensor's FOV's (h_int). If the vertical distance between Ardie's front bumper and the sensor is described as h_b, we can define h_d as h_int - h_b. Finally, knowing the relationship between eta, beta, and gamma that we found in the last section allows us to write w_d as:

w_d = (h_int - h_b) * tan(gamma - beta) = h_d * tan(gamma - beta)

w_d = (h_int - h_b) * tan(gamma - beta) = h_d * tan(gamma - beta)

## Calculating Outer FOV Border (w_side)

Figre 4: A close up of sensor B's FOV, as well as some corresponding

triangles necessary for design.

triangles necessary for design.

The final step in determining the sensor FOV geometry is a bit more involved. Basically I needed to find the total width across the front bumper encompassed by a single sensor's FOV. I could then subtract that total width, as well as w_d from the total width of Ardie's front bumper to determine how much, if any, of Ardie's front, outer corner sat in a deadzone. In order to do this, I needed to develop the triangles depicted in Figures 4 and 5.

Figure 4 depicts the entire FOV triangle of sensor B denoted by the two thin, black, solid lines, and leftmost, thin, canted, dashed black line. There are also two widths called out in Figure 4: w_delta, and w_delta_2. Figure 5 elaborates on this geometry a little more, showing exactly what w_delta_2 corresponds to, while also defining two other widths: w_edge, and w_f, such that w_edge = w_delta_2 + w_f.

Figure 4 depicts the entire FOV triangle of sensor B denoted by the two thin, black, solid lines, and leftmost, thin, canted, dashed black line. There are also two widths called out in Figure 4: w_delta, and w_delta_2. Figure 5 elaborates on this geometry a little more, showing exactly what w_delta_2 corresponds to, while also defining two other widths: w_edge, and w_f, such that w_edge = w_delta_2 + w_f.

Futher inspection of both figures shows that w_delta corresponds to the horizontal distance between the inner edge FOV line and the FOV center line (two thin, black, solid lines in Figure 4). Meanwhile, w_delta_2 and w_f must be summed in order to equate the horizontal distance between the FOV center line and the outer FOV edge line (solid blue and dashed blue lines in Figure 5). Knowing this, we can determine that w_side corresponds to the distance between the outer edge FOV line (dashed blue in Figure 5) and Ardie's outer edge. Therefore, w_side exists in a corner deadzone and, by definition, is equal to:

w_side = (w_ardie / 2) - (w_d + w_delta + w_delta_2 + w_f)

... where w_ardie = Ardie's total width (7.8 cm). It is divided by two because we are talking about one half of Ardie.

It is possible to determine the values of w_edge, w_delta, w_delta_2, and w_f from trigonometry alone. However, going into these detailed derivations is beyond the scope of this blog. If you would like to see these derivations, you are encouraged to download the raw design documents and touched up design document images from my dropbox account as the calculations are all performed by hand there. Inspecting those documents will reveal that:

w_delta = h_b * ( tan(gamma - beta) + tan(beta) )

w_delta_2 = h_b * tan (gamma)

w_f = a * sin(beta) * tan(gamma - beta)

therefore:

w_edge = h_b * tan(gamma) * ( tan(beta) * tan(gamma + beta) + 1)

and:

w_side = (w_ardie / 2) - (w_d + w_delta + w_edge)

w_delta_2 = h_b * tan (gamma)

w_f = a * sin(beta) * tan(gamma - beta)

therefore:

w_edge = h_b * tan(gamma) * ( tan(beta) * tan(gamma + beta) + 1)

and:

w_side = (w_ardie / 2) - (w_d + w_delta + w_edge)

## Matlab Code

Once I had all the math figured out I needed to feed it into a computer program to help me determine the optimal geometry for Ardie's new sensors. Thus, I created two loops in Matlab. The first would vary the vertical sensor location from 0.0 cm (bottom of the diagrams) to 3.0 cm (front bumper edge in the diagrams) by 0.2 cm each step. The second would vary the horizontal sensor location by 0.2 cm from the centerline to the outer edge (w = 0 to w = 3.9). Each loop would calculate the design parameters discussed here, while plotting up a nice looking schematic of each sensor. Furthermore, the design parameters would be output two two data text files (one for sensor A and one for sensor B) so that I could inspect the design values numerically.

The source code for this program can be found in my dropbox here. The outputs from the program corresponding to the design I selected can be found here.

The source code for this program can be found in my dropbox here. The outputs from the program corresponding to the design I selected can be found here.

## Conclusion

In the end I settled for a bit of a compromise. I decided to place each sensor at a vertical height (off of the bottom line in the schematics) of 0.6 centimeters. I decided to place them at a horizontal distance (from Ardie's centerline) of 1.5 centimeters in either direction. This geometry will give Ardie a forward looking deadzone that is ~ 30 centimeters long and ~2.7 centimeters wide. Hopefully the overlapping of the sensors past 30 centmeters will allow Ardie enough time to react before colliding with any objects. Furthermore, the geometry gave a corner deadzone that is ~ 1.66 centimeters wide at either corner for Ardie. I am hoping these deadzones will be small enough that Ardie will not hook his corners on anything as he navigates. The geometry is depicted in Figure 6 below.

Figure 6: Pictured is the final geometry of Ardie's sensors. The green field on the left shows sensor A's FOV. The red field on the right shows sensor B's FOV. The middle deadzone is depicted as the vertical triangle defined by the right green line and the left red line that intersect at the dotted black center line. The corner deadzones are around the black corners of Ardie's body which are not encompassed by either FOV.

The goal of this project was to force myself to use mathematics to design an optimal geometry for placing Ardie's new rangefinder sensors. These sensors will be used to detect obstacles. They will tell Ardie how far any obstacles are from him in his direction of travel. He will then use this information to throttle his two wheels separately in order to avoid said obstacles. Thus, getting the sensor geometry correct is imperative.

Furthermore, this geometrical math will be useful when writing the control laws for Ardie that will govern the use of these sensors.

All in all, the project was fun. However, while applied mathematics can be interesting, it isn't nearly as fun as actually buidling something. So my next robotics blog should involve some tinkering and building, rather than all of this theoretical simulation stuff. Until then,

Good Luck, and Good Hacking!

Brady C. Jackson

Furthermore, this geometrical math will be useful when writing the control laws for Ardie that will govern the use of these sensors.

All in all, the project was fun. However, while applied mathematics can be interesting, it isn't nearly as fun as actually buidling something. So my next robotics blog should involve some tinkering and building, rather than all of this theoretical simulation stuff. Until then,

Good Luck, and Good Hacking!

Brady C. Jackson