Robot Sensors
Propeller Robot Sensor Objects
 All Classes Functions
sonarsensor.h
1 #ifndef SONARSENSOR_H
2 #define SONARSENSOR_H
3 
4 #include "isonarsensor.h"
5 
16 class SonarSensor : public ISonarSensor
17 {
18 public:
19  SonarSensor();
20  SonarSensor(int t_pin, int e_pin, int t_len, int t_out);
21  void init(int t_pin, int e_pin, int t_len, int t_out);
22 
23  // Interface overrides: See interface defintions for documentation
24  long trigger();
25  long getRange_in();
26  long getRange_cm();
27 
28 private:
29  SonarSensor(const SonarSensor& s);
30 
31 protected:
32  int actPin; // Activity pin
33  int trigPin; // Trigger pin to start ranging cycle
34  int echoPin; // Echo pin to capture time-of-flight
35  int trigLen; // Length in usecs for the trigger pulse duration
36  int usTimeout; // Maximum expected echo length in microseconds
37  int echoTimeout; // Maximum expected echo length in clock pulses
38  long tof; // Last time of flight in usecs
39 };
40 
41 #endif // SONARSENSOR_H
long getRange_in()
Get the range in inches for the previous ranging cycle.
Definition: sonarsensor.cpp:103
void init(int t_pin, int e_pin, int t_len, int t_out)
Initializer function, used to initialize default constructed objects.
Definition: sonarsensor.cpp:46
long getRange_cm()
Get the range in centimeters for the previous ranging cycle.
Definition: sonarsensor.cpp:117
long trigger()
Trigger a sonar ranging cycle.
Definition: sonarsensor.cpp:78
Class to represent standard one or two pin echo timing sonar sensors.
Definition: sonarsensor.h:16
SonarSensor()
Default constructor for sonar sensor.
Definition: sonarsensor.cpp:7
Virtual interface class for any type of sonar sensor.
Definition: isonarsensor.h:12