Experimenting implementing PID controller, Kalman Filter and Localization on a robotic hardware car kit.
- Freenove 4WD Car Kit
- Sunfounder Super Starter Learning Kit V3.0 for Raspberry Pi
- DSD Tech HC-05 Bluetooth Serial Pass-through Module Wireless Serial Communicaton with Button for Arduino
-
Put together the Car kit.
-
Load libraries and run pre-built programs to experiment with sensors and actuators.
- Practicing having the car move backwards and forwards
- code

-
Challenge 1: Sense the environment in some way (light, temperature, sound, water level in your plant, etc.) and respond somehow
-
Challenge 2: Affect the environment in some way of your choice (move an object, make a robot drive or fly in a controlled way, turn an appliance on/off, etc…) Note: The environment must be affected by a type of actuator that can be controlled by software.
- Adapted boiler plate code to allow the car to detect objects at varying distances and adjust direction or rotate 180deg to attempt to move around the object
- code

-
Challenge 3 - AI – PID Controller
- Implement a PID controller to keep the car at a certain target distance from an object, e.g., your hand. The car should speed up or slow down depending on the distance from the object.
- I managed to get at least the forward movement working for PID implementation. It was pretty hard but a nice challenge. Getting the alpha error to correlate with a speed and tuning that so the car stopped nicely, accelerated smoothly is tricky. I would have liked to spend more time getting it to drive in reverse. I had to take the 5/4 stop/start out because my code wouldnt loop. At first I just tested for obstacle being too close to the car (car stopped) and far (car could drive forward).
- Then I tried to do an out of range stop. So for this video you can see the car drives forward when the obstacle is within a certain threshold but stops if the obstacle is close or really far out of range.
-
I also experimented with line tracking. There were some interesting lessons around the interferance of the color of flooring and the distinction between the black tape line and the floor. This can be seen in the below video:
Eventually I was successful in getting the car to track a loop albeit with some jittering reamining. This can be seen below:
There were additionally some interesting lessons around the following:
- Not enough power defined in the code to move the car forward
- Favoring driving left
- Frequency of loop() being very high since I didn't have a delay which caused the car to move and sense at very high frequency, and if the sensor readings are changing the car will move very fast between turning and going straight which was causing the jerky movement
- Impact of low batteries on oscillation
- Working towards the objective of keeping the car moving with the black tape as close to the center as possible
- Thinness of black tape line on readability of sensors
- Medium sized lines also helped improve the mapping (half width of electrical tape)
- Object distance detection and reversing the car as necessary








