Home

Awesome

<div align = center>

Autonomous driving robot car

Enables autonomous driving of a 2 or 4 wheel car controlled by an Arduino.

Badge License: GPLv3     Badge Version     Badge Commits since latest     Badge Build Status     Badge Hit Counter <br/> <br/> Stand With Ukraine

Available as RobotCarBlueDisplay example of the Arduino library PWMMotorControl.<br/> Requires the Arduino library BlueDisplay.

</div>

If you find this program useful, please give it a star.

🌎 Google Translate

<br/>

Features

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

Installation

Other examples of PWMMotorControl like SmartCarFollower will also run on this robot car.

<br/>

Pictures

4WD car with IR receiver and Bluetooth module and 4 AA rechargeable batteries.Instructable
4 wheel carInstructable
4 wheel car like the 2 WD car right, but with servo mounted head up.2 wheel car with encoders, 2 Li-ion batteries, Adafruit Motor Shield V2, Bluetooth connection, and servo mounted head down.
4 wheel car2 wheel car
Encoder fork sensorServo mounted head down
Encoder fork sensorServo mounting
VIN sensing with motor shieldRed car with Sharp GP2Y0A21YK distance sensor
VIN sensingRed car with Sharp GP2Y0A21YK distance sensor
Youtube video of MecanumWheelCar demoYoutube video of mecanum car controlled by the accelerator sensors of the tablet
MecanumWheelCar DemoArduino Mecanum Wheel Car Sensor Drive Demo
<br/>

SCREENSHOTS

Start pageTest page
Start pageTest page
Sensor drive pageSensor drive page for mecanum car
Sensor drive pageSensor drive page for mecanum car

Automatic control page with detected wall at right Automatic control page

<br/>

Wall detection

Ultrasonic distance measurement has a problem with walls. You can only detect a wall if the angle of the wall relative to sensor axis is approximately between 70 and 110 degree. For other angels the reflected ultrasonic beam cannot reach the receiver which leads to unrealistic great distances.<br/> 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. The (invalid) values 18 degrees right and left of these samples are then extrapolated by computeNeigbourValue().

<br/>

Compile options / macros for this software

To customize the software to different car configurations, there are some compile options / macros available.<br/> Modify them by enabling / disabling them, or change the values if applicable.

Compile options for the used PWMMotorControl library like USE_ENCODER_MOTOR_CONTROL are described here.

NameDefault valueDescription
CAR_HAS_VIN_VOLTAGE_DIVIDERundefinedVIN/11 at A2, e.g. 1 MΩ to VIN, 100 kΩ to ground. Required to show and monitor (for undervoltage) VIN voltage.
VIN_VOLTAGE_CORRECTIONundefined or 0.8 for UnoVoltage 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.
CAR_HAS_US_DISTANCE_SENSORdisabledA HC-SR04 ultrasonic distance sensor is mounted (default for most China smart cars).
US_SENSOR_SUPPORTS_1_PIN_MODEdisabledUse modified HC-SR04 modules or HY-SRF05 ones.</br>Modify HC-SR04 by connecting 10 kΩ between echo and trigger and then use only trigger pin.
CAR_HAS_IR_DISTANCE_SENSORdisabledUse Sharp GP2Y0A21YK / 1080 IR distance sensor.
CAR_HAS_TOF_DISTANCE_SENSORdisabledUse VL53L1X TimeOfFlight distance sensor.
CAR_HAS_DISTANCE_SERVOdisabledDistance sensor is mounted on a pan servo (default for most China smart cars).
DISTANCE_SERVO_IS_MOUNTED_HEAD_DOWNdisabledDistance.h
CAR_HAS_PAN_SERVOdisabledEnables the pan slider for the PanServo at the PAN_SERVO_PIN pin.
CAR_HAS_TILT_SERVOdisabledEnables the tilt slider for the TiltServo at the TILT_SERVO_PIN pin.
CAR_HAS_CAMERAdisabledEnables the Camera button for the CAMERA_SUPPLY_CONTROL_PIN pin.
CAR_HAS_LASERdisabledEnables the Laser button for the LASER_OUT_PIN / LED_BUILTIN pin.
ENABLE_RTTTL_FOR_CARundefinedPlays melody after initial timeout has reached. Enables the Melody button, which plays a random melody.
MONITOR_VIN_VOLTAGEdisabledShows VIN voltage and monitors it for undervoltage. VIN/11 at A2, 1 MΩ to VIN, 100 kΩ to ground.
ENABLE_EEPROM_STORAGEdisabledActivates the buttons to store compensation values. Normally they are stored after calibration.

Changing include (*.h) files with Arduino IDE

First, use Sketch > Show Sketch Folder (Ctrl+K).<br/> If you have not yet saved the example as your own sketch, then you are instantly in the right library folder.<br/> Otherwise you have to navigate to the parallel libraries folder and select the library you want to access.<br/> In both cases the library source and include files are located in the libraries src directory.<br/> The modification must be renewed for each new library version!

Modifying compile options / macros with PlatformIO

If you are using PlatformIO, you can define the macros in the platformio.ini file with build_flags = -D MACRO_NAME or build_flags = -D MACRO_NAME=macroValue.

Modifying compile options / macros with Sloeber IDE

If you are using Sloeber as your IDE, you can easily define global symbols with Properties > Arduino > CompileOptions.<br/> Sloeber settings