Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

I2c package needs to be update to work on bookworm #1177

Closed
Ezward opened this issue May 12, 2024 · 3 comments · May be fixed by #1178
Closed

I2c package needs to be update to work on bookworm #1177

Ezward opened this issue May 12, 2024 · 3 comments · May be fixed by #1178
Assignees
Labels
actuators Change that affects the steering and throttle drivers, generally in actuators.py or pins.py bug dependencies Pull requests that update a dependency file

Comments

@Ezward
Copy link
Contributor

Ezward commented May 12, 2024

Users have indicated that PCA9685 is not working on RaspberryPi OS Bookworm. This is likely because we are using a very old an deprecated library that was not updated to handle the change in how gpio is addressed in RaspberryPi OS.

The old dependency is Adafruit_PCA9685, which is marked as deprecated and suggests using Adafruit_CircuitPython_PCA9685.

Adafruit_CircuitPython_PCA9685 has two pieces we need, the PCA9685 class which initialized the PCA9685 bus, address and frequency, and the PWMChannel class, which controls a specific servo channel on the board.

We need to update the code in two places to use the new classes. The first is in the pin specifiers code, pins.py. The pins.py:PCA9685 class should now import the Adafruit_CircuitPython_PCA9685:PCA9685 class to initialize the board. Then for each pin that is created, it will instantiate a [Adafruit_CircuitPython_PCA9685:PWMChannel]((https://github.com/adafruit/Adafruit_CircuitPython_PCA9685/blob/874545d908077baed0be8055cbbc63280a00c034/adafruit_pca9685.py#L51C7-L51C17) to control the pin.

The other place to update is the legacy donkeycar/parts/actuator.py:PCA9685 actuator class. Here we can eliminate duplication by instantiating a pwm pin using the pin providers PwmPinPCA9685 function, calling it with the pca9685 factory method to get the shared driver. If we do that then all the PCA9685 code is in one place.

@Ezward Ezward added bug dependencies Pull requests that update a dependency file actuators Change that affects the steering and throttle drivers, generally in actuators.py or pins.py labels May 12, 2024
@Ezward Ezward self-assigned this May 12, 2024
@Ezward
Copy link
Contributor Author

Ezward commented May 12, 2024

Removing the old driver and install the new one only changes that one package; all the other related packages are not affected. That is good news.

(env) ed@raspberrypi5:~/projects/donkeycar $ pip uninstall Adafruit_PCA9685
Found existing installation: Adafruit-PCA9685 1.0.1
Uninstalling Adafruit-PCA9685-1.0.1:
  Would remove:
    /home/ed/projects/donkeycar/env/lib/python3.11/site-packages/Adafruit_PCA9685-1.0.1.dist-info/*
    /home/ed/projects/donkeycar/env/lib/python3.11/site-packages/Adafruit_PCA9685/*
Proceed (Y/n)? Y
  Successfully uninstalled Adafruit-PCA9685-1.0.1
(env) ed@raspberrypi5:~/projects/donkeycar $ pip3 install adafruit-circuitpython-pca9685
Looking in indexes: https://pypi.org/simple, https://www.piwheels.org/simple
Collecting adafruit-circuitpython-pca9685
  Downloading https://www.piwheels.org/simple/adafruit-circuitpython-pca9685/adafruit_circuitpython_pca9685-3.4.15-py3-none-any.whl (6.0 kB)
Requirement already satisfied: Adafruit-Blinka in ./env/lib/python3.11/site-packages (from adafruit-circuitpython-pca9685) (8.39.1)
Requirement already satisfied: adafruit-circuitpython-register in ./env/lib/python3.11/site-packages (from adafruit-circuitpython-pca9685) (1.9.18)
Requirement already satisfied: adafruit-circuitpython-busdevice in ./env/lib/python3.11/site-packages (from adafruit-circuitpython-pca9685) (5.2.9)
Requirement already satisfied: Adafruit-PlatformDetect>=3.62.0 in ./env/lib/python3.11/site-packages (from Adafruit-Blinka->adafruit-circuitpython-pca9685) (3.62.0)
Requirement already satisfied: Adafruit-PureIO>=1.1.7 in ./env/lib/python3.11/site-packages (from Adafruit-Blinka->adafruit-circuitpython-pca9685) (1.1.11)
Requirement already satisfied: pyftdi>=0.40.0 in ./env/lib/python3.11/site-packages (from Adafruit-Blinka->adafruit-circuitpython-pca9685) (0.55.4)
Requirement already satisfied: adafruit-circuitpython-typing in ./env/lib/python3.11/site-packages (from Adafruit-Blinka->adafruit-circuitpython-pca9685) (1.10.3)
Requirement already satisfied: RPi.GPIO in /usr/lib/python3/dist-packages (from Adafruit-Blinka->adafruit-circuitpython-pca9685) (0.7.1a4)
Requirement already satisfied: rpi-ws281x>=4.0.0 in ./env/lib/python3.11/site-packages (from Adafruit-Blinka->adafruit-circuitpython-pca9685) (5.0.0)
Requirement already satisfied: sysv-ipc>=1.1.0 in ./env/lib/python3.11/site-packages (from Adafruit-Blinka->adafruit-circuitpython-pca9685) (1.1.0)
Requirement already satisfied: typing-extensions~=4.0 in ./env/lib/python3.11/site-packages (from adafruit-circuitpython-register->adafruit-circuitpython-pca9685) (4.11.0)
Requirement already satisfied: adafruit-circuitpython-requests in ./env/lib/python3.11/site-packages (from adafruit-circuitpython-typing->Adafruit-Blinka->adafruit-circuitpython-pca9685) (3.2.8)
Requirement already satisfied: pyusb!=1.2.0,>=1.0.0 in ./env/lib/python3.11/site-packages (from pyftdi>=0.40.0->Adafruit-Blinka->adafruit-circuitpython-pca9685) (1.2.1)
Requirement already satisfied: pyserial>=3.0 in /usr/lib/python3/dist-packages (from pyftdi>=0.40.0->Adafruit-Blinka->adafruit-circuitpython-pca9685) (3.5)
Requirement already satisfied: Adafruit-Circuitpython-ConnectionManager in ./env/lib/python3.11/site-packages (from adafruit-circuitpython-requests->adafruit-circuitpython-typing->Adafruit-Blinka->adafruit-circuitpython-pca9685) (2.0.0)
Installing collected packages: adafruit-circuitpython-pca9685
Successfully installed adafruit-circuitpython-pca9685-3.4.15

@Ezward
Copy link
Contributor Author

Ezward commented May 13, 2024

Branch: https://github.com/autorope/donkeycar/tree/1177-update-i2c-driver-for-bookwork

  • no changes to user configuration should be required.
  • The bus number argument is now ignored. The I2C bus device is auto detected using Adafruit Blinka board interface, which is implemented for RaspberryPi, but may not be implemented for other SBCs. It also has one for generic embedded linux. I'm not sure if the this will work on the NVIDIA Jetson Nano or other NVIDIA Jetson devices, although this tutorial suggests it will. We will need to test. See boards.py and busio.py

@Ezward
Copy link
Contributor Author

Ezward commented May 20, 2024

I've tested main (donkey 5.1dev1) and it works fine on a RaspberryPi 5 with RaspberryPi OS bookworm. So I am closing this issue because we do not need it right now. I'm closing the associated PR #1178 as well. That code has some bug i the throttle output, but is mostly complete, so I'll keep the branch around in case we decide we want to do this work in the future.

@Ezward Ezward closed this as completed May 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
actuators Change that affects the steering and throttle drivers, generally in actuators.py or pins.py bug dependencies Pull requests that update a dependency file
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant