Skip to content

Commit 0f2b778

Browse files
committed
Add file header comments
1 parent a3d149d commit 0f2b778

File tree

11 files changed

+164
-11
lines changed

11 files changed

+164
-11
lines changed

examples/Example1_BasicReadings/Example1_BasicReadings.ino

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,18 @@
44
Copyright (c) 2024 SparkFun Electronics
55
*/
66

7+
/*******************************************************************************
8+
Example 1 - Basic Readings
9+
10+
This example demonstrates how to read the position and heading from the
11+
SparkFun Qwiic Optical Tracking Odometry Sensor (OTOS).
12+
13+
This example should be used to verify that the OTOS is connected and
14+
functioning correctly. It will just print the position and heading tracked
15+
by the OTOS to the serial monitor. It is recommended that you check out the
16+
other examples before using the OTOS in your own project.
17+
*******************************************************************************/
18+
719
#include "SparkFun_Qwiic_OTOS_Arduino_Library.h"
820
#include "Wire.h"
921

examples/Example2_SetUnits/Example2_SetUnits.ino

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,16 @@
44
Copyright (c) 2024 SparkFun Electronics
55
*/
66

7+
/*******************************************************************************
8+
Example 2 - Set Units
9+
10+
This example demonstrates how to change the units of the SparkFun Qwiic
11+
Optical Tracking Odometry Sensor (OTOS).
12+
13+
The OTOS library defaults to inches and degrees, but you can change the
14+
units to suit the needs of your project.
15+
*******************************************************************************/
16+
717
#include "SparkFun_Qwiic_OTOS_Arduino_Library.h"
818
#include "Wire.h"
919

examples/Example3_Calibration/Example3_Calibration.ino

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,21 @@
44
Copyright (c) 2024 SparkFun Electronics
55
*/
66

7+
/*******************************************************************************
8+
Example 3 - Calibration
9+
10+
This example demonstrates how to calibrate the SparkFun Qwiic Optical
11+
Tracking Odometry Sensor (OTOS).
12+
13+
This example should be used to calibrate the linear and angular scalars of
14+
the OTOS to get the most accurate tracking performance. The linear scalar
15+
can be used to compensate for scaling issues with the x and y measurements,
16+
while the angular scalar can be used to compensate for scaling issues with
17+
the heading measurement. Note that if the heading measurement is off, that
18+
can also cause the x and y measurements to be off, so it's recommended to
19+
calibrate the angular scalar first.
20+
*******************************************************************************/
21+
722
#include "SparkFun_Qwiic_OTOS_Arduino_Library.h"
823
#include "Wire.h"
924

examples/Example4_SetOffsetAndPosition/Example4_SetOffsetAndPosition.ino

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,20 @@
44
Copyright (c) 2024 SparkFun Electronics
55
*/
66

7+
/*******************************************************************************
8+
Example 4 - Set Offset and Position
9+
10+
This example demonstrates how to set the offset and position of the SparkFun
11+
Qwiic Optical Tracking Odometry Sensor (OTOS).
12+
13+
If your OTOS is mounted to a robot and is not centered, you can specify the
14+
offset for the sensor relative to the center of the robot; rather than
15+
returning the position of the sensor, the OTOS will calculate and return the
16+
position of the robot's center. If you know where your robot is located,
17+
such as the starting location or from another sensor, you can send that
18+
position to the OTOS and it will continue to track from there.
19+
*******************************************************************************/
20+
721
#include "SparkFun_Qwiic_OTOS_Arduino_Library.h"
822
#include "Wire.h"
923

examples/Example5_VelocityAndAcceleration/Example5_VelocityAndAcceleration.ino

Lines changed: 41 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,18 @@
44
Copyright (c) 2024 SparkFun Electronics
55
*/
66

7+
/*******************************************************************************
8+
Example 5 - Velocity and Acceleration
9+
10+
This example demonstrates how to read the velocity and acceleration from the
11+
SparkFun Qwiic Optical Tracking Odometry Sensor (OTOS).
12+
13+
The primary purpose of the OTOS is to track position, but it also provides
14+
velocity and acceleration measurements for more advanced applications. Note
15+
that these measurements can be noisy and inaccurate, especially if the
16+
sensor is not flat to the ground.
17+
*******************************************************************************/
18+
719
#include "SparkFun_Qwiic_OTOS_Arduino_Library.h"
820
#include "Wire.h"
921

