01/15/2021 at 19:39 •
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 :)
05/24/2020 at 08:00 •
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!