# Design of a Bio-Inspired Optical Compass for Education Purposes

Stéphane Viollet, Nicolas Thellier, Nicolas Thouvenel, Julien Diperi, Julien R. Serres

► To cite this version:

Stéphane Viollet, Nicolas Thellier, Nicolas Thouvenel, Julien Diperi, Julien R. Serres. Design of a Bio-Inspired Optical Compass for Education Purposes. ROBOTICS IN EDUCATION, RIE 2022, Practical Robotic Institute Austria and Slovak University of Technology in Bratislava, Apr 2022, Bratislava, Slovakia. pp.161-172, 10.1007/978-3-031-12848-6
15.hal – 03989729

HAL Id: hal-03989729

https://amu.hal.science/hal-03989729

Submitted on 15 Feb 2023

HAL is a multi-disciplinary open access
archive for the deposit and dissemination of sci-
entific research documents, whether they are pub-
lished or not. The documents may come from
teaching and research institutions in France or
abroad, or from public or private research centers.

L'archive ouverte pluridisciplinaire HAL, est
destinée au dépôt et à la diffusion de documents
scientifiques de niveau recherche, publiés ou non,
émanant des établissements d'enseignement et de
recherche français ou étrangers, des laboratoires
publics ou privés.

<figure><img src="image_1.png" /></figure>

Distributed under a Creative Commons Attribution 4.0 International License
# Design of a Bio-inspired Optical Compass for Education Purposes

Stéphane Viollet<fnref n="1" />, Nicolas Thellier<fnref n="2" />,<fnref n="3" />, Nicolas Thouvenel<fnref n="1" />,<fnref n="3" />, Julien Diperi<fnref n="1" />, and Julien R Serres<fnref n="1" />

**Abstract.** This study concerns the development of an optical compass inspired by the celestial compass of the desert ant *Cataglyphis*. This bio-inspired navigational instrument opens up new opportunities for navigation in the absence of GNSS or GSM coverage for locating outdoors. This pedagogical activity, through the design of the instrument, aims at understand different physical phenomena involved in optical heading detection: Rayleigh scattering of sunlight in the sky, polarization of light and measurement of heading from photosensors. The design and the fabrication of an experimental teaching device are both described. Experiments were performed to allow students (2nd year of master in robotics & IoT) to become familiar with bio-inspired engineering applied to optical heading detection. Students used an Arduino board (8-bit architecture) to address issues related to the real-time processing of microcontroller with limited computational capabilities. Finally, examples of measurements made by students are presented to demonstrate the pedagogical use of such an experimental device for heading measurement in robotics. Our prototype works in the blue visible light and has only 4 photosensors, each one covered with a different orientation of its polarizing filter.

**Keywords:** Bio-inspired engineering · biomimicry pedagogy · optical devices · robotics · insect vision · education · tutorial.

**Acronyms:** Computer Aided Design (CAD) · Global Navigation Satellite System (GNSS) · Global System for Mobile communications (GSM) · Internet of Things (IoT) · Light-Emitting Diode (LED) · Least Mean Squares (LMS).

## 1 Introduction

The aim of this study is to present an experimental setup to develop pedagogical activities around bio-inspired robotics. The setup relies mainly on a device,

<footnote n="1">¹Aix Marseille Univ, CNRS, ISM, Marseille, France</footnote>

<footnote n="2">²Univ. Toulon, Aix Marseille Univ., CNRS, LIS, DYNI team, SABIOD, Marseille, France</footnote>

<footnote n="3">³Univ. Toulon, Master ISC ROC, France</footnote>

<footnote>stephane.viollet@univ-amu.fr</footnote>

<footnote>julien.serres@univ-amu.fr</footnote>

<footnote>http://www.ism.univ-amu.fr/viollet/</footnote>

