Difference between revisions of "Self Driving RC Car/2020"
Jump to navigation
Jump to search
(103 intermediate revisions by 2 users not shown) | |||
Line 2: | Line 2: | ||
<youtube>OL0vg1WmI6I</youtube> | <youtube>OL0vg1WmI6I</youtube> | ||
<youtube>YeUMtQyvZKM</youtube> | <youtube>YeUMtQyvZKM</youtube> | ||
+ | |||
+ | = Presentation = | ||
+ | <pdf>https://www.doag.org/formes/pubfiles/11143501/2019-NN-Tim_van_Eijndhoven-Building_a_Self-driving_RC_Car-Praesentation.pdf</pdf> | ||
= Source Code = | = Source Code = | ||
* https://github.com/rc-dukes/dukes | * https://github.com/rc-dukes/dukes | ||
+ | In the [https://rc-dukes.github.io/dukes/dukes/apidocs/ javadoc apidocs] | ||
+ | you'll also find generated uml-diagrams like this one: | ||
+ | https://rc-dukes.github.io/dukes/dukes/apidocs/nl/vaneijndhoven/daisy/package.svg | ||
= Parts List = | = Parts List = | ||
+ | [http://wiki.bitplan.com/images/wiki/3/35/RCCarPartsList2019-06-07.xlsx Parts-List as Excel File] | ||
{| class="wikitable" | {| class="wikitable" | ||
|- | |- | ||
− | ! # !! part !! example | + | ! # !! picture !! part !! example sources !! documents !! ~ price |
+ | |- | ||
+ | | 1 || [[File:RC Car Chassis 2019-06-07.jpeg|200px]] || 1:10 RC Car chassis || | ||
+ | #[https://www.conrad.nl/p/110-elektro-tourenwagen-chassis-arr-238011 1:10 elektro tourenwagen chassis ARR] | ||
+ | #[https://www.amazon.de/gp/product/B01JLF7GB0 TAMIYA 57986" 1:10 RC TT-02-Chassis First Try On-Road] | ||
+ | | | ||
+ | # [https://produktinfo.conrad.com/datenblaetter/225000-249999/238011-an-01-ml-1_10_EP_TOURINGCAR_4WD_ARR_de_en_fr_nl.pdf de/en/fr/nl] | ||
+ | # [https://tamiyabase.com/tamiya-models/57986 Tamiya 57986] | ||
+ | | 70 € | ||
+ | |- | ||
+ | | 2 || [[File:SpeedControl 2019-06-06.jpg|200px]] || Speed Control || [https://www.conrad.de/de/p/modelcraft-carbon-series-automodell-brushed-fahrtregler-belastbarkeit-max-60-a-motorlimit-turns-20-207368.html Modelcraft Carbon Series Speed Control "20 Turns"] || [https://produktinfo.conrad.com/datenblaetter/200000-224999/207368-an-01-ml-CARBON_FAHRTREG_20TURNS_de_en_fr_nl.pdf de/en/fr/nl] || 21 € | ||
+ | |- | ||
+ | | 3 || [[File:RC Car Servo 2019-06-06.jpg|200px]] || RC-Car servo | ||
+ | | | ||
+ | #[https://www.conrad.nl/p/rc-car-servo-4519-206464 RC-Car servo 4519] | ||
+ | #[https://www.amazon.de/gp/product/B005UDQBX2 Carson 500502036 - Servo CS-6 - 6 kg/JR-Stecker ] | ||
+ | | [https://produktinfo.conrad.com/datenblaetter/200000-224999/206464-da-01-ml-PREMIUM_LINE_RC_CAR_SERVO_4519_de_en.pdf de/en] || 10 € | ||
+ | |- | ||
+ | | 4 || [[File:TopFuel-LiPo-25C-ECO-X-1300mAh-3S-21300341 b 0.JPG|200px]] || LiPo Battery 11 Volt 1300 mAh | | ||
+ | | | ||
+ | # [https://www.hacker-motor-shop.com/Batteries-and-accessories/Battery-search/TopFuel-LiPo-25C-ECO-X-1300mAh-3S.htm?shop=hacker_e&SessionId=&a=article&ProdNr=21300341&p=11452 TopFuel LiPo 25C-ECO-X 1300mAh 3S] | ||
+ | # [https://www.amazon.de/FLOUREON-Modellbau-Batterie-Ersatzakku-Helikopter/dp/B01N0NC0KY NiMH 7.2V 3500 mAh] | ||
+ | || || 16 € | ||
+ | |- | ||
+ | | 5 || [[File:Absima CB 1S BatteryCharger 2019-06-06.jpg|200px]] || Battery Charger | ||
+ | | | ||
+ | # | ||
+ | #[https://www.amazon.de/ANSMANN-Akkupack-Ladegerät-ACS-Akkupacklader-Schwarz/dp/B00WI4KRTK Ansmann NiMH Charger] | ||
+ | || || 27 € | ||
+ | |- | ||
+ | | 6 || [[File:713LX1Z383L. SL1500 .jpg|200px]] || Raspberry PI 3 B+ || [https://www.amazon.de/Raspberry-1373331-Pi-Modell-Mainboard/dp/B07BDR5PDW Raspberry PI 3 B+] || [https://www.raspberrypi.org/documentation/hardware/computemodule/datasheets/rpi_DATA_CM3plus_1p0.pdf en] || 35 € | ||
+ | |- | ||
+ | | 7 || [[File:81UBu4aoQHL. SL1500 .jpg|200px]] || microSD Card || [https://www.amazon.de/dp/B073S9SFK2/ SanDisk 16 GB] || || 7 € | ||
+ | |- | ||
+ | | 8 || [[File:61Z5yEYfnAL. SL1426 .jpg|200px]] || Raspberry PI Camera || [https://www.amazon.de/Raspberry-Pi-V2-1-1080P-Kamera-Modul/dp/B01ER2SKFS 1080 p Camera Module] || || 23 € | ||
|- | |- | ||
− | | | + | | 9 || [[File:41smcErJNjL.jpg|200px]] || DC/DC Converter 12 V-> 5V || [https://www.amazon.de/riorand-Display-Netzteil-Converter-Modul/dp/B00G890MIC 12 V->5 V Converter Module] || || 7 € |
|- | |- | ||
− | | | + | | 10 || [[File:31pzC7A3D3L.jpg|200px]] || Micro USB Connector || [https://www.amazon.de/Delock-Stecker-Offene-Kabelenden-schwarz/dp/B01A9GLG6Q Delock USB 2.0 Micro USB] || || 6 € |
|- | |- | ||
− | | | + | | || || || ||Total || 199 € |
− | |||
|- | |- | ||
− | | | + | | a |
+ | | [[File:71AYEqpWHcL. SL1500 .jpg|200px]] | ||
+ | | Breadbord Kit | ||
+ | | [https://www.amazon.de/gp/product/B01N4VCYUK MB102 Breadbord Kit] | ||
+ | | | ||
+ | | 7 € | ||
|- | |- | ||
+ | | b | ||
+ | | [[File:714Ep9LpwoL. SL1200 .jpg | 200 px]] | ||
+ | | Ulrasound Sensor | ||
+ | | [https://www.amazon.de/gp/product/B01M9CMJ9O 5 x HC-SR04 + Cables] | ||
+ | | | ||
+ | | 10 € | ||
|} | |} | ||
+ | = Assembly = | ||
+ | == DCC-DCC converter == | ||
+ | To run the Raspberry PI from the 7.4 Volt Battery of the car the DC-DC converter has to be soldered | ||
+ | into the voltage supply chain. You might want to select a converter with enough power for your usecase | ||
+ | === 15 Watt 3 A === | ||
+ | This configuration works if you only want to run a Raspberry PI and directly control the motor and steering servos of the RC car. | ||
+ | <gallery> | ||
+ | File:RC_IMG_3116.JPG | ||
+ | File:RC_IMG_3118.JPG | ||
+ | File:RC_IMG_3120.JPG | ||
+ | File:RC_IMG_3122.JPG | ||
+ | </gallery> | ||
+ | === 25 Watt 5 A === | ||
+ | This configuration is currently tried for running the servos over an Adafruit 16 channel servo controller and using extra servos. | ||
+ | [[File:DSC00011-parts.JPG|800px]] | ||
+ | [[File:DSC00016-connected.JPG|800px]] | ||
+ | |||
+ | == Camera mount == | ||
+ | <gallery> | ||
+ | File:RC_IMG_3124.JPG | ||
+ | File:RC_IMG_3125.JPG | ||
+ | </gallery> | ||
+ | == Servo and LED == | ||
+ | [[File:RcCarWiring2019-06-22.png|800px]] | ||
+ | |||
+ | = Raspberry = | ||
+ | For a start a [https://www.thingiverse.com/thing:2786498 3D Printed case] for the Raspberry PI was used: | ||
+ | |||
+ | https://cdn.thingiverse.com/renders/c4/f0/15/73/67/2094b280ac54121f9dad5fc172b1a3eb_preview_featured.jpg | ||
+ | https://cdn.thingiverse.com/renders/1b/80/70/b5/5a/081727802f13879a77f4b8bfbd0277d1_preview_featured.jpg | ||
+ | |||
+ | [[File:RaspberryWithCaseIMG_0025.JPG|800px]] | ||
+ | |||
+ | = PI Installation = | ||
+ | see {{Link|target=Raspberry PI}} | ||
+ | |||
+ | |||
+ | == WebCam Interface == | ||
+ | * https://github.com/silvanmelchior/RPi_Cam_Web_Interface | ||
+ | <source lang='bash'> | ||
+ | cd /usr/local/src | ||
+ | sudo git clone https://github.com/silvanmelchior/RPi_Cam_Web_Interface.git | ||
+ | cd RPi_Cam_Web_Interface/ | ||
+ | ./install.sh | ||
+ | </source> | ||
+ | [[File:WebCamInterface2019-06-21.png|600px]] | ||
+ | === In case of error === | ||
+ | A message like: | ||
+ | <source lang='bash'> | ||
+ | #mmal: mmal_component_create_core: could not create component 'vc.ril.camera' (1) | ||
+ | sh: 1: /var/www/html/macros/error_hard.sh: Permission denied | ||
+ | </source> | ||
+ | Indicates that you might have a cabling problem. | ||
+ | === In case of success === | ||
+ | http://<yourpi>/html should show the cam interface: | ||
+ | [[File:RpiCamControl2019-06-21.png|600px]] | ||
+ | |||
+ | == Servo Interface - Servoblaster == | ||
+ | * https://github.com/richardghirst/PiBits/tree/master/ServoBlaster | ||
+ | * https://github.com/srcshelton/servoblaster | ||
+ | <source lang='bash'> | ||
+ | wf@pibee:~ $ cd /usr/local/src | ||
+ | wf@pibee:/usr/local/src $ sudo git clone https://github.com/srcshelton/servoblaster | ||
+ | cd servoblaster | ||
+ | sudo make install | ||
+ | sudo reboot | ||
+ | </source> | ||
+ | |||
+ | == OpenJDK == | ||
+ | <source lang='bash'> | ||
+ | sudo apt-get install openjdk-8-jdk | ||
+ | </source> | ||
+ | == Screen == | ||
+ | <source lang='bash'> | ||
+ | sudo apt-get install screen | ||
+ | </source> | ||
+ | = Server Installation = | ||
+ | Tested on | ||
+ | # Mac OS 10.13.6 High Sierra with macports 2.5.4 | ||
+ | # Ubuntu 18.04.2 LTS | ||
+ | == OpenCV == | ||
+ | see also {{Link|target=OpenCV}} | ||
+ | === MacOS === | ||
+ | If you'd like to generally use OpenCV you can get it e.g. from the macports project: | ||
+ | ==== MacPorts ==== | ||
+ | <source lang='bash'> | ||
+ | sudo port install opencv +java | ||
+ | ls /opt/local/share/OpenCV/java | ||
+ | libopencv_java343.dylib opencv-343.jar | ||
+ | </source> | ||
+ | For your convenience you'll find these two files in the lib directory. | ||
+ | ==== From Source ==== | ||
+ | # install5 in opencvubuntu has the commands for MacOS - but does not work even if you install dpkg with | ||
+ | <source lang='bash'> | ||
+ | sudo port install dpkg | ||
+ | </source> | ||
+ | |||
+ | === Ubuntu 18 === | ||
+ | You might want to use scripts/opencvubuntu to download the 75 MByte libopencv_java343.so and install the backports libjasper libraries that are not published with Ubuntu 18 by default. You'll find | ||
+ | some other links in the script that might also give you hints on how to proceed if you have another environment or different needs. You might want to create an Issue if you run into trouble. | ||
+ | === Windows === | ||
+ | Help Wanted -please file an issue if you want to try to get things running on Windows. | ||
+ | |||
+ | = Deployment = | ||
+ | |||
+ | Deploying to your Raspberry is done by compiling e.g. on a laptop and then transferring | ||
+ | the results to your PI. | ||
+ | |||
+ | == Compile == | ||
+ | <source lang='bash'> | ||
+ | scripts/install.sh | ||
+ | </source> | ||
+ | There is a usage for this script if you call it with <nowiki>scripts/install.sh -h</nowiki>. | ||
+ | Essentially this is doing a <nowiki>mvn clean install</nowiki>. The clean part is important to get the platform specific native openCV Library integrated into the server code. | ||
+ | |||
+ | == Example Configuration == | ||
+ | |||
+ | You need to configure your PI's host address and user in a file ~/dukes/dukes.ini in the remotecar section. | ||
+ | Also you need to check your GPIO pins and the servo settings for your car for LED,Engine and Wheels. You might want to try these things out before using the software the first time. | ||
+ | |||
+ | The original wiring is: | ||
+ | |||
+ | * MOTOR: GPIO-17 - Servoblaster ID 1 | ||
+ | * WHEEL: GPIO-18 - Servoblaster ID 2 | ||
+ | * LED: GPIO-24 - Servolbaster ID 6 | ||
+ | The software uses the standard Servoblaster ID's above which are hard-coded at this time. The GPIO configuration will only work with other devices which we intend to support in the future. | ||
+ | <source lang='bash'> | ||
+ | # | ||
+ | # WF 2019-06-21 | ||
+ | # | ||
+ | # rc-duke configuration file | ||
+ | # remote car raspberry PI configuration | ||
+ | remotecar.host=picaro | ||
+ | remotecar.user=wf | ||
+ | # camera url format | ||
+ | camera.url=http://picaro/html/cam_pic_new.php | ||
+ | # webserver configuration | ||
+ | webcontrol.port=8080 | ||
+ | imageview.port=8081 | ||
+ | # watchdog | ||
+ | # how often to send a heart beat in milliseconds | ||
+ | watchdog.heartbeat.interval.ms=150 | ||
+ | # how many beats may be missed before remote car is forced to stop | ||
+ | watchdog.max.missed.beats=6 | ||
+ | # use servoblaster as servo control | ||
+ | servo.command=servoblaster | ||
+ | # be careful with your GPIO configuration | ||
+ | # you might damage your PI with a misconfiguration! | ||
+ | # led configuration | ||
+ | led.gpio=24 | ||
+ | led.on=250 | ||
+ | led.off=0 | ||
+ | # wheel configuration | ||
+ | wheel.gpio=18 | ||
+ | # positive - higher values mean go right | ||
+ | wheel.orientation=+ | ||
+ | wheel.center=144 | ||
+ | wheel.stepsize=1 | ||
+ | wheel.max.left=115 | ||
+ | wheel.max.left.angle=-18.0 | ||
+ | wheel.max.right=158 | ||
+ | wheel.max.right.angle=14 | ||
+ | # engine configuration | ||
+ | engine.gpio=17 | ||
+ | # positive - higher values means going quicker | ||
+ | engine.orientation=+ | ||
+ | engine.speed.zero=130 | ||
+ | engine.stepsize=1 | ||
+ | engine.min.speed.reverse=127 | ||
+ | engine.max.speed.reverse=122 | ||
+ | engine.min.speed.forward=133 | ||
+ | engine.max.speed.forward=138 | ||
+ | engine.max.velocity.reverse=-1.0 | ||
+ | engine.min.velocity.reverse=-0.5 | ||
+ | engine.min.velocity.forward=0.23 | ||
+ | engine.max.velocity.forward=1.0 | ||
+ | </source> | ||
+ | The deploy script as a help option that shows how it can be used: | ||
+ | <source lang='bash'> | ||
+ | deploy.sh [-a|-d|-h|-m|-s] | ||
+ | |||
+ | -a |--autostart : configure the remotecar app to autostart on reboot | ||
+ | -d |--debug : debug this script | ||
+ | -m |--maven : run maven install | ||
+ | -h |--help : show this usage | ||
+ | -s |--start : deploy and start remotecar (duke) fat jar | ||
+ | </source> | ||
+ | * <nowiki>deploy -m</nowiki> will create the duke-farm fat jar | ||
+ | * <nowiki>deploy -s</nowiki> will send the jar to your PI using rsync and start it | ||
+ | * <nowiki>deploy -a</nowiki> will create an autostart configuration that restarts the client on reboot see https://github.com/rc-dukes/dukes/issues/26 | ||
+ | |||
+ | == Running the server == | ||
+ | - start 'CarServer' in module 'rc-server' in IDE | ||
+ | - point your browser to http://localhost:8080 | ||
+ | === Creating a fatjar of the server === | ||
+ | <source lang='bash'> | ||
+ | ../scripts/install.sh -h | ||
+ | usage: install.sh [-d|-f|-j|-q]* [-h]? | ||
+ | |||
+ | -d |--debug : debug this script | ||
+ | -f |--fatjar : create a fat jar | ||
+ | -j |--javadoc : with javadoc (default is without) | ||
+ | -q |--quick : no tests, no javadoc | ||
+ | |||
+ | -h |--help : show this usage | ||
+ | </source> | ||
+ | From the rc-server directory <nowiki>../scripts/install.sh -f -q</nowiki> | ||
+ | should create a fat jar with the maven assembly-plugin | ||
+ | |||
+ | <source lang='bash'>java -jar target/rc-server-0.0.2-jar-with-dependencies.jar</source> | ||
+ | (Please replace 0.0.2 with the current version of the project) | ||
+ | |||
+ | Should then start the server and the web ui should be available by either using | ||
+ | |||
+ | http://localhost:8080 | ||
+ | or using the index.html file or detect.html files from the sources in rc-webcontrol/src/main/resources/web/ | ||
+ | == Starting all together == | ||
+ | The start script will let you pick the components you'd like to start. | ||
+ | <source lang='bash'> | ||
+ | scripts/start -h | ||
+ | start [-d|-h] | ||
+ | |||
+ | -a |--all : run all parts of the software | ||
+ | -c |--car : run car software on pi | ||
+ | -s |--server : run server software | ||
+ | -r |--remote : point webbrowser to remot control | ||
+ | -w |--web : point webbrowser to detect.html | ||
+ | -d |--debug : debug this script | ||
+ | -h |--help : show this usage | ||
+ | </source> | ||
+ | So <nowiki>scripts/start -a</nowiki> will start | ||
+ | # the car software on the pi | ||
+ | # the server software e.g. on you laptop | ||
+ | # point your webrowser to the detect.html page (after waiting for the page to get available) | ||
+ | |||
+ | = First Experiments = | ||
+ | These are just some experiments with the Raspberry PI, Ultrasonic Sensors and Servos that might you get warmed up for the real | ||
+ | challenge of getting your 1:10 RC self driving car going. You don't need to go thru all theses experiments. The basic car only uses the camera and two servos and no ultrasonic sensors. | ||
+ | # {{Link|target=Ultrasonic Sensor}} | ||
+ | # {{Link|target=SG90-Servo}} | ||
+ | # {{Link|target=Raspberry PI Camera}} | ||
+ | # {{Link|target=Raspberry PWM LED Control}} | ||
+ | # <youtube>2vAoOYF3m8U</youtube> | ||
+ | Author: {{Link|target=Wolfgang Fahl}} | ||
<headertabs/> | <headertabs/> | ||
+ | [[Category:Raspberry]][[Category:Self Driving RC Car]][[Category:frontend]] |