SlideShare a Scribd company logo
1 of 28
RUST IS FOR ROBOTS
Building an autonomous vehicle with
Rust and the Raspberry Pi
Andy Grove - Boulder/Denver Rust Meetup - 9/21/16
PLEASE ASK QUESTIONS!
ABOUT ME
• Co-Founder & Chief Architect @ AgilData
• Started in C++, then 20 years Java, now Scala & Rust
• AgilData is building its next product in Rust
• Also offering Rust consultancy and project kick-start
services
• I enjoy being a “Maker” in my spare time
• Digital electronics, robotics, 3D printing, woodworking,
etc, etc.
G-FORCE
(ironic name)
WHY THIS PROJECT?
• I was inspired by the last Rust meetup and I agreed
to give a talk at this one
• Sparkfun Autonomous Vehicle Competition (AVC)
was coming up
• This was a great opportunity for me to learn about
using Rust on the Raspberry Pi and get to share that
knowledge
• And four weeks was plenty of time, right?
OBJECTIVES
• Navigate to pre-determined waypoints (GPS co-ordinates)
• Using GPS and compass to determine location and heading
• Change speed of left/right motors to control movement
• Avoid obstacles
• Using ultra-sonic sensors to detect distance to objects
• Record instrumented video
• Essential for debugging
COMPONENTS
DIGITAL IO INTERFACES
• GPIO - General Purpose IO
• Turning pins on and off, or reading high/low inputs from pins
• SPI - Serial Peripheral Interface
• Four wire interface (MISO, MOSI, SCLK + dedicated SS per slave)
• I2C - Inter-Integrated Circuit (pronounced I-squared-C)
• Two wire interface (SDA - Serial Data & SCL - Serial Clock)
• Each device has unique 7-bit address
• Serial
• Familiar to most of use - same as file or network i/o
WHY RASPBERRY PI?
• Great support for Linux (Raspbian)
• Designed for hacking hardware
• Hardware support for GPIO, SPI, and I2C
• Support for webcams and video processing (with GPU
acceleration)
• USB makes it easy to connect to serial devices
• Built-in WiFi
• All this for $35 !
RASPBERRY PI 3
WHY RUST?• Better performance than Java or scripting languages
(assumption)
• Safe language - nobody wants their robot to fail with a
segmentation fault or null pointer exception
• Crates already exist for interfacing with GPIO, SPI, I2C and
Serial
• Rust is natively supported on the Pi using rustup.rs
• Easy to call existing C libraries such as OpenCV with zero
overhead
SERIAL IO
• Linux presents serial IO devices as files e.g.
/dev/ttyUSB0
• Use udev rules to map to convenient names e.g.
/dev/gps
• USB-Serial adapter required to connect to serial devices
• serial-rs crate makes it easy to configure baud rate,
parity, etc
• Use std::io::Read and std::io::Write to interact with
device
SERIAL IO
PARSING GPS DATA
• GPS data uses NMEA format
• Simple comma-separated format
• Example: $GPGLL,4916.45,N,12311.12,W,225444,A
SPI
• SPI devices are represented as files too!
• Example: /dev/spidev0.0
• Use spidev crate to interact
I2C
• I2C devices are represented as… yes, files!
• Example: /dev/i2c-1
• Use i2cdev crate
GPIO
• GPIO devices are represented as files too, but the sysfs_gpio crate abstracts this
• GPIO is the simplest interface - simply read or write 1 or 0 to an individual pin
• Raspberry Pi does not support analog IO directly
• Suitable for:
• Interacting with digital circuits
• Blinking LEDs
• Not suitable for:
• Driving high current devices like motors
CALLING C CODE
USING FFI
OPENCV
AUGMENTING VIDEO
DEMO
SPARKFUN AVC PRACTICE
https://www.youtube.com/watch?v=IaBiMtyEZOs
WHAT WENT WRONG?
• Ultrasonic sensors aren’t fantastic at detecting hay bales,
especially at an oblique angle
• LIDAR would have been better, but also more $$
• Magnetometer (compass) was not correctly calibrated and
I also hadn’t accounted for magnetic declination (8
degrees!)
• Four weeks wasn’t quite long enough for this project
• But I learned a lot!
RUST/PI CHALLENGES
• Compilation is SLOW on the Pi
• Splitting project into multiple crates helps a lot
• Incremental compilation will be here soon
• Compilation on the Mac natively is not possible since the libraries are
Linux-specific
• Cross-compiling is a pain to set up, but probably worth the investment
• Docker can help
• Severe lack of sample code or existing libraries in Rust for any sensors,
so you have to write your own (using Arduino libraries as a reference)
RESOURCES
WEB SITES
• For inspiration, tutorials, blogs, parts, visit these sites:
• sparkfun.com
• adafruit.com
• instructables.com
• hackaday.com
• make.com
• tindie.com
MAKER COMMUNITY
• Local maker spaces
• Solid State Depot (Boulder)
• The Gizmo Dojo (Broomfield)
• Tinkermill (Longmont)
• Mini Maker Faires
• NoCo Mini Maker Faire (Loveland) - October 8/9
• Denver Mini Maker Faire - Summer 2017
QUESTIONS?
• Source code
• https://github.com/andygrove/rust-avc
• Contact
• Twitter: @andygrove73
• Email: andy.grove@agildata.com
• Blog: http://theotherandygrove.com