<footnote>http://www.ism.univ-amu.fr/serres/</footnote>
which is an optical compass that allows to measure a heading in relation to
the state of polarization of the light in the sky [1]. This type of compass has
been recently used at the Institute of Movement Sciences (Marseille, France)
on board a biomimetic robot, called AntBot [2,3], and on board a car [4], in
an open source project<fnref n="1" />,<fnref n="2" />. AntBot was able to navigate without cartography,
GNSS, GSM nor even a magnetometer in order to return to its starting point in
a straight line like the desert ant *Cataglyphis* [5]. This optical device was used
with 2nd year students of master in robotics & IoT in the form of a tutored
project lasting fifteen hours, where students acquired knowledge based on two
scientific papers explaining two different methods of heading estimation [6,7].
Then, students choose one of the two methods to work in pairs or in trinominal,
and finally had to program it on board an Arduino board (8-bit architecture)
to estimate the heading. A mechanical design phase was also planned during
the project (3 hours of CAD design) to build a tray containing the photosensors
used for heading estimation and an emitting blue LED covered with a polarizing
filter playing the role of the artificial sky.

## 2 Optical compass design

### 2.1 Polarized light from the sky

From a physical point of view, it is well known since Rayleigh and his work on the propagation of light in the Earth's atmosphere where there are interactions between photons and molecules in our atmosphere that lead to a linear polarization of the light from the sky in a regular and symmetrical pattern with respect to the solar meridian and whose spatial organization depends on the position of the sun in the sky [8]. We therefore have on the one hand a well known and modelled physical phenomenon and on the other hand a biological principle exploiting this physical phenomenon for the measurement of the heading [8].

For navigational purposes, we know that desert ants [5], bees [8], monarch butterflies [9], and many other insects use polarized light from the sky to estimate their course, an essential component of navigation. Polarized light from the sky can be seen as vectors whose orientations (polarization angle) are distributed in concentric circles centered around the sun (Fig. 1). The orientation of each electric polarization vector (e-vector) is always defined with respect to the solar meridian. The vector pointing to the maximum polarization intensity *I*<sub>pmax</sub> in the sky is a vector perpendicular to the axis passing through the center of the Earth and the sun (solar vector). Thus, the polarized light from the sky is minimal when the sun is at zenith, and maximal at sunset and sunrise (Fig. 2).

Human beings are not sensitive to the polarization of light in the sky. Therefore, the sky appears uniform as shown in Fig. 1A. In this photograph of the sky,

<footnote n="1">¹ GitHub JuSquare, AntBot, https://github.com/JuSquare/AntBot</footnote>

<footnote n="2">² Julien Serres' website, The ant-inspired robot AntBot navigates autonomously in unknown outdoor environments without GPS and using only 14 pixels, http://www.ism.univ-amu.fr/serres/en/antbot.html</footnote>
<figure><img src="image_2.png" /><figcaption>**Fig. 1.** Wide angle views of the sky. **A** Photograph taken without a linear polarizing filter. **B,C** Photographs taken with a linear polarizing filter under a clear, cloudy sky. In both cases, the filter is oriented along the solar meridian indicated here by the red dotted line in B. Credits: Nigel Howe, CC-BY. From aibolita website, Polarized Light in Nature, https://aibolita.com/eye-diseases/38640-polarized-light-in-nature.html.</figcaption></figure>

we only perceive the color gradient due to the position of the sun, here close to the horizon. On the other hand, if we observe the sky through a linearly polarized filter also known as an analyzer, we notice the presence of a sharp contrast (vertical dark line) in the sky (Fig. 1B,C). In practice, the orientation of this darker bar depends on the orientation of the polarizing filter. If the polarizing filter and the axis of the solar meridian (i.e., the semicircle passing through the sun and the zenith) are parallel (aligned), then the dark line will be perpendicular to the meridian. On the other hand, if the filter is oriented perpendicular to the meridian, then the dark line will be parallel to the solar meridian. This is due to the fact that e-vectors are always perpendicular to the solar meridian. Figure 3 shows the effect of the orientation of the linear polarizing filter on the sky light.

Based on these observations, we can feel that there is a kind of straight line in the sky that could be used as a reference to orient oneself, like the Magnet North in a magnetic compass. If we place photosensors or photodiodes behind each polarizing filter, we can intuitively estimate the orientation of the solar meridian shown in Fig. 3 by measuring the distribution of light intensities, which can be modelled by the well-known Malus' law [11]. This is the physical law on which our optical compass works to find its heading.

## 2.2 Description of the device

