SmartVehicle-Basis
SmartFactory
Sonar.h
Go to the documentation of this file.
1
// /**
2
// * @file Sonar.h
3
// * @brief TODO Library for mechatronic component sonar.
4
// *
5
// * The sonar module consists of a sonar sensor and a servo motor.
6
// * Based on the deviation of the sonar to the focus point an error is
7
// * given to the loop to turn the sonar to the right direction.
8
// *
9
// * The HC-SR04 has a range from 2cm to 3mm with a resolution form 2mm. Max freq. is 50Hz
10
// * Voltage 5V
11
// *
12
// * @author Glenn Huber (glenn.patrick.huber@hsr.ch)
13
// * @author Robert Paly (robert.paly@hsr.ch)
14
// * @author Felix Nyffenegger (felix.nyffenegger@hsr.ch)
15
// *
16
// * @version 1.1 - Added Doxygen-Documentation - Luca Mazzoleni (luca.mazzoleni@hsr.ch) - 2019-03-20
17
// * @version 1.0 - BA FTS FS 2018
18
// *
19
// * @date 2019-03-20
20
// * @copyright Copyright (c) 2019
21
// *
22
// */
23
24
// #ifndef sonar_h
25
// #define sonar_h
26
27
// #include "Arduino.h"
28
// #include "Configuration.h"
29
// #include "LogConfiguration.h"
30
// #include "Modular.h"
31
// #include "NewPing.h"
32
// #include "Servo.h"
33
34
// /**
35
// * @brief
36
// *
37
// */
38
// struct SonarState {
39
// int obstacleDistance = SONAR_MAX_DISTANCE; ///<
40
// float sonarFactor = 1; ///<
41
// bool detachServo = false; ///<
42
// bool isAttached = false; ///<
43
// };
44
45
// /**
46
// * @brief
47
// *
48
// */
49
// class Sonar : public Component {
50
// public:
51
// /**
52
// * @brief Construct a new Sonar object
53
// *
54
// * @param servoPin -
55
// * @param triggerPin -
56
// * @param echoPin -
57
// * @param maxDistance -
58
// * @param min_Error -
59
// * @param max_Error -
60
// * @param min_TurnAngle -
61
// * @param max_TurnAngle -
62
// */
63
// Sonar(int servoPin, int triggerPin, int echoPin, int maxDistance, int min_Error, int max_Error, int min_TurnAngle, int max_TurnAngle);
64
65
// /**
66
// * @brief
67
// *
68
// * @param state -
69
// * @param directionError -
70
// * @param servoActive -
71
// */
72
// void loop(SonarState *state, int directionError, bool servoActive);
73
74
// /**
75
// * @brief Gets distance to next obstacle in front of the vehicle
76
// *
77
// * @return int - return distance in cm
78
// */
79
// int getDistanceToObstacle();
80
81
// /**
82
// * @brief Correct the sonar-orientation and turn it into the drivingdirection
83
// *
84
// * Take the direction error and maps it into an turnangle (180 - 0 degree).
85
// * Afterwards realigne the sonar so it faces the path correctly
86
// *
87
// * @param directionError - deviation from the path -5(left) - +5(right)
88
// *
89
// * @todo smoother position change
90
// */
91
// void turnSonar(int directionError);
92
93
// /**
94
// * @brief
95
// *
96
// * @param state -
97
// * @todo for what?? ->motorControl
98
// */
99
// void calculateSonarFactor(SonarState *state);
100
101
// /**
102
// * @brief Testfunction for Sonar-Class
103
// *
104
// * 0 - run all tests \n
105
// * 1 - run test for servo right\n
106
// * 2 - run test for obstacle detection \n
107
// *
108
// * @param test - Choose which test to run
109
// */
110
// void Test(const int test);
111
112
// protected:
113
// NewPing *sonar; ///<
114
// Servo sonarServo; ///<
115
// int minError; ///<
116
// int maxError; ///<
117
// int minTurnAngle; ///<
118
// int maxTurnAngle; ///<
119
// int _servoPin; ///<
120
// };
121
122
// #endif
src
EnvironmentDetection
Sonar
Sonar.h
Generated by
1.8.15