More Related Content

What's hot

Using AWS, Terraform, and Ansible to Automate Splunk at Scale
Using AWS, Terraform, and Ansible to Automate Splunk at ScaleUsing AWS, Terraform, and Ansible to Automate Splunk at Scale
Using AWS, Terraform, and Ansible to Automate Splunk at ScaleData Works MD
 
Go: What's Different ?
Go: What's Different ?Go: What's Different ?
Go: What's Different ?Tarun Vashisth
 
Avoiding Data Hotspots at Scale
Avoiding Data Hotspots at ScaleAvoiding Data Hotspots at Scale
Avoiding Data Hotspots at ScaleScyllaDB
 
Developing a Staff-Only Samvera Application
Developing a Staff-Only Samvera ApplicationDeveloping a Staff-Only Samvera Application
Developing a Staff-Only Samvera ApplicationJames Griffin
 
ApacheCon Europe Big Data 2016 – Parquet in practice & detail
ApacheCon Europe Big Data 2016 – Parquet in practice & detailApacheCon Europe Big Data 2016 – Parquet in practice & detail
ApacheCon Europe Big Data 2016 – Parquet in practice & detailUwe Korn
 
Hardware and Software Requirements for Koha
Hardware and Software Requirements for KohaHardware and Software Requirements for Koha
Hardware and Software Requirements for KohaAnil Mishra
 
Python Programming and GIS
Python Programming and GISPython Programming and GIS
Python Programming and GISJohn Reiser
 
Cloud-Friendly Hadoop and Hive - StampedeCon 2013
Cloud-Friendly Hadoop and Hive - StampedeCon 2013Cloud-Friendly Hadoop and Hive - StampedeCon 2013
Cloud-Friendly Hadoop and Hive - StampedeCon 2013StampedeCon
 
Casual mass parallel data processing in Java
Casual mass parallel data processing in JavaCasual mass parallel data processing in Java
Casual mass parallel data processing in JavaAltoros
 
Update on Crimson - the Seastarized Ceph - Seastar Summit
Update on Crimson  - the Seastarized Ceph - Seastar SummitUpdate on Crimson  - the Seastarized Ceph - Seastar Summit
Update on Crimson - the Seastarized Ceph - Seastar SummitScyllaDB
 
Coursera amazon cloudsearch presentation
Coursera amazon cloudsearch presentation Coursera amazon cloudsearch presentation
Coursera amazon cloudsearch presentation Michael Bohlig
 
Infrastructure-as-Code with Pulumi - Better than all the others (like Ansible)?
Infrastructure-as-Code with Pulumi- Better than all the others (like Ansible)?Infrastructure-as-Code with Pulumi- Better than all the others (like Ansible)?
Infrastructure-as-Code with Pulumi - Better than all the others (like Ansible)?Jonas Hecht
 
Infrastructure as "Code" with Pulumi
Infrastructure as "Code" with PulumiInfrastructure as "Code" with Pulumi
Infrastructure as "Code" with PulumiVenura Athukorala
 
