This is a rover I've been developing to knock some rust off of some old autonomous rover work I've done in the past as well as take advantage of the new Community Edition of LabVIEW that's been released and includes support for deploying to Raspberry Pis and BeagleBone Blacks among other included microcontroller integrations.
The rover is comprised of a Raspberry Pi (currently a 2B) that will be handling the high level integration and planning based on the various sensors. There's an ATmega328p in the base that handles the odometry and motor control maths that's connected to the Pi via I2C. The rover also has an Adafruit ultimate GPS, BNO055 IMU, and will eventually include a set of 6-8 sonars for low level obstacle avoidance and an XV-11 lidar for mapping and planning. The sonars will be coordinated via an additional Arduino Nano clone and the Lidar will also be interfaced with an arduino nano that will forward everything to the Pi.
Raspberry Pi 2B
Arduino Nano clone
Motor control, Sonar coordination, lidar interfacing
Adafruit small caster wheels
Sparkfun 1000mAh 7.4V LiPo batteries
Well Hackaday shared this on Twitter so I might as well post some news about this!
TL;DR I was using my PC's hard drive mounting screws for the casters but then I needed to mount hard drives...
I'm still working with all the code I wrote for the 2 wheeled rover but have currently moved everything over to a tank chassis after needing the mounting screws used for the caster back. It's one of those pre-assembled $50 jobbies from amazon and has 9V motors with encoders mounted:
I'm already on my third revision of the chassis design, as shown from an in progress Fusion360 capture below. I've been able to mount the motor batteries within the chassis itself saving a lot of space and I created a standoff adapter from the chassis that the electronics enclosure mounts to that holds the USB battery pack that powers the Pi and sensors.
One thing I'll be working on with this rover is getting back into mapping and obstacle avoidance to get more autonomous behaviors. This rover has 6 sonars arranged around the perimeter which will allow for rough mapping / localization in an enclosed environment but will mainly be used for determining when we can drive forward and turn. To ensure the best consistency of the sonars there's also a DHT22 humidity and temperature sensor exposed to the outside to calculate more accurate speed of sound in variable conditions. For outdoor usage the main navigation sensor will still be the GPS.
Another component I've fit in is the 16 channel servo driver board that will also connect up to the Pi over the I2C bus. Initially this will be used for a pan/tilt camera system for the Pi's camera. This will be setup a bit better than most camera pan tilts as the brackets will keep the camera lens at the center of rotation which will make vision processing much easier when trying to map back to local frame coordinates. It will also make remote operation of the rover nicer since you'll be able to look around while driving forward, for instance.
I've decided that one of my first full-up tasks with this will be to create an overlay interface for Twitch streams that will allow viewing the sensor data in real time as well as providing controls via keyboard or gamepad/joystick to drive the rover and the pan/tilt. Before I get to that point I'll likely have one more revision of the electronics enclosure as there were a few things in it that I didn't account for properly so I had to cut some mounting posts out or let one of the sonars stick out of the enclosure a bit instead of being flush like the others visible above.
Moving to the tank chassis and its different motor setup has created quite a few complications for the code I wrote for the wheeled chassis. These encoders count so much slower than the wheeled rover (about 20 times slower) that the loop rates I was able to hit for the wheeled rover weren't providing enough counts per iteration to get good velocity calculations and PID control. I had to slow the loop rate down from 100hz on the ATmega328 being used for motor control down to 10Hz and now it works though it still doesn't have the velocity resolution I'd prefer. It's more than enough to move forward though and I'm probably just being overly pedantic for a hobby+ level rover :)
I've figured out where my problems were coming from with the PID velocity control!
1. I was trying to be too efficient. Trying to reuse the volatile variables means they were likely updating in the middle of a PID routine resulting in drastically incorrect floating point representations for some of the tuning parameters and control setpoints causing the PID calculations to basically stop. I've since setup signalling from the ISR handlers to the main loop so that the main loop can know when to pull volatile variables into local non-volatile variables that are used in odometry and velocity control.
2. I'm occasionally missing capturing when the I2C library should be receiving a value as a register location instead of register content data. This was resulting in the output range max value getting set to 0 which of course means no more PID output. Still need to track down why this is happening but I'm very close to getting to very tight joystick control of the rover!