-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSensorCog.cpp
More file actions
29 lines (22 loc) · 880 Bytes
/
Copy pathSensorCog.cpp
File metadata and controls
29 lines (22 loc) · 880 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#include "SensorCog.h"
void sensorCog(){
Sensor* sensorLeft = k9->sensorLeft;
Sensor* sensorRight = k9->sensorRight;
Sensor* sensorFront = k9->sensorFront;
while(!shutdown){
// Update sensors with new measurement, only if sensor is not locked
if(!sensorLeft->getThreadSafeLock())
sensorLeft->update(ping_cm(PIN_PING_SENSOR_LEFT));
if(!sensorRight->getThreadSafeLock())
sensorRight->update(ping_cm(PIN_PING_SENSOR_RIGHT));
if(!sensorFront->getThreadSafeLock())
sensorFront->update(ping_cm(PIN_PING_SENSOR_FRONT));
// Check if the last measurement of the left and right sensor is deviating
// If so, wait till the main core has taken care of it
if(sensorLeft->isLastMeasurementDeviating())
sensorLeft->setThreadSafeLock(true);
if(sensorRight->isLastMeasurementDeviating())
sensorRight->setThreadSafeLock(true);
// Sensor helper stuff
}
}