PiCar-X Issues With Robot-Hat

It seems that when you follow the instructions on:


Certain parts of the car don’t seem to work.

In my investigations, I think it has something to do with changes that have been made to robot-hat that have not been updated in some of the Picar-X example programs.

Specifically, anything that uses the grayscale module seems to be looking for a method that doesn’t exist.

I believe this can be fixed by cloning the robot-hat v2.0 repo but I wanted to get your thoughts.

What system are you using and what version.
After you install the source code, the example does not work properly.
Please check whether there is any error report during the installation process, if so, please provide us the screenshot of the error report.
What is your system version after installing the source code, does the example not work.


I did a fresh install on both a Raspberry Pi 3 and a Raspberry Pi 4 to test my theory.

All of the example programs are broken except TTS because it does not rely on any PWM or ADC pins to run.

Attached below are the two most relevant errors.

I am 90% positive that the issue is because of updates made to the robot-hat or picar-x GitHub repos that change the names and parameters of many functions.

Picar-x is looking for functions in robot-hat that no longer exist with the same name.

You can check this by looking through the recent commits.

I have gotten most things working again on my own by editing both packages so that they now point to the correct functions but it was a pain.

I’ll give you an easy example:

The mine_cart example invokes the get_graycale_data function which in turn tries to invoke the function read from the Grayscale_Module class in the Modules file of robot-hat. This class has no function called read so it returns an error.

This is just one example. I have noticed similar errors in Servo, ADC, and PWM.

I just wanted to let you all know because it completely breaks your entire project.

We have solved the uploading well, you follow the steps below:

  1. Uninstall and remove picar-x, robot_hat
    cd ~
    sudo pip3 uninstall robot_hat
    sudo rm -rf robot_hat
    sudo pip3 uninstall picar-x
    sudo rm -rf picar-x
  2. Reinstall and download picar-x and robot_hat:
    cd ~
    git clone GitHub - sunfounder/robot-hat: Robot Hat python library
    cd robot-hat
    sudo python3 setup.py install

cd ~
git clone -b v2.0 GitHub - sunfounder/picar-x
cd picar-x
sudo python3 setup.py install

At this point you can try running the example again.