The device consists of a graduated turntable on which are distributed 4 photosensors, a support allowing to place 30 cm above the 4 photosensors and a blue LED simulating the polarized light coming from the sky. For this purpose, a piece of polarizing filter is placed just in front of the emitting blue LED. All the plastic parts have been laser cut (10 mm thick acrylic) and the wooden sup-
<figure><img src="image_3.png" /><figcaption>**Fig. 2.** Illustration of the distribution of polarized light in concentric circles around the sun (dotted circle). The angles $\varphi_0$ (here 180°) and $\mu_0$ are the azimuth and the elevation of the sun, respectively. The angles $\varphi$ and $\mu$ are the azimuth and the elevation of a point of the sky, respectively. The vector $\chi$ is an e-vector (see 2.1). From [8].</figcaption></figure>

ports of the photosensors have been made of wood (Medium-Density Fibreboard - MDF).

We used an Arduino Leonardo board connected to a Light Sensor Grove board (shield board) for the acquisition of analog signals from each individual Light Sensor Grove. The advantage of this hardware is that it is very reliable, the software libraries are provided free of charge and the cost is very low (about € 100 in total for the components shown in Figs. 4 and 5).

In a mechanical CAD session, the students were asked after a training session with Fusion 360 software<fnref n="1" /> to make a 3D printout of a polarizing filter holder for each photosensor (Fig. 6) as well as a plate described in the next section. The main difference between a real sky and a blue source used for the educational model is its degree of polarization (a quantity used to describe the portion of an electromagnetic wave which is polarized) does not vary over time, nor the angle of polarization, which usually changes with the position of the sun in the sky.

<footnote n="1">¹ Autodesk, Fusion 360 free trial, https://www.autodesk.com/products/fusion-360/free-trial</footnote>
<figure><img src="image_4.png" /><figcaption>Fig. 3. Photograph showing the more or less significant absorption of light from the sky as it passes through a bunch of linear polarizing filters. The angle equal to 45° corresponds to the angle between two adjacent polarized filters. Depending on the orientation of the linear polarizing filter, the light is more or less transmitted: the maximum transmission is obtained according to the orientation of the yellow arrow; the minimum is reached when the orientation is perpendicular to the e-vector as described by the green arrow. Credits: Colorado State University, from YouTube, Show Me Some Science! Polarization of the Sky, https://www.youtube.com/watch?v=TP5JOfrPguQ.</figcaption></figure>

## 3 Heading estimation method

In the two methods described below, we neglect errors in the positioning of the polarizing filters and photosensors on the plate. However, this type of error can be taken into account in the processing as described in [7]. From the two publications presented in class [6,7], we asked students to choose between the following two methods:

- A distribution of two pairs (called 2-2 configuration) separated by an angle equal to 60° assumed known by construction (Fig. 7A).

- A circular distribution of the 4 photosensors with a known angle of 30° between two adjacent light sensors (Fig. 7B).

The students also had to design two different mechanical supports according to the chosen method. The design of each support is shown in Fig. 7. The formalism associated with each method is clearly explained in [6,7]. However, we can ask students to re-demonstrate it and provide the intermediate calculations.

In general, the model of the intensity delivered by a polarized photosensor is written as follows (Malus law):

$$S_i = K_i \cdot I \cdot (1 + d \cdot \cos(2\phi - 2\phi_i)) \quad (1)$$
<figure><img src="image_5.png" /><figcaption>**Fig. 4.** Experimental device for learning methods of heading estimation from polarised light coming from the blue upper LED. The stage is rotated manually. The angular orientation of the compass with respect to the polarised blue light can be read directly from the graduated turn table. The photosensors can be arranged in two possible configurations (see Fig. 7).</figcaption></figure>

