The purpose of this lab was to get acquainted with the TOF sensors
From the TOF datasheet, the i2c address was 0x52. I plan to use both TOF sensors simultaneously, so I will need to change the i2c address of one of them. I wired the XSHUT pin to A3 for one of the TOF sensors. Upon startup, I will temporarily disable this TOF sensor, assign a new i2c address, and enable it. Using both sensors simultaneously is ideal because it lets you capture data from different directions without turning, enabling better obstacle avoidance and path planning.
Currently, I plan to place one i2c sensor on the front and one i2c sensor on the right side of the robot. With sensors on the front and side, the robot will detect obstacles in front and on the side. This could avoid colliding with walls when making turns. This sensor configuration will miss obstacles behind the robot, so I will be careful when backing up. Overall, I think having sensors facing two different directions will give the most information to the robot.
Here is a sketch of my wiring diagram. I used the two long connectors to the TOF sensors, ensuring I could place them anywhere on the robot. I used the short connector to connect the sensors to the Artemis.
This shows the hardware connections for the TOF sensors to the QWIIC breakout board. It also shows the battery connected to the Artemis.
The TOF sensor was listed as 0x29 when I expected it to be 0x52. Upon further inspection, I realized that the i2c protocol uses the last digit (LSB) as the read/write bit. As a result, the original address (0x52) is bit shifted to the right, yielding 0x29.
I initially read through the dataset to investigate the three different sensor modes. However, the Arduino library only supports two sensor modes (short, and long), so I focused on those. The long mode is good up to 4 meters but is sensitive to lighting conditions. The short mode is only good up to 1.3 meters, but is robust to noise. Since 1.3 meters is about 4 feet, this mode will give enough distances for the vast majority of tasks I have to complete, so I chose to set both sensors on short mode to make them robust to noisy conditions. I tested the sensor’s range, accuracy, and reliability at various distances. I recorded 40 sensor measurements at each distance and sent them to the computer via Python. The following graphs show my analysis:
These graphs demonstrate that the sensor is accurate from 25mm to 1000mm, slightly shorter than the datasheet’s range of 1.3m. It had an accuracy between 10 - 20mm, which is higher than what the datasheet claims, but is probably affected by the errors in the testing setup as well. Overall, an accuracy of about 2cm is probably good for most of the required tasks. The sensors are very reliable, with a standard deviation of about 2mm. Near the end of the range, the accuracy decreases from about 15mm to 50mm. The reliability also decreases after about 1000mm, indicating that this sensor practically cannot be used for distances larger than a meter away, which is plenty of range for my tasks.
To test the ranging time, I recorded the ranging times for 10 measurements and averaged them together. This gave an average ranging time of 52.5ms for my sensor. There will be some variation based on distance, but the distance is insignificant compared to the speed of light, so this is a good estimate of the ranging time.
I modified the code so I could use two TOF sensors simultaneously. I used the following routine to configure separate i2c addresses for each sensor.
Using this, I successfully ran both sensors and printed their output to the screen, as shown in the following video.
After testing out both sensors, I modified the Arduino code so the sensors could run as fast as possible. I printed the clock to Serial to analyze the Artemis loop speed compared to the TOF speed. I used this code:
This image shows the Serial monitor while running this code.
From the screenshot, we can see that the Artemis loop runs every 13ms which is a frequency of about 76 Hz. The sensors run about every 98ms which is a frequency of 10.2 Hz. The sensors run slower than the loop, so they are the limiting factor when running this code.
I modified the lab 2 code to incorporate the TOF sensors and the IMU together. I wrote a new case statement that collects TOF and IMU data for a set period, and sends this data to the computer. This is the code I used. It is the same IMU code used in the lab, modified to use the TOF sensors.
This shows the callback function on the Python side.
This graph shows the two TOF sensors’ output over time.
This graph shows the IMU data over time. It was collected from the code described in the previous section.
There are several different types of IR distance sensors. There are amplitude-based IR sensors, triangulation IR sensors, and IR TOF sensors. Amplitude-based IR sensors work by sending out IR pulses and comparing the amplitude of the sent signal to the received signal. From the ratio, the sensor can determine the distance of objects. They are very cheap and have a sampling rate, but they only work over short distances. Additionally, they are sensitive to ambient light, texture, and object color. Triangulation IR sensors work by sending out an IR pulse at a specific angle and measuring the angle of the received pulse. Based on this angle, the sensor computes the distance. These sensors are good up to 1m and are insensitive to surface texture or color, but they are bulky, expensive, and slow. IR TOF sensors send out a pulse and measure the return time. The distance is computed based on the return time since the speed of light is known. These sensors are not sensitive to ambient light, surface texture, or color, but have a slow operating speed.
I evaluated my sensor against different colors to check for consistency.
From the plot, we can see that the TOF sensor is consistent and accurate across different colors.