Skip to content

Commit fd4e9ac

Browse files
committed
3. Party libs
1 parent 264adf2 commit fd4e9ac

17 files changed

+388
-174
lines changed

.github/workflows/TestCompile.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ on:
2020
pull_request:
2121
jobs:
2222
build:
23-
name: Test compiling examples for UNO
23+
name: Test compiling examples for Uno
2424
runs-on: ubuntu-latest
2525
env:
2626
REQUIRED_LIBRARIES: Servo,Adafruit Motor Shield V2 Library,PlayRtttl
@@ -44,7 +44,7 @@ jobs:
4444
-DDISTANCE_SERVO_IS_MOUNTED_HEAD_DOWN
4545
-mcall-prologues # reduces size by 870 bytes
4646

47-
- arduino-boards-fqbn: arduino:avr:uno|TimeOfFlight # UNO board with ToF distance sensor
47+
- arduino-boards-fqbn: arduino:avr:uno|TimeOfFlight # Uno board with ToF distance sensor
4848
build-properties:
4949
RobotCarBlueDisplay:
5050
-DMOTOR_SHIELD_2WD_FULL_CONFIGURATION

LICENSE.txt

Lines changed: 55 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
GNU GENERAL PUBLIC LICENSE
22
Version 3, 29 June 2007
33

4-
Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
4+
Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
55
Everyone is permitted to copy and distribute verbatim copies
66
of this license document, but changing it is not allowed.
77

@@ -618,4 +618,57 @@ an absolute waiver of all civil liability in connection with the
618618
Program, unless a warranty or assumption of liability accompanies a
619619
copy of the Program in return for a fee.
620620

621-
END OF TERMS AND CONDITIONS
621+
END OF TERMS AND CONDITIONS
622+
623+
How to Apply These Terms to Your New Programs
624+
625+
If you develop a new program, and you want it to be of the greatest
626+
possible use to the public, the best way to achieve this is to make it
627+
free software which everyone can redistribute and change under these terms.
628+
629+
To do so, attach the following notices to the program. It is safest
630+
to attach them to the start of each source file to most effectively
631+
state the exclusion of warranty; and each file should have at least
632+
the "copyright" line and a pointer to where the full notice is found.
633+
634+
<one line to give the program's name and a brief idea of what it does.>
635+
Copyright (C) <year> <name of author>
636+
637+
This program is free software: you can redistribute it and/or modify
638+
it under the terms of the GNU General Public License as published by
639+
the Free Software Foundation, either version 3 of the License, or
640+
(at your option) any later version.
641+
642+
This program is distributed in the hope that it will be useful,
643+
but WITHOUT ANY WARRANTY; without even the implied warranty of
644+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
645+
GNU General Public License for more details.
646+
647+
You should have received a copy of the GNU General Public License
648+
along with this program. If not, see <https://www.gnu.org/licenses/>.
649+
650+
Also add information on how to contact you by electronic and paper mail.
651+
652+
If the program does terminal interaction, make it output a short
653+
notice like this when it starts in an interactive mode:
654+
655+
<program> Copyright (C) <year> <name of author>
656+
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
657+
This is free software, and you are welcome to redistribute it
658+
under certain conditions; type `show c' for details.
659+
660+
The hypothetical commands `show w' and `show c' should show the appropriate
661+
parts of the General Public License. Of course, your program's commands
662+
might be different; for a GUI interface, you would use an "about box".
663+
664+
You should also get your employer (if you work as a programmer) or school,
665+
if any, to sign a "copyright disclaimer" for the program, if necessary.
666+
For more information on this, and how to apply and follow the GNU GPL, see
667+
<https://www.gnu.org/licenses/>.
668+
669+
The GNU General Public License does not permit incorporating your program
670+
into proprietary programs. If your program is a subroutine library, you
671+
may consider it more useful to permit linking proprietary applications with
672+
the library. If this is what you want to do, use the GNU Lesser General
673+
Public License instead of this License. But first, please read
674+
<https://www.gnu.org/licenses/why-not-lgpl.html>.

README.md