<figure><img src="image_6.png" /><figcaption>**Fig. 5.** The different components used to build the celestial compass. They are for the most part commercially available on shelves. (a) Arduino Leonardo, USB HID microcontroller board (€20); (b) Grove Base Shield (€5); (c) Grove Light Sensor with a peak wavelength at 540 nm, corresponding to visible green (€3 per unit); (d) Connection Wires for Arduino (€1 per unit); (e) Linear polarising filter (cut from a single sheet, €0.05/cm²); (f) Wooden supports, designed in the laboratory and made by laser cutting; (g) Filter support, designed with a CAD software (Autodesk, Fusion 360 free trial) and 3D printed.</figcaption></figure>
<figure><img src="image_7.png" /><figcaption>**Fig. 6.** Individual photosensor composed of a Grove Light Sensor module (photoresistance on electronic card), two wooden supports, a white plastic support serving as optical insulator and support for the polarized filter placed above the photoresistance. Filters are cut precisely and glued. Only one filter is used at a time, placed according to two orthogonal directions.</figcaption></figure>

<figure><img src="image_8.png" /><figcaption>**Fig. 7.** Schematic representation of photosensors to illustrate the two configurations. Each light sensor is paired with a polarized filter, the orientation of which is represented by the corresponding gradient circle. (A) 2-2 orthogonal configuration ; (B) Circular pattern. $S_i$ is the intensity delivered by a polarized photosensor, $\phi_i$ is the orientation in space with respect to the body axis.</figcaption></figure>
with $i = 1$ as shown in Fig. 7A (with $\phi_0 = 0$) and $i = 1, ..., 4$ as shown in Fig. 7B (with $\phi_1 = 0$), $K_i$ a gain to be identified by calibration, the variable $I$ is the intensity of the source, the variable $d$ is the degree of polarization, and the variable $\alpha_i$ is the angle known by construction between each photosensor and $\phi$ the heading to be measured relative to the polarized light source. The first method (the orthogonal one 2-2, Fig. 7A) allows to discuss the usefulness of an adequate bio-inspired analog pre-processing (logarithmic division) based on the model proposed by Thomas Labhart [10]. The second method (the circular one, Fig. 7B) allows students to become familiar with non-linear calibration methods such as Least Mean Squares (LMS) method.

We only introduce the algorithm of the first method to estimate an optical heading (Fig. 7A, details in [6]). To test the method, an angle $\phi_1$ of 30° can be chosen. From the signal outputs of each photosensor, logarithmic voltage values are calculated for both pairs of orthogonal photosensors:

$$p_1(\phi) = \log_{10} \left( \frac{S_2}{S_1} \right) \qquad p_2(\phi) = \log_{10} \left( \frac{S_4}{S_3} \right) \qquad (2)$$

$p_1(\phi)$ and $p_2(\phi)$ are then linearized as follows:

$$\overline{p_{1,2}}(\phi) = \frac{1}{10^{p_{1,2}(\phi)} + 1} \qquad (3)$$

that gives:

$$\bar{p}_1(\phi) = \frac{1}{2}(1 - d \cos(2\phi)) \quad \text{and} \quad \bar{p}_2(\phi) = \frac{1}{2}(1 - d \cos(2\phi - 2\phi_1)) \qquad (4)$$

with $\phi_o$ the angle between the pairs $S_1, S_2$ and $S_3, S_4$ (see figure 7A).

Then we can obtain the two variables $y_1(\phi)$ and $y_2(\phi)$ defined as follows:

$$y_1 = 1 - 2\bar{p}_1(\phi) = d \cos(2\phi) \quad \text{and} \quad y_2 = 1 - 2\bar{p}_2(\phi) = d(\cos(2\phi) \cos(2\phi_1) + \sin(2\phi) \sin(2\phi_1)) \qquad (5)$$

Then we can consider the two following vectors U and Y:

$$Y = [y_1 \ y_2] \quad \text{and} \quad U = [U(1) \ U(2)] = [d \cos(2\phi) \ d \sin(2\phi)] \qquad (6)$$

Then we have:

$$Y = AU^T \quad \text{with} \quad A = \begin{bmatrix} 1 & 0 \\ \cos(2\phi_1) & \sin(2\phi_1) \end{bmatrix} \qquad (7)$$

$$\text{And thus, } U = A^{-1}Y^T \text{ with } A^{-1} = \begin{bmatrix} 1 & 0 \\ -\frac{\cos(2\phi_1)}{\sin(2\phi_1)} & \frac{1}{\sin(2\phi_1)} \end{bmatrix}$$

