Skip to content

Commit 44f42ab

Browse files
committed
fix no wifi build
1 parent 68f7d5b commit 44f42ab

File tree

3 files changed

+47
-47
lines changed

3 files changed

+47
-47
lines changed

.vscode/settings.json

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
{
2+
"editor.formatOnSave": true,
23
"cSpell.words": [
34
"arduino",
45
"devkit",

include/OTOS.h

+5-7
Original file line numberDiff line numberDiff line change
@@ -2,22 +2,20 @@
22
#define OTOS_H
33

44
#include <Arduino.h>
5-
#include "pins.h"
6-
#include "ESP32_Helper.h"
7-
using namespace Printer;
8-
9-
#include <SparkFun_Qwiic_OTOS_Arduino_Library.h>
105
#include <Wire.h>
6+
#include <SparkFun_Qwiic_OTOS_Arduino_Library.h>
117

8+
#include "pins.h"
9+
#include "ESP32_Helper.h"
1210

1311
class OpticalTrackingOdometrySensor
1412
{
1513
public:
1614
void Initialisation();
1715
void Update();
1816
void HandleCommand(Command cmd);
19-
void PrintCommandHelp();
20-
17+
const void PrintCommandHelp();
18+
2119
void SetPose(float x, float y, float h);
2220
void Teleplot();
2321

src/OTOS.cpp

+41-40
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,30 @@
11
#include "OTOS.h"
22

3+
using namespace Printer;
4+
35
void OpticalTrackingOdometrySensor::Initialisation()
46
{
57
println("Init QwiicOTOS");
68

79
Wire.setPins(SDA, SCL);
8-
//Wire.begin();
910
Wire.begin(SDA, SCL, 400000UL);
1011

1112
// Normal speed is 100 000
1213
// With higher speed, instructions on I2C take less time
13-
//Wire.setClock(400000UL);
14+
// Wire.setClock(400000UL);
1415

1516
int retryConnect = 0;
1617
// Attempt to begin the sensor
1718
isConnected = myOtos.begin();
18-
while(!isConnected && retryConnect < 3)
19+
while (!isConnected && retryConnect < 3)
1920
{
2021
println("OTOS not connected, check your wiring and I2C address!");
2122
delay(1000);
2223
isConnected = myOtos.begin();
2324
retryConnect++;
2425
}
2526

26-
if(isConnected)
27+
if (isConnected)
2728
{
2829
println("OTOS connected!");
2930

@@ -57,8 +58,8 @@ void OpticalTrackingOdometrySensor::Initialisation()
5758
// multiple speeds to get an average, then set the linear scalar to the
5859
// inverse of the error. For example, if you move the robot 100 inches and
5960
// the sensor reports 103 inches, set the linear scalar to 100/103 = 0.971
60-
myOtos.setAngularScalar(0.992);//0.992
61-
myOtos.setLinearScalar(1.00);//1.035
61+
myOtos.setAngularScalar(0.992); // 0.992
62+
myOtos.setLinearScalar(1.00); // 1.035
6263

6364
// Set the desired units for linear and angular measurements. Can be either
6465
// meters or inches for linear, and radians or degrees for angular. If not
@@ -68,7 +69,7 @@ void OpticalTrackingOdometrySensor::Initialisation()
6869
myOtos.setLinearUnit(kSfeOtosLinearUnitMeters);
6970
// myOtos.setLinearUnit(kSfeOtosLinearUnitInches);
7071
myOtos.setAngularUnit(kSfeOtosAngularUnitRadians); // /!\ OTOS in radians !
71-
//myOtos.setAngularUnit(kSfeOtosAngularUnitDegrees);
72+
// myOtos.setAngularUnit(kSfeOtosAngularUnitDegrees);
7273

7374
// Assuming you've mounted your sensor to a robot and it's not centered,
7475
// you can specify the offset for the sensor relative to the center of the
@@ -87,26 +88,26 @@ void OpticalTrackingOdometrySensor::Initialisation()
8788
// Reset the tracking algorithm - this resets the position to the origin,
8889
// but can also be used to recover from some rare tracking errors
8990
myOtos.resetTracking();
90-
91+
9192
// After resetting the tracking, the OTOS will report that the robot is at
9293
// the origin. If your robot does not start at the origin, or you have
9394
// another source of location information (eg. vision odometry), you can set
9495
// the OTOS location to match and it will continue to track from there.
9596
sfe_otos_pose2d_t currentPose = {0, 0, 0};
9697
myOtos.setPosition(currentPose);
9798

98-
sfeTkError_t error;
99+
sfTkError_t error;
99100
sfe_otos_signal_process_config_t config;
100101
error = myOtos.getSignalProcessConfig(config);
101102
if (error != 0)
102-
print("Error get Signal Process Config : ", ((int)(error)));
103+
print("Error get Signal Process Config : ", error);
103104
else
104105
{
105-
//println("Signal Process Config :");
106-
//println("enVar : ", config.enVar);
107-
//println("enRot : ", config.enRot);
108-
//println("enAcc : ", config.enAcc);
109-
//println("enLut : ", config.enLut);
106+
// println("Signal Process Config :");
107+
// println("enVar : ", config.enVar);
108+
// println("enRot : ", config.enRot);
109+
// println("enAcc : ", config.enAcc);
110+
// println("enLut : ", config.enLut);
110111
}
111112
}
112113
}
@@ -115,7 +116,7 @@ void OpticalTrackingOdometrySensor::Update()
115116
{
116117
if (isConnected)
117118
{
118-
sfeTkError_t error;
119+
sfTkError_t error;
119120
// Get the latest position, which includes the x and y coordinates, plus the
120121
// heading angle
121122
// sfe_otos_pose2d_t myPosition;
@@ -137,14 +138,14 @@ void OpticalTrackingOdometrySensor::Update()
137138
// If Velocity and Acceleration are not needed, use getPosition to decrease blocking time
138139
// currently blocking time of getPosVelAcc with 400 000 speed : 600µS
139140
error = myOtos.getPosVelAcc(myPosition, myVelocity, myAcceleration);
140-
position.x = myPosition.x*1000;
141-
position.y = myPosition.y*1000;
141+
position.x = myPosition.x * 1000;
142+
position.y = myPosition.y * 1000;
142143
position.h = myPosition.h;
143-
velocity.x = myVelocity.x*1000;
144-
velocity.y = myVelocity.y*1000;
144+
velocity.x = myVelocity.x * 1000;
145+
velocity.y = myVelocity.y * 1000;
145146
velocity.h = myVelocity.h;
146-
acceleration.x = myAcceleration.x*1000;
147-
acceleration.y = myAcceleration.y*1000;
147+
acceleration.x = myAcceleration.x * 1000;
148+
acceleration.y = myAcceleration.y * 1000;
148149
acceleration.h = myAcceleration.h;
149150
if (error != 0)
150151
print("Error getPosVelAcc : ", error);
@@ -153,25 +154,25 @@ void OpticalTrackingOdometrySensor::Update()
153154

154155
void OpticalTrackingOdometrySensor::HandleCommand(Command cmd)
155156
{
156-
//if (cmd.cmd == "Otos")
157+
// if (cmd.cmd == "Otos")
157158
//{
158-
// Otos:0;0
159+
// Otos:0;0
159160
// print("Otos : ", cmd.data[0]);
160161
//}
161162
}
162163

163-
void OpticalTrackingOdometrySensor::PrintCommandHelp()
164+
const void OpticalTrackingOdometrySensor::PrintCommandHelp()
164165
{
165166
Printer::println("OTOS Command Help :");
166167
Printer::println("! No Command yet !");
167-
//Printer::println(" > Otos:[int]");
168-
//Printer::println(" [int] ");
169-
//Printer::println();
168+
// Printer::println(" > Otos:[int]");
169+
// Printer::println(" [int] ");
170+
// Printer::println();
170171
}
171172

172173
void OpticalTrackingOdometrySensor::SetPose(float x, float y, float h)
173174
{
174-
sfeTkError_t error;
175+
sfTkError_t error;
175176
// Reset the tracking algorithm - this resets the position to the origin,
176177
// but can also be used to recover from some rare tracking errors
177178
myOtos.resetTracking();
@@ -180,18 +181,18 @@ void OpticalTrackingOdometrySensor::SetPose(float x, float y, float h)
180181
// the origin. If your robot does not start at the origin, or you have
181182
// another source of location information (eg. vision odometry), you can set
182183
// the OTOS location to match and it will continue to track from there.
183-
sfe_otos_pose2d_t currentPose = {x/1000, y/1000, h};
184-
184+
sfe_otos_pose2d_t currentPose = {x / 1000, y / 1000, h};
185+
185186
int retrySetPose = 0;
186187
error = myOtos.setPosition(currentPose);
187-
while(error !=0 && retrySetPose < 3)
188+
while (error != 0 && retrySetPose < 3)
188189
{
189190
println("OTOS Error SetPose : ", error);
190191
delay(100);
191192
error = myOtos.setPosition(currentPose);
192193
retrySetPose++;
193194
}
194-
if(error != 0 || retrySetPose >= 3)
195+
if (error != 0 || retrySetPose >= 3)
195196
{
196197
// Force position, but will be override when update occurs
197198
myPosition.x = x;
@@ -203,16 +204,16 @@ void OpticalTrackingOdometrySensor::SetPose(float x, float y, float h)
203204

204205
void OpticalTrackingOdometrySensor::Teleplot()
205206
{
206-
//teleplot("X", myPosition.x*1000);
207-
//teleplot("Y", myPosition.y*1000);
208-
//teleplot("H", myPosition.h);
207+
// teleplot("X", myPosition.x*1000);
208+
// teleplot("Y", myPosition.y*1000);
209+
// teleplot("H", myPosition.h);
209210

210-
teleplot("VX", myVelocity.x*1000);
211-
teleplot("VY", myVelocity.y*1000);
211+
teleplot("VX", myVelocity.x * 1000);
212+
teleplot("VY", myVelocity.y * 1000);
212213
teleplot("VH", myVelocity.h);
213214

214-
teleplot("AX", myAcceleration.x*1000);
215-
teleplot("AY", myAcceleration.y*1000);
215+
teleplot("AX", myAcceleration.x * 1000);
216+
teleplot("AY", myAcceleration.y * 1000);
216217
teleplot("AH", myAcceleration.h);
217218

218219
/*

0 commit comments

Comments
 (0)