Bldr: A Minimalist JSON Templating DSL
Bldr: A Minimalist JSON Templating DSLBldr: A Minimalist JSON Templating DSL
Bldr: A Minimalist JSON Templating DSLAlex Sharp
 
Using S3 Select to Deliver 100X Performance Improvements Versus the Public Cloud
Using S3 Select to Deliver 100X Performance Improvements Versus the Public CloudUsing S3 Select to Deliver 100X Performance Improvements Versus the Public Cloud
Using S3 Select to Deliver 100X Performance Improvements Versus the Public CloudDatabricks
 

What's hot (20)

Using AWS, Terraform, and Ansible to Automate Splunk at Scale
Using AWS, Terraform, and Ansible to Automate Splunk at ScaleUsing AWS, Terraform, and Ansible to Automate Splunk at Scale
Using AWS, Terraform, and Ansible to Automate Splunk at Scale
 
Go: What's Different ?
Go: What's Different ?Go: What's Different ?
Go: What's Different ?
 
Avoiding Data Hotspots at Scale
Avoiding Data Hotspots at ScaleAvoiding Data Hotspots at Scale
Avoiding Data Hotspots at Scale
 
Developing a Staff-Only Samvera Application
Developing a Staff-Only Samvera ApplicationDeveloping a Staff-Only Samvera Application
Developing a Staff-Only Samvera Application
 
ApacheCon Europe Big Data 2016 – Parquet in practice & detail
ApacheCon Europe Big Data 2016 – Parquet in practice & detailApacheCon Europe Big Data 2016 – Parquet in practice & detail
ApacheCon Europe Big Data 2016 – Parquet in practice & detail
 
Hardware and Software Requirements for Koha
Hardware and Software Requirements for KohaHardware and Software Requirements for Koha
Hardware and Software Requirements for Koha
 
Python Programming and GIS
Python Programming and GISPython Programming and GIS
Python Programming and GIS
 
Microsoft Azure + R
Microsoft Azure + RMicrosoft Azure + R
Microsoft Azure + R
 
Cloud-Friendly Hadoop and Hive - StampedeCon 2013
Cloud-Friendly Hadoop and Hive - StampedeCon 2013Cloud-Friendly Hadoop and Hive - StampedeCon 2013
Cloud-Friendly Hadoop and Hive - StampedeCon 2013
 
East Bay Rails: January 2012
East Bay Rails: January 2012East Bay Rails: January 2012
East Bay Rails: January 2012
 
Casual mass parallel data processing in Java
Casual mass parallel data processing in JavaCasual mass parallel data processing in Java
Casual mass parallel data processing in Java
 
Update on Crimson - the Seastarized Ceph - Seastar Summit
Update on Crimson  - the Seastarized Ceph - Seastar SummitUpdate on Crimson  - the Seastarized Ceph - Seastar Summit
Update on Crimson - the Seastarized Ceph - Seastar Summit
 
Coursera amazon cloudsearch presentation
Coursera amazon cloudsearch presentation Coursera amazon cloudsearch presentation
Coursera amazon cloudsearch presentation
 
Intro ror
Intro rorIntro ror
Intro ror
 
LINQ and LINQPad
LINQ and LINQPadLINQ and LINQPad
LINQ and LINQPad
 
Infrastructure-as-Code with Pulumi - Better than all the others (like Ansible)?
Infrastructure-as-Code with Pulumi- Better than all the others (like Ansible)?Infrastructure-as-Code with Pulumi- Better than all the others (like Ansible)?
Infrastructure-as-Code with Pulumi - Better than all the others (like Ansible)?
 
Infrastructure as "Code" with Pulumi
Infrastructure as "Code" with PulumiInfrastructure as "Code" with Pulumi
Infrastructure as "Code" with Pulumi
 
Bldr: A Minimalist JSON Templating DSL
Bldr: A Minimalist JSON Templating DSLBldr: A Minimalist JSON Templating DSL
Bldr: A Minimalist JSON Templating DSL
 
Using S3 Select to Deliver 100X Performance Improvements Versus the Public Cloud
Using S3 Select to Deliver 100X Performance Improvements Versus the Public CloudUsing S3 Select to Deliver 100X Performance Improvements Versus the Public Cloud
Using S3 Select to Deliver 100X Performance Improvements Versus the Public Cloud
 