Then we can apply the following equations to obtain the optical heading $\phi$ and degree of polarisation $d$:
$$ \phi = \frac{1}{2} \arctan \left( \frac{U(2)}{U(1)} \right) = \frac{1}{2} \arctan \left( \frac{y_2 - y_1 \cos(2\phi_1)}{y_1 \sin(2\phi_1)} \right) \quad (8) $$

$$ = \frac{1}{2} \arctan \left( \frac{(1 - 2\bar{p}_2(\phi)) - (1 - 2\bar{p}_1(\phi)) \cos(2\phi_1)}{(1 - 2\bar{p}_1(\phi)) \sin(2\phi_1)} \right) \quad (9) $$

and $d = \sqrt{(U(1))^2 + (U(2))^2}$ with

$$ U(1) = y_1 \text{ and } U(2) = \frac{y_2 - y_1 \cos(2\phi_1)}{\sin(2\phi_1)} \quad (10) $$

Thus, both the degree of polarization $d$ and the optical heading $\phi$, with respect to the reference axis (body axis) of the compass, can be calculated:

$$ d = \sqrt{(1 - 2\bar{p}_1(\phi))^2 + \frac{(1 - 2\bar{p}_2(\phi) - (1 - 2\bar{p}_1(\phi)) \cos(2\phi_1))^2}{\sin^2(2\phi_1)}} \quad (11) $$

$$ \phi = \frac{1}{2} atan \left( \frac{(1 - 2\bar{p}_2(\phi)) - (1 - 2\bar{p}_1(\phi)) \cos(2\phi_1)}{(1 - 2\bar{p}_1(\phi)) \sin(2\phi_1)} \right) \quad (12) $$

However, given the nature of the expression of the equation (12) (1/2 factor and arctangent), the heading $\phi$ could only be determined between an interval [-45°; +45°]. We can see in Fig. 8 an example of calibration performed on raw data acquired by the 4 sensors (Fig. 8A) in order to estimate the gain $K_i$ of each sensor and the real angles of the linear polarizers that were installed by hand. A non-linear LMS method (Fig. 8B) was used to estimate parameters $K_i$ and $\phi_i$ on the basis of the Malus' law (see equation 1) for each photosensor. Results are summarized in Tab. 1. We can see in Fig. 9 an example of heading estimation programmed on board an Arduino Leonardo board, and an overview of the graphical user interface (GUI) developed by the students of the University of Toulon (Fig. 10) to better analyse their results in real time.

<table><caption>**Table 1.** Estimated gain and orientation angle of each photosensor with respect to the body axis of the device, and theoretical angles of each sensor axis.</caption><thead><tr><th>Parameter</th><th>Sensor 1</th><th>Sensor 2</th><th>Sensor 3</th><th>Sensor 4</th></tr></thead><tbody><tr><td>Gain K<sub>i</sub></td><td>K<sub>1</sub> = 210</td><td>K<sub>2</sub> = 157</td><td>K<sub>3</sub> = 209</td><td>K<sub>4</sub> = 218</td></tr><tr><td>Experimental φ<sub>i</sub></td><td>φ<sub>1</sub> = 0°</td><td>φ<sub>2</sub> = 90°</td><td>φ<sub>3</sub> = 35°</td><td>φ<sub>4</sub> = 117°</td></tr><tr><td>Theoretical φ<sub>i</sub></td><td>φ<sub>1</sub> = 0°</td><td>φ<sub>2</sub> = 90°</td><td>φ<sub>3</sub> = 30°</td><td>φ<sub>4</sub> = 120°</td></tr></tbody></table>
<figure><img src="image_9.png" /><figcaption>**Fig. 8.** Example of calibration of photosensors of the orthogonal method (see Fig. 7A). (A) Raw data. (B) Sensor values after curve fitting (LMS method); (C) Sensor values after gain normalization.</figcaption></figure>

# 4 Evaluation

The evaluation of the students was done in the form of a report as well as a 10-minute oral for the Aix-Marseille students, the final grade being in this case the average of the report and the oral.

# 5 Conclusion

