{"id":21072473,"url":"https://github.com/lukas/robot","last_synced_at":"2025-05-16T05:32:26.353Z","repository":{"id":66365465,"uuid":"65312129","full_name":"lukas/robot","owner":"lukas","description":"Simple library for controlling a raspberry pi based robot","archived":false,"fork":false,"pushed_at":"2017-10-19T22:18:28.000Z","size":64,"stargazers_count":178,"open_issues_count":5,"forks_count":50,"subscribers_count":36,"default_branch":"master","last_synced_at":"2025-03-18T01:35:11.225Z","etag":null,"topics":["camera","raspberry-pi","robot","robotics","sonar","wheel"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/lukas.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2016-08-09T16:50:21.000Z","updated_at":"2025-02-19T13:03:36.000Z","dependencies_parsed_at":null,"dependency_job_id":"eb9e63b9-aeb1-49bb-b582-f3691dd3b8bd","html_url":"https://github.com/lukas/robot","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lukas%2Frobot","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lukas%2Frobot/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lukas%2Frobot/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lukas%2Frobot/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/lukas","download_url":"https://codeload.github.com/lukas/robot/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254474630,"owners_count":22077324,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["camera","raspberry-pi","robot","robotics","sonar","wheel"],"created_at":"2024-11-19T18:56:39.324Z","updated_at":"2025-05-16T05:32:26.348Z","avatar_url":"https://github.com/lukas.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# robot\n\nThis will run a simple robot with a webserver on a raspberry PI with the Adafruit Motor Hat.  I wrote this up for myself for fun and to help me remember how I set things up.\n\nHigh level overview can be found in this article: https://www.oreilly.com/learning/how-to-build-a-robot-that-sees-with-100-and-tensorflow\n\n## Hardware\n\n- Raspberry PI 3\n- 16GB (or larger) SIM Card\n- Adafruit Motor Hat (for wheels)\n- Any chassis with DC motors - for example: https://www.amazon.com/Emgreat-Chassis-Encoder-wheels-Battery/dp/B00GLO5SMY/ref=sr_1_2?ie=UTF8\u0026qid=1486959207\u0026sr=8-2\u0026keywords=robot+chassis\n- Adafruit Servo Hat (for arms)\n- HC-SR04 sonars\n- Any stepper motor arm - for example: SainSmart DIY Control Palletizing Robot Arm for the arm (https://www.amazon.com/dp/B0179BTLZ2/ref=twister_B00YTW763Y?_encoding=UTF8\u0026psc=1)\n- Raspberry PI compatible camera - for example: https://www.amazon.com/Raspberry-Pi-Camera-Module-Megapixel/dp/B01ER2SKFS/ref=sr_1_1?s=electronics\u0026ie=UTF8\u0026qid=1486960149\u0026sr=1-1\u0026keywords=raspberry+pi+camera\n\nTo get started, you should be able to make the robot work without the arm, sonar and servo hat.\n\n## Programs\n\n- robot.py program will run commands from the commandline\n- sonar.py tests sonar wired into GPIO ports\n- wheels.py tests simple DC motor wheels\n- arm.py tests a servo controlled robot arm\n- autonomous.py implements a simple driving algorithm using the wheels and sonal\n- inception_server.py runs an image classifying microservice\n\n## Example Robots\n\nHere are two robots I made that use this software\n\n![Robots](https://joyfulgrit.files.wordpress.com/2013/10/img_0183.jpg?w=700)\n\n## Wiring The Robot\n### Sonar\n\nIf you want to use the default sonar configuation, wire like this:\n\n- Left sonar trigger GPIO pin 23 echo 24\n- Center sonar trigger GPIO pin 17 echo 18\n- Right sonar trigger GPIO pin 22 echo 27\n\nYou can modify the pins by making a robot.conf file.\n\n### Wheels\n\nYou can easily change this but this is what wheels.py expects\n\n- M1 - Front Left\n- M2 - Back Left (optional - leave unwired for 2wd chassis)\n- M3 - Back Right (optional - leave unwired for 2wd chassis)\n- M4 - Front Right \n\n\n## Installation\n\n### basic setup\n\nThere are a ton of articles on how to do basic setup of a Raspberry PI - one good one is here https://www.howtoforge.com/tutorial/howto-install-raspbian-on-raspberry-pi/\n\nYou will need to turn on i2c and optionally the camera\n\n```\nraspi-config\n```\n\nNext you will need to download i2c tools and smbus\n\n```\nsudo apt-get install i2c-tools python-smbus python3-smbus\n```\n\nTest that your hat is attached and visible with\n\n```\ni2cdetect -y 1\n```\n\nInstall this code\n\n```\nsudo apt-get install git\ngit clone https://github.com/lukas/robot.git\ncd robot\n```\n\nInstall dependencies\n\n```\npip install -r requirements.txt\n```\n\nAt this point you should be able to drive your robot locally, try:\n\n```\n./robot.py forward\n```\n\n### server\n\nTo run a webserver in the background with a camera you need to setup gunicorn and nginx\n\n#### nginx\n\nNginx is a lightway fast reverse proxy - we store the camera image in RAM and serve it up directly.  This was the only way I was able to get any kind of decent fps from the raspberry pi camera.  We also need to proxy to gunicorn so that the user can control the robot from a webpage.\n\ncopy the configuration file from nginx/nginx.conf to /etc/nginx/nginx.conf\n\n```\nsudo apt-get install nginx\nsudo cp nginx/nginx.conf /etc/nginx/nginx.conf\n```\n\nrestart nginx\n\n```\nsudo nginx -s reload\n```\n\n#### gunicorn\n\ninstall gunicorn\n\n\ncopy configuration file from services/web.service /etc/systemd/system/web.service\n\n```\nsudo cp services/web.service /etc/systemd/system/web.service\n```\n\nstart gunicorn web app service\n\n```\nsudo systemctl daemon-reload\nsudo systemctl enable web\nsudo systemctl start web\n```\n\nYour webservice should be started now.  You can try driving your robot with buttons or arrow keys\n\n#### camera\n\nIn order to stream from the camera you can use RPi-cam.  It's documented at http://elinux.org/RPi-Cam-Web-Interface but you can also just run the following\n\n```\ngit clone https://github.com/silvanmelchior/RPi_Cam_Web_Interface.git\ncd RPi_Cam_Web_Interface\nchmod u+x *.sh\n./install.sh\n```\n\nNow a stream of images from the camera should be constantly updating the file at /dev/shm/mjpeg.  Nginx will serve up the image directly if you request localhost/cam.jpg.\n\n#### tensorflow\n\nThere is a great project at https://github.com/samjabrahams/tensorflow-on-raspberry-pi that gives instructions on installing tensorflow on the Raspberry PI.  Recently it's gotten much easier, just do\n\n```\nwget https://github.com/samjabrahams/tensorflow-on-raspberry-pi/releases/download/v0.11.0/tensorflow-0.11.0-cp27-none-linux_armv7l.whl\nsudo pip install tensorflow-0.11.0-cp27-none-linux_armv7l.whl\n```\n\nNext start a tensorflow service that loads up an inception model and does object recognition the the inception model\n\n```\nsudo cp services/inception.service /etc/systemd/system/inception.service\nsudo systemctl daemon-reload\nsudo systemctl enable inception\nsudo systemctl start inception\n```\n\n\n\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flukas%2Frobot","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flukas%2Frobot","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flukas%2Frobot/lists"}