Evalution about programming language part 1
Evalution about programming language part 1Evalution about programming language part 1
Evalution about programming language part 1
 

Similar to Build an Autonomous Vehicle with Rust and Raspberry Pi

Hardware hacking on the pi; what's js got to do with it
Hardware hacking on the pi; what's js got to do with itHardware hacking on the pi; what's js got to do with it
Hardware hacking on the pi; what's js got to do with itAlexander Roche
 
Raspberrypi best ppt
Raspberrypi best ppt Raspberrypi best ppt
Raspberrypi best ppt SOMRAJ GAUTAM
 
PyData Frankfurt - (Efficient) Data Exchange with "Foreign" Ecosystems
PyData Frankfurt - (Efficient) Data Exchange with "Foreign" EcosystemsPyData Frankfurt - (Efficient) Data Exchange with "Foreign" Ecosystems
PyData Frankfurt - (Efficient) Data Exchange with "Foreign" EcosystemsUwe Korn
 
6 reasons Jubilee could be a Rubyist's new best friend
6 reasons Jubilee could be a Rubyist's new best friend6 reasons Jubilee could be a Rubyist's new best friend
6 reasons Jubilee could be a Rubyist's new best friendForrest Chang
 
Raspberry pi seminar
Raspberry pi seminarRaspberry pi seminar
Raspberry pi seminarAkash Kumar
 
Raspberry Pi Training in Jalandhar
Raspberry Pi Training in JalandharRaspberry Pi Training in Jalandhar
Raspberry Pi Training in JalandharE2MATRIX
 
Raspberry Pi Training in Chandigarh
Raspberry Pi Training in ChandigarhRaspberry Pi Training in Chandigarh
Raspberry Pi Training in ChandigarhE2MATRIX
 
Raspberry Pi Training in Mohali
Raspberry Pi Training in MohaliRaspberry Pi Training in Mohali
Raspberry Pi Training in MohaliE2MATRIX
 
Raspberry Pi Training in Phagwara
Raspberry Pi Training in PhagwaraRaspberry Pi Training in Phagwara
Raspberry Pi Training in PhagwaraE2MATRIX
 
Unit 6 - PART2.pptx
Unit 6 - PART2.pptxUnit 6 - PART2.pptx
Unit 6 - PART2.pptxBLACKSPAROW
 
Raspberry Pi training in Ludhiana
Raspberry Pi training in LudhianaRaspberry Pi training in Ludhiana
Raspberry Pi training in LudhianaE2MATRIX
 
Raspberry Pi Training in Amritsar
Raspberry Pi Training in AmritsarRaspberry Pi Training in Amritsar
Raspberry Pi Training in AmritsarE2MATRIX
 
Scratching the itch, making Scratch for the Raspberry Pie
Scratching the itch, making Scratch for the Raspberry PieScratching the itch, making Scratch for the Raspberry Pie
Scratching the itch, making Scratch for the Raspberry PieESUG
 
Build IoT Applications with C#
Build IoT Applications with C#Build IoT Applications with C#
Build IoT Applications with C#Ken Samson, MISM
 

Similar to Build an Autonomous Vehicle with Rust and Raspberry Pi (20)

Hardware hacking on the pi; what's js got to do with it
Hardware hacking on the pi; what's js got to do with itHardware hacking on the pi; what's js got to do with it
Hardware hacking on the pi; what's js got to do with it
 
Raspberrypi best ppt
Raspberrypi best ppt Raspberrypi best ppt
Raspberrypi best ppt
 
Raspberry pi
Raspberry piRaspberry pi
Raspberry pi
 
PyData Frankfurt - (Efficient) Data Exchange with "Foreign" Ecosystems
PyData Frankfurt - (Efficient) Data Exchange with "Foreign" EcosystemsPyData Frankfurt - (Efficient) Data Exchange with "Foreign" Ecosystems
PyData Frankfurt - (Efficient) Data Exchange with "Foreign" Ecosystems
 