We presented a new pedagogical device for implementing an optical compass based on the knowledge of the visual system of the desert ant *Cataglyphis* in order to train 2nd year students of master in robotics & IoTs. This experimental device allows to work on both theoretical concepts of physics and optics, but also highly highlighted points such as mechanical CAD and Arduino board programming to implement real time signal processing methods. All students were able to calibrate their own sensor and to program a method of heading estimation under the artificial light source mimicking the blue sky. Unfortunately, due to saturation of the photosensor (photoresistor) exposed to natural lighting condition, we were not able to test the principle outdoors in real conditions, so
<figure><img src="image_10.png" /><figcaption>**Fig. 9.** Results by applying Eq. 11 to calculate the degree of polarization *d* and Eq. 12 to calculate the angle of polarization *φ* in comparison with the actual orientation tunable by hand.</figcaption></figure>

they could see differences between controlled conditions indoors and real condi-
tions outdoors. A major improvement of the device would be to use photodiodes
coupled to logarithmic amplifiers instead of photoresistors. The signal process-
ing algorithms can be extended to the Kalman filter and the implementation
of advanced analog processing functions such as logarithmic amplification and
signal division. As any robotic application, it allows a teacher to choose different
focuses of studies for his/her students (3D-modelling, fabrication, programming
and math methods, physics of processes).

References

1. Dupeyroux, J., Viollet, S., Serres, J. R. Polarized skylight-based heading measure-
ments: a bio-inspired approach. Journal of the Royal Society Interface, **16**(150),
20180878 (2019)

2. Dupeyroux, J., Serres J. R., Viollet S.: AntBot: A six-legged walking robot able to home like desert ants in outdoor environments, Science Robotics, 4(27), eaau0307 (2019)

3. Dupeyroux, J., Viollet, S., Serres, J. R. An ant-inspired celestial compass applied to autonomous outdoor robot navigation. Robotics and Autonomous Systems, **117**, 40-56 (2019)

4. Dupeyroux, Julien, Stéphane Viollet, and Julien R. Serres. Bio-inspired celestial compass yields new opportunities for urban localization. 2020 28th Mediterranean Conference on Control and Automation (MED). IEEE, 2020, 881-886.

5. Wehner R.: Desert ant navigation: how miniature brains solve complex tasks. Journal of Comparative Physiology A, **189**(8):579-88 (2003)
<figure><img src="image_11.png" /><figcaption>**Fig. 10.** Overview of the graphical user interface (GUI) developed by the students of the University of Toulon in Python language and with the help of Tkinter, a graphical Python library. (A) The main window displays an animated compass indicating in real time both the heading and the angle of polarization (two rotations: the needle indicates the specific heading to follow, and the external crown that rotates accordingly to the angle of polarization, and allows to orientate and follow the specified heading by the needle. (B) The bottom center window is the monitor. It allows to see in real time the output responses of the 4 photosensors, as well as the current degree of polarization *d* and heading *φ*. (C) The settings window allows to configure the Arduino (Serial Port...), and set parameters for calibration (number of steps), monitor etc. (D) The right window allows for an easy and convenient semi-auto calibration. It goes further by computing the curve fitting and showing estimated gains *K*<sub>*i*</sub> and angles *φ*<sub>*i*</sub> (downloading dataset is also possible).</figcaption></figure>

6. Wang X., Gao J., Fan Z.: Empirical corroboration of an earlier theoretical resolution to the UV paradox of insect polarized skylight orientation. Naturwissenschaften, **101**, 95–103 (2014)

7. Du T., Li X., Wang Y., Yang J., Quan W.: Multiple disturbance analysis and calibration of an inspired polarization sensor. IEEE Access, **7**, 58507-58518 (2019)

8. Rossel S., Wehner R.: The bee's map of the e-vector pattern in the sky. Proceedings of the National Academy of Sciences, **79**(14), 4451-4455 (1982)

9. Reppert S.M., Zhu H., White R.H.: Polarized light helps monarch butterflies navigate. Current Biology,**14**(2), 155-158 (2004)

10. Labhart, T.: Polarization-opponent interneurons in the insect visual system. Nature, **331**(6155), 435-437 (1988)

11. Wikipedia contributors. Polarizer. Wikipedia, The Free Encyclopedia. November 10, 2021, 13:44 UTC. Available at: https://en.wikipedia.org/w/index.php?title=Polarizer&oldid=1054516039