Skip to content

Commit eef8b46

Browse files
committed
starting tof, wip, not working yet
1 parent 2905aba commit eef8b46

File tree

6 files changed

+79
-7
lines changed

6 files changed

+79
-7
lines changed

.DS_Store

6 KB
Binary file not shown.

src/Arduino_Robot_Firmware.cpp

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -67,15 +67,12 @@ int Arduino_Robot_Firmware::begin(){
6767
connectExternalI2C();
6868
ext_wire->begin(ARDUINO_ROBOT_ADDRESS);
6969

70-
7170

7271
if (beginAPDS()!=0){
7372
errorLed(ERROR_APDS);
7473
}
7574

7675
beginServo();
77-
//beginI2Cselect();
78-
//connectExternalI2C();
7976

8077
if (beginBMS()!=0){
8178
errorLed(ERROR_BMS);
@@ -85,7 +82,7 @@ int Arduino_Robot_Firmware::begin(){
8582
//errorLed(ERROR_TOUCH);
8683
}
8784

88-
if (beginImu()!=){
85+
if (beginImu()!=0){
8986
errorLed(ERROR_IMU);
9087
}
9188

@@ -268,7 +265,7 @@ void Arduino_Robot_Firmware::updateTouch(){
268265
touch_status = touch_sensor->getStatus();
269266
}
270267

271-
bool Arduino_Robot_Firmware::getTouchPressed(){
268+
bool Arduino_Robot_Firmware::getAnyTouchPressed(){
272269
if (touch_sensor->touched(touch_status,TOUCH_PAD_GUARD)){
273270
return true;
274271
}
@@ -395,6 +392,7 @@ int Arduino_Robot_Firmware::beginImu(){
395392
void Arduino_Robot_Firmware::updateImu(){
396393
imu->Get_X_Axes(accelerometer);
397394
imu->Get_G_Axes(gyroscope);
395+
398396
}
399397

400398

src/Arduino_Robot_Firmware.h

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212
#include "Arduino_MAX17332.h"
1313
#include "AT42QT2120.h"
1414
#include "LSM6DSOSensor.h"
15+
#include "motion_fx.h"
16+
1517

1618
class Arduino_Robot_Firmware{
1719
private:
@@ -38,6 +40,10 @@ class Arduino_Robot_Firmware{
3840
int32_t gyroscope[3];
3941

4042

43+
MFX_input_t data_in;
44+
MFX_output_t data_out;
45+
46+
4147
public:
4248

4349
DCmotor * motor_left;
@@ -102,7 +108,7 @@ class Arduino_Robot_Firmware{
102108
// Touch
103109
int beginTouch();
104110
void updateTouch();
105-
bool getTouchPressed();
111+
bool getAnyTouchPressed();
106112
bool getTouchKey(const uint8_t key);
107113
bool getTouchUp();
108114
bool getTouchRight();

src/pinout_definitions.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,11 @@
6969
#define EXT_A1 PA6 //MISO
7070
#define EXT_A2 PA5 //SCK
7171
#define EXT_A3 PA4 //CS
72+
#define EXT_GPIO0 PC3
73+
#define EXT_GPIO1 PC4
74+
#define EXT_GPIO2 PB0
75+
#define EXT_GPIO3 PB1
76+
7277

7378

7479
// Uart

src/robot_definitions.h

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#ifndef __ROBOT_DEFINITIONS_H__
22
#define __ROBOT_DEFINITIONS_H__
33

4+
// Motor Control and mechanical parameters
45
#define CONTROL_LIMIT 4096 // PWM resolution
56

67
#define MOTOR_LIMIT 100.0 // Mechanical RPM limit speed of used motors
@@ -15,10 +16,18 @@ const float MOTOR_RATIO = MOTOR_CPR*MOTOR_GEAR_RATIO;
1516
#define MOTOR_CONTROL_PERIOD 0.01
1617

1718

18-
19+
// Sensor fusioning parameters
1920
#define FROM_MG_TO_G 0.001f
2021
#define FROM_G_TO_MG 1000.0f
2122
#define FROM_MDPS_TO_DPS 0.001f
2223
#define FROM_DPS_TO_MDPS 1000.0f
24+
#define MOTION_FX_FREQ 100U
25+
const float MOTION_FX_PERIOD = (1000U / MOTION_FX_FREQ);
26+
#define MOTION_FX_ENGINE_DELTATIME 0.01f
27+
#define STATE_SIZE (size_t)(2432)
28+
#define SAMPLETODISCARD 15
29+
#define GBIAS_ACC_TH_SC (2.0f*0.000765f)
30+
#define GBIAS_GYRO_TH_SC (2.0f*0.002f)
31+
#define DECIMATION 1U
2332

2433
#endif

src/sensor_tof_matrix.h

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
#ifndef __SENSOR_TOF_MATRIX_H__
2+
#define __SENSOR_TOF_MATRIX_H__
3+
4+
#include "Arduino.h"
5+
#include "Wire.h"
6+
#include "vl53l7cx_class.h"
7+
8+
9+
class SensorTofMatrix{
10+
private:
11+
VL53L7CX * sensor;
12+
TwoWire * wire;
13+
public:
14+
SensorTofMatrix(TwoWire * _wire, const uint8_t lpn_pin, const uint8_t i2c_rst_pin){
15+
wire=_wire;
16+
sensor = new VL53L7CX(wire,lpn_pin,i2c_rst_pin);
17+
}
18+
19+
int begin(){
20+
wire->begin();
21+
sensor->begin();
22+
sensor->init_sensor();
23+
sensor->vl53l7cx_set_resolution(VL53L7CX_RESOLUTION_4X4);
24+
sensor->vl53l7cx_start_ranging();
25+
}
26+
27+
void print(){
28+
int size=4;
29+
VL53L7CX_ResultsData Results;
30+
uint8_t NewDataReady = 0;
31+
uint8_t status;
32+
do {
33+
status = sensor->vl53l7cx_check_data_ready(&NewDataReady);
34+
} while (!NewDataReady);
35+
36+
if ((!status) && (NewDataReady != 0)) {
37+
status = sensor->vl53l7cx_get_ranging_data(&Results);
38+
for (int y=0; y<size; y++){
39+
for (int x=0; x<size; x++){
40+
Serial.print((int)Results.distance_mm[x+y*size]);
41+
Serial.print(" ");
42+
}
43+
Serial.println();
44+
}
45+
Serial.println();
46+
}
47+
}
48+
49+
/*void setResolution(){
50+
sensor->setRes
51+
}*/
52+
};
53+
54+
#endif

0 commit comments

Comments
 (0)