6 reasons Jubilee could be a Rubyist's new best friend
6 reasons Jubilee could be a Rubyist's new best friend6 reasons Jubilee could be a Rubyist's new best friend
6 reasons Jubilee could be a Rubyist's new best friend
 
Raspberry pi
Raspberry piRaspberry pi
Raspberry pi
 
Raspberry pi seminar
Raspberry pi seminarRaspberry pi seminar
Raspberry pi seminar
 
UPNext
UPNextUPNext
UPNext
 
Raspberry Pi Technology
Raspberry Pi Technology Raspberry Pi Technology
Raspberry Pi Technology
 
Rasberry pi
 Rasberry pi Rasberry pi
Rasberry pi
 
Raspberry Pi Training in Jalandhar
Raspberry Pi Training in JalandharRaspberry Pi Training in Jalandhar
Raspberry Pi Training in Jalandhar
 
Raspberry Pi Training in Chandigarh
Raspberry Pi Training in ChandigarhRaspberry Pi Training in Chandigarh
Raspberry Pi Training in Chandigarh
 
Raspberry Pi Training in Mohali
Raspberry Pi Training in MohaliRaspberry Pi Training in Mohali
Raspberry Pi Training in Mohali
 
Raspberry pi
Raspberry pi Raspberry pi
Raspberry pi
 
Raspberry Pi Training in Phagwara
Raspberry Pi Training in PhagwaraRaspberry Pi Training in Phagwara
Raspberry Pi Training in Phagwara
 
Unit 6 - PART2.pptx
Unit 6 - PART2.pptxUnit 6 - PART2.pptx
Unit 6 - PART2.pptx
 
Raspberry Pi training in Ludhiana
Raspberry Pi training in LudhianaRaspberry Pi training in Ludhiana
Raspberry Pi training in Ludhiana
 
Raspberry Pi Training in Amritsar
Raspberry Pi Training in AmritsarRaspberry Pi Training in Amritsar
Raspberry Pi Training in Amritsar
 
Scratching the itch, making Scratch for the Raspberry Pie
Scratching the itch, making Scratch for the Raspberry PieScratching the itch, making Scratch for the Raspberry Pie
Scratching the itch, making Scratch for the Raspberry Pie
 
Build IoT Applications with C#
Build IoT Applications with C#Build IoT Applications with C#
Build IoT Applications with C#
 

Recently uploaded

Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupFlorian Wilhelm
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek SchlawackFwdays
 
SAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxSAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxNavinnSomaal
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr BaganFwdays
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsSergiu Bodiu
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLScyllaDB
 
Search Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdfSearch Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdfRankYa
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Mattias Andersson
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsPixlogix Infotech
 
Artificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxArtificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxhariprasad279825
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxLoriGlavin3
 
Powerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time ClashPowerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time Clashcharlottematthew16
 
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo Day
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo DayH2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo Day
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo DaySri Ambati
 
Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Manik S Magar
 
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...Fwdays
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebUiPathCommunity
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubKalema Edgar
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfAlex Barbosa Coqueiro
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsRizwan Syed
 

Recently uploaded (20)

Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project Setup
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
 
SAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxSAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptx
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platforms
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQL
 
Search Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdfSearch Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdf
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and Cons
 
Artificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxArtificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptx
 
DMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special EditionDMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special Edition
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
 
Powerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time ClashPowerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time Clash
 
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo Day
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo DayH2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo Day
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo Day
 
Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!
 
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio Web
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding Club
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdf
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL Certs
 

