-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathuser-guide_ultrasonic.html
More file actions
136 lines (117 loc) · 7.2 KB
/
user-guide_ultrasonic.html
File metadata and controls
136 lines (117 loc) · 7.2 KB
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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
<!DOCTYPE html>
<html lang="en">
<head>
<!-- Required meta tags -->
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<!-- Page title -->
<title>User Guide: Ultrasonic Proximity Sensor</title>
<!-- Bootstrap core CSS: Material design -->
<link rel="stylesheet" href="vendor/material/css/material-icons.css">
<link rel="stylesheet" href="vendor/material/css/bootstrap-material-design.min.css">
<!-- highlight.js -->
<link rel="stylesheet" href="vendor/highlight/default.min.css">
<script src="vendor/highlight/highlight.min.js"></script>
<script>hljs.initHighlightingOnLoad();</script>
<!-- Custom styles -->
<link rel="stylesheet" href="css/custom.css">
<!-- Custom JS scripts -->
<script type="text/javascript" src="js/custom.js"></script>
</head>
<body>
<!-- Content wrapper -->
<div id="wrapper" class="row">
<!-- Sidebar -->
<div id="sidebar-wrapper" class="bg-dark" w3-include-html="toc.html"></div>
<!-- Page Content -->
<div id="page-content-wrapper">
<div class="container-fluid">
<h1>User Guide: Ultrasonic Proximity Sensors</h1><hr />
<div>
<h2>Setup</h2>
<p>The Ultrasonic sensor used: <a href="https://www.sparkfun.com/products/13959">HC-SR04</a></p>
<p>The line colours corresponding to the pins are as follows:</p>
<table class="table table-bordered" style="width: auto">
<thead class="thead-light">
<tr>
<th scope="col">Colour</th>
<th scope="col">Pins</th>
</tr>
</thead>
<tbody>
<tr>
<td>Red</td>
<td>5V</td>
</tr>
<tr>
<td>White</td>
<td>Gnd</td>
</tr>
<tr>
<td>Green</td>
<td>Trigger</td>
</tr>
<tr>
<td>Red</td>
<td>Echo</td>
</tr>
</tbody>
</table>
</div>
<div>
<h2>Usage</h2>
<h3>Run Arduino code</h3>
<ul>
<li>In Arduino IDE, program the board with the <a href="https://github.com/EE3-DTPRJ-Robot-Intelligence/Documentation-draft/blob/master/Ultrasonic/ultrasonic_hcsr04.ino"><code>ultrasonic_hcsr04.ino</code></a> code</li>
<li>Plug the pins according to the definitions in the <code>ultrasonic_hcsr04.ino</code> code</li>
</ul>
<h3></a>Gain access to port</h3>
<p>In terminal run,</p>
<pre><code class="hljs">sudo chmod 777 /dev/ACM0</code></pre>
<h3>Run python directly</h3>
<a href="https://github.com/EE3-DTPRJ-Robot-Intelligence/Documentation-draft/blob/master/Ultrasonic/ultrasonic.py"><code>ultrasonic.py</code></a>
<p>In terminal run,</p>
<pre><code class="hljs">python ultrasonic.py</code></pre>
<h3>Run ROS</h3>
<a href="https://github.com/EE3-DTPRJ-Robot-Intelligence/Documentation-draft/blob/master/Ultrasonic/ultrasonic_ros.py"><code>ultrasonic_ros.py</code></a>
<p>In terminal run,</p>
<pre><code class="hljs">roscore
source /devel/setup.bash
rosrun <PACKAGE NAME> ultrasonic_ros.py</code></pre>
<p>The data (array of int) is published to this rostopic: <code>/ultrasonic_data</code>
</div>
<div>
<h3>Run Quickie</h3>
<h4>Notes for applying ultrasonic data (ROS) with Quickie</h4>
<p>The idea was to utilise ultrasonic data published in rostopic and implement a safety feature on Quickie. The safety feature was to ensure that Quickie does not head in a direction where obstacles are present within 30 cm of Quickie. That means that Quickie will not respond to any command by the XBox controller which violates the 30 cm distance constraint.</p>
<p>In <code>joy_4.py</code> , the constraint is set by the variable ‘safe_distance’ which is set to 30 cm.<br>
The distance calculated by each ultrasonic sensor corresponds to the following indexed data of the tuple in ‘ultrasonic_dist_arr’.</p>
<p>Here is a diagram of the position of ultrasonic sensors on Quickie:</p>
<p><img src="asset/img/ultrasonic/position_of_ultrasonic.png"></p>
<p>Bearing in mind that distances exceeding the range is set to 0, the algorithm formulated is as follows:</p>
<pre><code class="hljs python"><span class="hljs-comment"># If ultrasonic_dist_arr[1/2/3/8] is < safe_distance and > 0,</span>
<span class="hljs-comment"># If speed>0,</span>
<span class="hljs-comment"># speed = 0</span>
<span class="hljs-comment"># If ultrasonic_dist_arr[7] is < safe_distance and > 0,</span>
<span class="hljs-comment"># If speed<0,</span>
<span class="hljs-comment"># speed = 0</span>
<span class="hljs-comment"># If ultrasonic_dist_arr[0/4/5/6] is < safe_distance and > 0,</span>
<span class="hljs-comment"># direction = 0</span></code></pre>
<h4>Run Quickie</h4>
<p>In terminal run,</p>
<pre><code class="hljs">python joy_4.py</code></pre>
</div>
</div> <!-- /#page-content-wrapper -->
</div> <!-- /#wrapper -->
<!-- call includeHTML() -->
<script type="text/javascript">includeHTML();</script>
<!-- Bootstrap core JavaScript ================================================== -->
<!-- jQuery first, then Popper.js, then Bootstrap JS -->
<!-- Placed at the end of the document so the pages load faster -->
<script type="text/javascript" src="vendor/jquery/jquery.min.js"></script>
<script type="text/javascript" src="vendor/popper/popper.min.js"></script>
<!-- Bootstrap core JS: Material design -->
<script type="text/javascript" src="vendor/material/js/bootstrap-material-design.min.js"></script>
</body>
</html>