Rover API Documentation
rover_hcsr04.hpp
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2017 FH Dortmund and others
3  * All rights reserved. This program and the accompanying materials
4  * are made available under the terms of the Eclipse Public License v1.0
5  * which accompanies this distribution, and is available at
6  * http://www.eclipse.org/legal/epl-v10.html
7  *
8  * Description:
9  * RoverHCSR04 API - Interfaces for Rover ultrasonic sensor application development
10  * Header file
11  *
12  * Contributors:
13  * M.Ozcelikors <mozcelikors@gmail.com>, created RoverHCSR04 class 04.12.2017
14  *
15  */
16 
17 #ifndef ROVERAPI_ROVER_HCSR04_HPP_
18 #define ROVERAPI_ROVER_HCSR04_HPP_
19 
21 
25 static const int TRIG0 = 7; //BCM-4 -> WiringPi 7
29 static const int ECHO0 = 0; //BCM-17 -> WiringPi 0
30 
34 static const int TRIG1 = 1; //BCM-18 -> WiringPi 1
38 static const int ECHO1 = 2; //BCM-27 -> WiringPi 2
39 
40 namespace rover
41 {
45  class RoverHCSR04 : public RoverSensor
46  {
47  private:
52 
56  int trigPin;
57 
61  int echoPin;
62 
67 
68  public:
73  explicit RoverHCSR04 (const RoverSensorID_t sensor_id);
74 
78  ~RoverHCSR04();
79 
84  void initialize (void);
85 
90  float read (void);
91 
97  void setTrigPin (const int trig_pin);
98 
103  int getTrigPin (void);
104 
110  void setEchoPin (const int echo_pin);
111 
116  int getEchoPin (void);
117 
118  };
119 }
120 
121 
122 
123 #endif /* ROVERAPI_ROVER_HCSR04_HPP_ */
int ROVERHCSR04_SETUP_
Flag to hold if RoverHCSR04 is set up.
Definition: rover_hcsr04.hpp:66
RoverSensor class is an abstract class to define interface between common sensors used in the rover...
Definition: rover_sensor.hpp:48
RoverSensorID_t sensorID
Sensor Identification.
Definition: rover_hcsr04.hpp:51
RoverSensorID_t
RoverSensorID_t defines the sensor location ID of the proximity sensors on the rover.
Definition: rover_sensor.hpp:38
int getTrigPin(void)
Returns the private attribute trigPin for HCSR04.
Definition: rover_hcsr04.cpp:117
static const int TRIG1
HC-SR04 Sensor Trigger Pin for Rear Sensor Socket (in wiringPi format)
Definition: rover_hcsr04.hpp:34
int trigPin
Trigger pin.
Definition: rover_hcsr04.hpp:56
void initialize(void)
Function to setup HCSR04 sensor.
Definition: rover_hcsr04.cpp:47
static const int ECHO1
HC-SR04 Sensor Echo Pin for Rear Sensor Socket (in wiringPi format)
Definition: rover_hcsr04.hpp:38
static const int TRIG0
HC-SR04 Sensor Trigger Pin for Front Sensor Socket (in wiringPi format)
Definition: rover_hcsr04.hpp:25
rover Namespace contains classes to manage Rover sensors, gpio, buzzer, buttons, driving, utilities, and cloud.
Definition: rover_api.hpp:293
int getEchoPin(void)
Returns the private attribute echoPin for HCSR04.
Definition: rover_hcsr04.cpp:127
void setEchoPin(const int echo_pin)
Sets the private attribute echoPin for HCSR04.
Definition: rover_hcsr04.cpp:122
RoverHCSR04 is a class that is inherited from RoverSensor abstract class. RoverHCSR04 class contains ...
Definition: rover_hcsr04.hpp:45
~RoverHCSR04()
Destructor for the RoverHCSR04 class.
Definition: rover_hcsr04.cpp:45
RoverHCSR04(const RoverSensorID_t sensor_id)
Constructor for the RoverHCSR04 class.
Definition: rover_hcsr04.cpp:22
float read(void)
Member function to read from HC-SR04 ultrasonic sensor given its sensor id.
Definition: rover_hcsr04.cpp:61
int echoPin
Echo pin.
Definition: rover_hcsr04.hpp:61
void setTrigPin(const int trig_pin)
Sets the private attribute trigPin for HCSR04.
Definition: rover_hcsr04.cpp:112
static const int ECHO0
HC-SR04 Sensor Echo Pin for Front Sensor Socket (in wiringPi format)
Definition: rover_hcsr04.hpp:29