Lines changed: 49 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,47 @@
1-
# Autonomous driving robot car
2-
### Version 2.0.0
3-
[![License: GPL v3](https://img.shields.io/badge/License-GPLv3-blue.svg)](https://www.gnu.org/licenses/gpl-3.0)
4-
[![Commits since latest](https://img.shields.io/github/commits-since/ArminJo/Arduino-RobotCar/latest)](https://github.com/ArminJo/Arduino-RobotCar/commits/master)
5-
[![Build Status](https://github.com/ArminJo/Arduino-RobotCar/workflows/TestCompile/badge.svg)](https://github.com/ArminJo/Arduino-RobotCar/actions)
6-
![Hit Counter](https://visitor-badge.laobi.icu/badge?page_id=ArminJo_Arduino-RobotCar)
7-
8-
- Enables autonomous driving of a 2 or 4 wheel car controlled by an Arduino.
9-
- To avoid obstacles a HC-SR04 ultrasonic sensor mounted on a SG90 Servo continuously scans the environment.
1+
2+
<div align = center>
3+
4+
# [Autonomous driving robot car](https://github.com/ArminJo/Arduino-RobotCar)
5+
Enables autonomous driving of a 2 or 4 wheel car controlled by an Arduino.
6+
7+
[![Badge License: GPLv3](https://img.shields.io/badge/License-GPLv3-brightgreen.svg)](https://www.gnu.org/licenses/gpl-3.0)
8+
&nbsp; &nbsp;
9+
[![Badge Version](https://img.shields.io/github/v/release/ArminJo/Arduino-RobotCar?include_prereleases&color=yellow&logo=DocuSign&logoColor=white)](https://github.com/ArminJo/Arduino-RobotCar/releases/latest)
10+
&nbsp; &nbsp;
11+
[![Badge Commits since latest](https://img.shields.io/github/commits-since/ArminJo/Arduino-RobotCar/latest?color=yellow)](https://github.com/ArminJo/Arduino-RobotCar/commits/master)
12+
&nbsp; &nbsp;
13+
[![Badge Build Status](https://github.com/ArminJo/Arduino-RobotCar/workflows/TestCompile/badge.svg)](https://github.com/ArminJo/Arduino-RobotCar/actions)
14+
&nbsp; &nbsp;
15+
![Badge Hit Counter](https://visitor-badge.laobi.icu/badge?page_id=ArminJo_Arduino-RobotCar)
16+
<br/>
17+
<br/>
18+
[![Stand With Ukraine](https://raw.githubusercontent.com/vshymanskyy/StandWithUkraine/main/badges/StandWithUkraine.svg)](https://stand-with-ukraine.pp.ua)
19+
20+
Available as [RobotCarBlueDisplay](https://github.com/ArminJo/PWMMotorControl/tree/master/examples/RobotCarBlueDisplay) example of the Arduino library [PWMMotorControl](https://github.com/ArminJo/PWMMotorControl).<br/>
21+
Requires the Arduino library [BlueDisplay](https://github.com/ArminJo/Arduino-BlueDisplay).
22+
23+
</div>
24+
25+
#### If you find this program useful, please give it a star.
26+
27+
<br/>
28+
29+
# Features
30+
- Obstacles avoidance by a HC-SR04 ultrasonic sensor mounted on a SG90 Servo which continuously scans the environment.
1031
- To overcome the drawbacks of ultrasonic sensors, an additional IR or TOF (TimeOfFlight) sensor can be mounted to the servo.
11-
- Manual control is implemented by a GUI using a Bluetooth HC-05 Module and the [BlueDisplay library](https://github.com/ArminJo/Arduino-BlueDisplay).
32+
- Manual control implemented by a GUI using a Bluetooth HC-05 Module and the [BlueDisplay library](https://github.com/ArminJo/Arduino-BlueDisplay).
1233

1334
**Just overwrite the function doUserCollisionAvoiding() to test your own skill**.
1435
You may also overwrite the function fillAndShowForwardDistancesInfo(), if you use your own scanning method.
1536

16-
This example requires the **[PWMMotorControl library](https://github.com/ArminJo/PWMMotorControl)** to control the motors,
17-
the **[BlueDisplay library](https://github.com/ArminJo/BlueDisplay)** for Smartphone control and **[PlayRtttl library](https://github.com/ArminJo/PlayRtttl)** for the melody feature.
37+
# Installation
38+
- Install **[BlueDisplay library](https://github.com/ArminJo/BlueDisplay)** with *Tools > Manage Libraries...* or *Ctrl+Shift+I*. Use "BlueDisplay" as filter string.<br/>
39+
- Install **[PWMMotorControl library](https://github.com/ArminJo/PWMMotorControl)** with *Tools > Manage Libraries...* or *Ctrl+Shift+I*. Use "PWMMotorControl" as filter string.<br/>
40+
- Open the example **[RobotCarBlueDisplay](https://github.com/ArminJo/PWMMotorControl/tree/master/examples/RobotCarBlueDisplay)**, available at File > Examples > Examples from Custom Libraries / **PWMMotorControl**.
41+
42+
Other examples of PWMMotorControl like **[SmartCarFollower](https://github.com/ArminJo/PWMMotorControl#smartcarfollower)** will also run on this robot car.
43+
44+
<br/>
1845

1946
# Pictures
2047
| 4WD car with IR receiver and Bluetooth module and 4 AA rechargeable batteries. | Instructable |
@@ -25,9 +52,11 @@ the **[BlueDisplay library](https://github.com/ArminJo/BlueDisplay)** for Smartp
2552
| Encoder fork sensor | Servo mounted head down |
2653
| ![Encoder fork sensor](https://github.com/ArminJo/Arduino-RobotCar/blob/master/pictures/ForkSensor.jpg) | ![Servo mounting](https://github.com/ArminJo/Arduino-RobotCar/blob/master/pictures/ServoAtTopBack.jpg) |
2754
| VIN sensing with motor shield | Red car with Sharp GP2Y0A21YK distance sensor |
28-
| ![VIN sensing](https://github.com/ArminJo/Arduino-RobotCar/blob/master/pictures/SensingVIn.jpg) | https://github.com/ArminJo/Arduino-RobotCar/blob/master/pictures/RedCar.jpg |
29-
| Youtube video of mecanum demo | Youtube video of mecanum car controlled by the accelerator sensors of the tablet |
30-
| [![Arduino Mecanum Wheel Car Demo](https://i.ytimg.com/vi/https://youtu.be/VX92jeqr8_g/hqdefault.jpg)](https://www.youtube.com/watch?v=https://youtu.be/VX92jeqr8_g) | [![Arduino Mecanum Wheel Car Sensor Drive Demo](https://i.ytimg.com/vi/lhlxLTj9Mrg/hqdefault.jpg)](https://www.youtube.com/watch?v=lhlxLTj9Mrg) |
55+
| ![VIN sensing](https://github.com/ArminJo/Arduino-RobotCar/blob/master/pictures/SensingVIn.jpg) | ![Red car with Sharp GP2Y0A21YK distance sensor](https://github.com/ArminJo/Arduino-RobotCar/blob/master/pictures/RedCar.jpg) |
56+
| **Youtube video** of MecanumWheelCar demo | **Youtube video** of mecanum car controlled by the accelerator sensors of the tablet |
57+
| [![MecanumWheelCar Demo](https://i.ytimg.com/vi/VX92jeqr8_g/hqdefault.jpg)](https://www.youtube.com/watch?v=VX92jeqr8_g) | [![Arduino Mecanum Wheel Car Sensor Drive Demo](https://i.ytimg.com/vi/lhlxLTj9Mrg/hqdefault.jpg)](https://www.youtube.com/watch?v=lhlxLTj9Mrg) |
58+
59+
<br/>
3160

3261
# SCREENSHOTS
3362
| Start page | Test page |
@@ -45,13 +74,17 @@ Automatic control page with detected wall at right
4574
- The tiny white bars are the distances computed by the doWallDetection() function. They overlay the green (assumed timeout) values.
4675
- The tiny black bar is the rotation chosen by doCollisionAvoiding() function.
4776

77+
<br/>
78+
4879
# Wall detection
4980
Ultrasonic distance measurement has a problem with walls.
5081
You can **only detect a wall** if the angle of the wall relative to sensor axis is approximately **between 70 and 110 degree**.
5182
For other angels the reflected ultrasonic beam cannot reach the receiver which leads to unrealistic great distances.<br/>
5283
The implemented wall detection function `doWallDetection()` takes samples every 18 degrees and if it gets 2 adjacent short distances below `DISTANCE_MAX_FOR_WALL_DETECTION_CM`, it assumes a wall determined by these 2 samples.
5384
The (invalid) values 18 degrees right and left of these samples are then extrapolated by `computeNeigbourValue()`.
5485

86+
<br/>
87+
5588
# Compile options / macros for this software
5689
To customize the software to different car configurations, there are some compile options / macros available.<br/>
5790
Modify them by enabling / disabling them, or change the values if applicable.
@@ -61,7 +94,7 @@ Compile options for the used **PWMMotorControl library** like `USE_ENCODER_MOTOR
6194
| Name | Default value | Description |
6295
|-|-|-|
6396
| `CAR_HAS_VIN_VOLTAGE_DIVIDER` | undefined | VIN/11 at A2, e.g. 1 M&ohm; to VIN, 100 k&ohm; to ground. Required to show and monitor (for undervoltage) VIN voltage. |
64-
| `VIN_VOLTAGE_CORRECTION` | undefined or 0.8 for UNO | Voltage to be subtracted from VIN voltage for voltage monitoring. E.g. if there is a series diode between Li-ion and VIN as on the UNO boards, set it to 0.8. |
97+
| `VIN_VOLTAGE_CORRECTION` | undefined or 0.8 for Uno | Voltage to be subtracted from VIN voltage for voltage monitoring. E.g. if there is a series diode between Li-ion and VIN as on the Uno boards, set it to 0.8. |
6598
| `CAR_HAS_US_DISTANCE_SENSOR` | disabled | A HC-SR04 ultrasonic distance sensor is mounted (default for most China smart cars). |
6699
| `US_SENSOR_SUPPORTS_1_PIN_MODE` | disabled | Use modified HC-SR04 modules or HY-SRF05 ones.</br>Modify HC-SR04 by connecting 10 k&ohm; between echo and trigger and then use only trigger pin. |
67100
| `CAR_HAS_IR_DISTANCE_SENSOR` | disabled | Use Sharp GP2Y0A21YK / 1080 IR distance sensor. |

src/ADCUtils.h

Lines changed: 33 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -115,49 +115,52 @@
115115
extern float sVCCVoltage;
116116
extern uint16_t sVCCVoltageMillivolt;
117117

118-
extern long sLastVoltageCheckMillis;
119-
extern uint8_t sVoltageTooLowCounter;
120-
121-
uint16_t readADCChannel(uint8_t aChannelNumber);
122-
uint16_t readADCChannelWithReference(uint8_t aChannelNumber, uint8_t aReference);
123-
uint16_t waitAndReadADCChannelWithReference(uint8_t aChannelNumber, uint8_t aReference);
124-
uint16_t waitAndReadADCChannelWithReferenceAndRestoreADMUXAndReference(uint8_t aChannelNumber, uint8_t aReference);
125-
uint16_t readADCChannelWithOversample(uint8_t aChannelNumber, uint8_t aOversampleExponent);
126-
void setADCMultiplexerAndReferenceForNextConversion(uint8_t aChannelNumber, uint8_t aReference);
127-
uint16_t readADCChannelWithReferenceOversample(uint8_t aChannelNumber, uint8_t aReference, uint8_t aOversampleExponent);
128-
uint16_t readADCChannelWithReferenceOversampleFast(uint8_t aChannelNumber, uint8_t aReference, uint8_t aOversampleExponent);
129-
uint16_t readADCChannelWithReferenceMultiSamples(uint8_t aChannelNumber, uint8_t aReference, uint8_t aNumberOfSamples);
130-
uint16_t readADCChannelWithReferenceMax(uint8_t aChannelNumber, uint8_t aReference, uint16_t aNumberOfSamples);
131-
uint16_t readADCChannelWithReferenceMaxMicros(uint8_t aChannelNumber, uint8_t aReference, uint16_t aMicrosecondsToAquire);
132-
uint16_t readUntil4ConsecutiveValuesAreEqual(uint8_t aChannelNumber, uint8_t aDelay, uint8_t aAllowedDifference,
133-
uint8_t aMaxRetries);
134-
135-
uint8_t checkAndWaitForReferenceAndChannelToSwitch(uint8_t aChannelNumber, uint8_t aReference);
118+
extern long sLastVCCCheckMillis;
119+
extern uint8_t sVCCTooLowCounter;
120+
121+
uint16_t readADCChannel(uint8_t aADCChannelNumber);
122+
uint16_t readADCChannelWithReference(uint8_t aADCChannelNumber, uint8_t aReference);
123+
uint16_t waitAndReadADCChannelWithReference(uint8_t aADCChannelNumber, uint8_t aReference);
124+
uint16_t waitAndReadADCChannelWithReferenceAndRestoreADMUXAndReference(uint8_t aADCChannelNumber, uint8_t aReference);
125+
uint16_t readADCChannelWithOversample(uint8_t aADCChannelNumber, uint8_t aOversampleExponent);
126+
void setADCChannelAndReferenceForNextConversion(uint8_t aADCChannelNumber, uint8_t aReference);
127+
uint16_t readADCChannelWithReferenceOversample(uint8_t aADCChannelNumber, uint8_t aReference, uint8_t aOversampleExponent);
128+
uint16_t readADCChannelWithReferenceOversampleFast(uint8_t aADCChannelNumber, uint8_t aReference, uint8_t aOversampleExponent);
129+
uint16_t readADCChannelWithReferenceMultiSamples(uint8_t aADCChannelNumber, uint8_t aReference, uint8_t aNumberOfSamples);
130+
uint16_t readADCChannelWithReferenceMax(uint8_t aADCChannelNumber, uint8_t aReference, uint16_t aNumberOfSamples);
131+
uint16_t readADCChannelWithReferenceMaxMicros(uint8_t aADCChannelNumber, uint8_t aReference, uint16_t aMicrosecondsToAquire);
132+
uint16_t readUntil4ConsecutiveValuesAreEqual(uint8_t aADCChannelNumber, uint8_t aReference, uint8_t aDelay,
133+
uint8_t aAllowedDifference, uint8_t aMaxRetries);
134+
135+
uint8_t checkAndWaitForReferenceAndChannelToSwitch(uint8_t aADCChannelNumber, uint8_t aReference);
136136

137137
/*
138138
* readVCC*() functions store the result in sVCCVoltageMillivolt or sVCCVoltage
139139
*/
140-
float getVCCVoltageSimple();
141-
void readVCCVoltageSimple();
142-
uint16_t getVCCVoltageMillivoltSimple();
143-
void readVCCVoltageMillivoltSimple();
144-
float getVCCVoltage();
145-
void readVCCVoltage();
146-
uint16_t getVCCVoltageMillivolt();
147-
void readVCCVoltageMillivolt();
148-
uint16_t getVCCVoltageReadingFor1_1VoltReference();
140+
float getVCCVoltageSimple(void);
141+
void readVCCVoltageSimple(void);
142+
uint16_t getVCCVoltageMillivoltSimple(void);
143+
void readVCCVoltageMillivoltSimple(void);
144+
float getVCCVoltage(void);
145+
void readVCCVoltage(void);
146+
uint16_t getVCCVoltageMillivolt(void);
147+
void readVCCVoltageMillivolt(void);
148+
uint16_t getVCCVoltageReadingFor1_1VoltReference(void);
149149
uint16_t printVCCVoltageMillivolt(Print *aSerial);
150150
void readAndPrintVCCVoltageMillivolt(Print *aSerial);
151151

152152
uint16_t getVoltageMillivolt(uint16_t aVCCVoltageMillivolt, uint8_t aADCChannelForVoltageMeasurement);
153153
uint16_t getVoltageMillivolt(uint8_t aADCChannelForVoltageMeasurement);
154154
uint16_t getVoltageMillivoltWith_1_1VoltReference(uint8_t aADCChannelForVoltageMeasurement);
155-
float getTemperatureSimple();
156-
float getTemperature();
155+
float getCPUTemperatureSimple(void);
156+
float getCPUTemperature(void);
157+
float getTemperature(void) __attribute__ ((deprecated ("Renamed to getCPUTemperature()"))); // deprecated
157158

158159
bool isVCCTooLowMultipleTimes();
159160
void resetVCCTooLowMultipleTimes();
160-
bool isVoltageTooLow();
161+
bool isVCCTooLow();
162+
bool isVCCTooHigh();
163+
bool isVCCTooHighSimple();
161164

162165
#endif // defined(__AVR__) ...
163166
#endif // _ADC_UTILS_H

0 commit comments

Comments
 (0)