@@ -60,14 +72,38 @@ void loop()
6072
myOtos.getVelocity(vel);
6173
myOtos.getAcceleration(acc);
6274

63-
// Or all at once with the following:
75+
// Or burst read them all at once with the following:
6476
// myOtos.getPosVelAcc(pos, vel, acc);
6577

66-
// Print measurements
67-
Serial.printf("Pos: X: %.3f\tY: %.3f\tH: %.3f\n", pos.x, pos.y, pos.h);
68-
Serial.printf("Vel: X: %.3f\tY: %.3f\tH: %.3f\n", vel.x, vel.y, vel.h);
69-
Serial.printf("Acc: X: %.3f\tY: %.3f\tH: %.3f\n", acc.x, acc.y, acc.h);
78+
// Print position
79+
Serial.println();
80+
Serial.println("Position:");
81+
Serial.print("X (Inches): ");
82+
Serial.println(pos.x);
83+
Serial.print("Y (Inches): ");
84+
Serial.println(pos.y);
85+
Serial.print("Heading (Degrees): ");
86+
Serial.println(pos.h);
87+
88+
// Print velocity
89+
Serial.println();
90+
Serial.println("Position:");
91+
Serial.print("X (Inches): ");
92+
Serial.println(vel.x);
93+
Serial.print("Y (Inches): ");
94+
Serial.println(vel.y);
95+
Serial.print("Heading (Degrees): ");
96+
Serial.println(vel.h);
97+
98+
// Print acceleration
7099
Serial.println();
100+
Serial.println("Position:");
101+
Serial.print("X (Inches): ");
102+
Serial.println(acc.x);
103+
Serial.print("Y (Inches): ");
104+
Serial.println(acc.y);
105+
Serial.print("Heading (Degrees): ");
106+
Serial.println(acc.h);
71107

72108
// Wait a bit so we don't spam the serial port
73109
delay(500);

examples/Example6_StandardDeviation/Example6_StandardDeviation.ino

Lines changed: 25 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,24 @@
44
Copyright (c) 2024 SparkFun Electronics
55
*/
66

7+
/*******************************************************************************
8+
Example 6 - Standard Deviation
9+
10+
This example demonstrates how to read the standard deviation of the
11+
measurements of the SparkFun Qwiic Optical Tracking Odometry Sensor (OTOS).
12+
13+
The OTOS uses Kalman filters to estimate the position, velocity, and
14+
acceleration of the x, y, and heading. The square root of the diagonal
15+
elements of the covariance matrices are provided for the standard deviation
16+
of each measurement. THEY DO NOT REPRESENT THE ACTUAL TRACKING ERROR! These
17+
are statistical quantities that assume a correct model of the system, but
18+
there could be unmodelled error sources that cause the physical error to
19+
become larger than these statistical error (eg. improper calibration, or
20+
tilting the OTOS to not be flat against the tracking surface). These are
21+
provided primarily for anyone wanting to perform sensor fusion with
22+
additional sensors.
23+
*******************************************************************************/
24+
725
#include "SparkFun_Qwiic_OTOS_Arduino_Library.h"
826
#include "Wire.h"
927

@@ -69,22 +87,21 @@ void loop()
6987
// REPRESENT THE ACTUAL TRACKING ERROR! These are statistical quantities
7088
// that assume a correct model of the system, but there could be unmodelled
7189
// error sources that cause the physical error to become larger than these
72-
// statistical error (eg. improper calibration, or rotating the OTOS to not
90+
// statistical error (eg. improper calibration, or tilting the OTOS to not
7391
// be flat against the tracking surface). These are provided primarily for
74-
// anyone wanting to perform sensor fusion with additional sensors, but they
75-
// can be used to at least "get an idea" of the quality of the accuracy.
92+
// anyone wanting to perform sensor fusion with additional sensors.
7693
myOtos.getPositionStdDev(posStdDev);
7794
// myOtos.getVelocityStdDev(velStdDev);
7895
// myOtos.getAccelerationStdDev(accStdDev);
7996

