![](/media/cache/group/default_image.jpg.50x50_q85.jpg)
code for the speed robot
Dependencies: MPU6050-DMP mbed PololuQTRSensors vl53l0x
tof.h
- Committer:
- deepanaishtaweera174
- Date:
- 2019-09-30
- Revision:
- 5:bb0763ae79ff
- Parent:
- 4:538efc40388e
- Child:
- 6:a635edf31d8b
File content as of revision 5:bb0763ae79ff:
void InitTOFSensors() { DigitalOut xshut1(XSHUT_pin1); DigitalOut xshut2(XSHUT_pin2); DigitalOut xshut3(XSHUT_pin3); DigitalIn xshut3_(XSHUT_pin3); wait(0.01); Sensor3.setAddress(Sensor3_newAddress); DigitalIn xshut2_(XSHUT_pin2); wait(0.01); Sensor2.setAddress(Sensor2_newAddress); DigitalIn xshut1_(XSHUT_pin1); wait(0.01); Sensor1.setAddress(Sensor1_newAddress); if (Sensor1.init()) { PrintSerial("Sensor 1 : Configured"); } else { PrintSerial("Sensor 1 : Configuration Failed"); } if (Sensor2.init()) { PrintSerial("Sensor 2 : Configured"); } else { PrintSerial("Sensor 2 : Configuration Failed"); } if (Sensor3.init()) { PrintSerial("Sensor 3 : Configured"); } else { PrintSerial("Sensor 3 : Configuration Failed"); } Sensor1.setSignalRateLimit(SignalRateLimit); Sensor2.setSignalRateLimit(SignalRateLimit); Sensor3.setSignalRateLimit(SignalRateLimit); Sensor1.setMeasurementTimingBudget(MeasurementBudget); Sensor2.setMeasurementTimingBudget(MeasurementBudget); Sensor3.setMeasurementTimingBudget(MeasurementBudget); Sensor1.setTimeout(Timeout); Sensor2.setTimeout(Timeout); Sensor3.setTimeout(Timeout); Sensor1.startContinuous(); Sensor2.startContinuous(); Sensor3.startContinuous(); } void PrintTOFDistances() { front_Distance = Sensor1.readRangeContinuousMillimeters(); float front_DistanceCM = (float)( front_Distance / 10.0); left_Distance = Sensor2.readRangeContinuousMillimeters() ; float left_DistanceCM = (float)(left_Distance / 10.0); right_Distance = Sensor3.readRangeContinuousMillimeters(); float right_DistanceCM = (float)(right_Distance / 10.0); printf("F: %.2f L: %.2f R: %.2f",front_DistanceCM,left_DistanceCM,right_DistanceCM); }