Build an Autonomous Vehicle with Rust and Raspberry Pi

  • 1. RUST IS FOR ROBOTS Building an autonomous vehicle with Rust and the Raspberry Pi Andy Grove - Boulder/Denver Rust Meetup - 9/21/16
  • 3. ABOUT ME • Co-Founder & Chief Architect @ AgilData • Started in C++, then 20 years Java, now Scala & Rust • AgilData is building its next product in Rust • Also offering Rust consultancy and project kick-start services • I enjoy being a “Maker” in my spare time • Digital electronics, robotics, 3D printing, woodworking, etc, etc.
  • 5. WHY THIS PROJECT? • I was inspired by the last Rust meetup and I agreed to give a talk at this one • Sparkfun Autonomous Vehicle Competition (AVC) was coming up • This was a great opportunity for me to learn about using Rust on the Raspberry Pi and get to share that knowledge • And four weeks was plenty of time, right?
  • 6. OBJECTIVES • Navigate to pre-determined waypoints (GPS co-ordinates) • Using GPS and compass to determine location and heading • Change speed of left/right motors to control movement • Avoid obstacles • Using ultra-sonic sensors to detect distance to objects • Record instrumented video • Essential for debugging
  • 8. DIGITAL IO INTERFACES • GPIO - General Purpose IO • Turning pins on and off, or reading high/low inputs from pins • SPI - Serial Peripheral Interface • Four wire interface (MISO, MOSI, SCLK + dedicated SS per slave) • I2C - Inter-Integrated Circuit (pronounced I-squared-C) • Two wire interface (SDA - Serial Data & SCL - Serial Clock) • Each device has unique 7-bit address • Serial • Familiar to most of use - same as file or network i/o
  • 9. WHY RASPBERRY PI? • Great support for Linux (Raspbian) • Designed for hacking hardware • Hardware support for GPIO, SPI, and I2C • Support for webcams and video processing (with GPU acceleration) • USB makes it easy to connect to serial devices • Built-in WiFi • All this for $35 !
  • 11. WHY RUST?• Better performance than Java or scripting languages (assumption) • Safe language - nobody wants their robot to fail with a segmentation fault or null pointer exception • Crates already exist for interfacing with GPIO, SPI, I2C and Serial • Rust is natively supported on the Pi using rustup.rs • Easy to call existing C libraries such as OpenCV with zero overhead
  • 12. SERIAL IO • Linux presents serial IO devices as files e.g. /dev/ttyUSB0 • Use udev rules to map to convenient names e.g. /dev/gps • USB-Serial adapter required to connect to serial devices • serial-rs crate makes it easy to configure baud rate, parity, etc • Use std::io::Read and std::io::Write to interact with device
  • 14. PARSING GPS DATA • GPS data uses NMEA format • Simple comma-separated format • Example: $GPGLL,4916.45,N,12311.12,W,225444,A
  • 15. SPI • SPI devices are represented as files too! • Example: /dev/spidev0.0 • Use spidev crate to interact
  • 16. I2C • I2C devices are represented as… yes, files! • Example: /dev/i2c-1 • Use i2cdev crate
  • 17. GPIO • GPIO devices are represented as files too, but the sysfs_gpio crate abstracts this • GPIO is the simplest interface - simply read or write 1 or 0 to an individual pin • Raspberry Pi does not support analog IO directly • Suitable for: • Interacting with digital circuits • Blinking LEDs • Not suitable for: • Driving high current devices like motors
  • 23. WHAT WENT WRONG? • Ultrasonic sensors aren’t fantastic at detecting hay bales, especially at an oblique angle • LIDAR would have been better, but also more $$ • Magnetometer (compass) was not correctly calibrated and I also hadn’t accounted for magnetic declination (8 degrees!) • Four weeks wasn’t quite long enough for this project • But I learned a lot!
  • 24. RUST/PI CHALLENGES • Compilation is SLOW on the Pi • Splitting project into multiple crates helps a lot • Incremental compilation will be here soon • Compilation on the Mac natively is not possible since the libraries are Linux-specific • Cross-compiling is a pain to set up, but probably worth the investment • Docker can help • Severe lack of sample code or existing libraries in Rust for any sensors, so you have to write your own (using Arduino libraries as a reference)
  • 26. WEB SITES • For inspiration, tutorials, blogs, parts, visit these sites: • sparkfun.com • adafruit.com • instructables.com • hackaday.com • make.com • tindie.com
  • 27. MAKER COMMUNITY • Local maker spaces • Solid State Depot (Boulder) • The Gizmo Dojo (Broomfield) • Tinkermill (Longmont) • Mini Maker Faires • NoCo Mini Maker Faire (Loveland) - October 8/9 • Denver Mini Maker Faire - Summer 2017
  • 28. QUESTIONS? • Source code • https://github.com/andygrove/rust-avc • Contact • Twitter: @andygrove73 • Email: andy.grove@agildata.com • Blog: http://theotherandygrove.com