80-
// These values can instead be read out in chunks:
97+
// These values can instead be burst read out in chunks:
8198
// myOtos.getPosVelAcc(pos, vel, acc);
8299
// myOtos.getPosVelAccStdDev(posStdDev, velStdDev, accStdDev);
83100

84-
// Or all at once:
101+
// Or burst read them all at once:
85102
// myOtos.getPosVelAccAndStdDev(pos, vel, acc, posStdDev, velStdDev, accStdDev);
86103

87-
// Print measurements
104+
// Print position and standard deviation
88105
Serial.println();
89106
Serial.println("Sensor pose:");
90107
Serial.print("X (Inches): ");
@@ -100,6 +117,7 @@ void loop()
100117
Serial.print(" +/- ");
101118
Serial.println(posStdDev.h);
102119

120+
// Print velocity and standard deviation
103121
// Serial.println();
104122
// Serial.println("Sensor velocity:");
105123
// Serial.print("X (Inches/sec): ");
@@ -115,6 +133,7 @@ void loop()
115133
// Serial.print(" +/- ");
116134
// Serial.println(velStdDev.h);
117135

136+
// Print acceleration and standard deviation
118137
// Serial.println();
119138
// Serial.println("Sensor acceleration:");
120139
// Serial.print("X (Inches/sec^2): ");

examples/Example7_GetVersion/Example7_GetVersion.ino

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,19 @@
44
Copyright (c) 2024 SparkFun Electronics
55
*/
66

7+
/*******************************************************************************
8+
Example 7 - Get Version
9+
10+
This example demonstrates how to get the hardware and firmware version
11+
numbers from the SparkFun Qwiic Optical Tracking Odometry Sensor (OTOS).
12+
13+
There may be future hardware and/or firmware changes of the OTOS, so you can
14+
use this example to check which version you have. See the product page or
15+
hardware repository to see what the latest version is:
16+
https://www.sparkfun.com/products/24904
17+
https://github.com/sparkfun/SparkFun_Optical_Tracking_Odometry_Sensor
18+
*******************************************************************************/
19+
720
#include "SparkFun_Qwiic_OTOS_Arduino_Library.h"
821
#include "Wire.h"
922

examples/Example8_SelfTest/Example8_SelfTest.ino

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,17 @@
44
Copyright (c) 2024 SparkFun Electronics
55
*/
66

7+
/*******************************************************************************
8+
Example 8 - Self Test
9+
10+
This example demonstrates how to perform a self test of the SparkFun Qwiic
11+
Optical Tracking Odometry Sensor (OTOS).
12+
13+
The self test triggers the OTOS to perform a series of tests to ensure the
14+
sensor is functioning correctly. This is performed during QC testing, but
15+
you can also perform this test yourself.
16+
*******************************************************************************/
17+
718
#include "SparkFun_Qwiic_OTOS_Arduino_Library.h"
819
#include "Wire.h"
920

src/SparkFun_Qwiic_OTOS_Arduino_Library.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,14 @@
44
Copyright (c) 2024 SparkFun Electronics
55
*/
66

7+
/*******************************************************************************
8+
SparkFun_Qwiic_OTOS_Arduino_Library.h - Arduino wrapper of the C++ driver
9+
for the SparkFun Qwiic Optical Tracking Odometry Sensor (OTOS).
10+
11+
This is a simple wrapper around the C++ driver to make it easier to use with
12+
Arduino.
13+
*******************************************************************************/
14+
715
#pragma once
816

917
#include "Arduino.h"

src/sfeQwiicOtos.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,11 @@
44
Copyright (c) 2024 SparkFun Electronics
55
*/
66

7+
/*******************************************************************************
8+
sfeQwiicOtos.h - C++ driver implementation for the SparkFun Qwiic Optical
9+
Tracking Odometry Sensor (OTOS).
10+
*******************************************************************************/
11+
712
#include "sfeQwiicOtos.h"
813

914
sfeQwiicOtos::sfeQwiicOtos()

0 commit comments

Comments
 (0)